-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow downloading metadata in the sequence detail view #3003
base: main
Are you sure you want to change the base?
Conversation
// This type cast isn't pretty, but if the API would be typed correctly, the union type | ||
// of the actual details resonse and the potential 'string' would polute the whole API, | ||
// so I decided to just do this cast here. We know that the return value is a TSV string. | ||
}).then((result) => result.map((data) => data as unknown as string)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would appreciate input on this. I have fiddled with the Zodios setup quite a bit, but reached the conclusion that this would be the most sensible way to handle the TSV data. Alternatives I considered:
- Get the JSON data from the API and turn it into TSV in somewhere in the backend server (not necessarily in this function). Pros: no casting required. Cons: duplicating the TSV functionality.
- Tried to modify the Zodios API definition and adjusted the Type so it can return a string as well. Pro: Typesafety possible. Cons: the 'string' edgecase polutes all the other regular usages of the endpoint and makes the code much more convoluted in many places.
I think with Zodios the best solution would be to distinguish json and TSV via endpoint, i.e. use a different endpoint alltogether like (sample/details/tsv
- I know, not very RESTy but you get the idea). This way we could have a nicely typed TSV endpoint. But that requires a backend API change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not the right person to comment on this - I don't know my zodios. @fengelniederhammer might have ideas
website/src/components/SequenceDetailsPage/SequencesDataTableTitle.astro
Show resolved
Hide resolved
> | ||
<span class='hidden sm:inline'>Download FASTA</span> | ||
<span class='sm:hidden inline text-xl'> | ||
showDownload && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe it would be nice to just reuse the react DownloadButton component here, but they handle responsiveness differently and are also styled slightly differently and for now I couldn't be bothered to "merge" the two buttons into a single component. If desired I can put some more work into this refactoring so we end up with a single component.
website/src/components/SequenceDetailsPage/SequencesDataTableTitle.astro
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all this work - looks really nice. A few thoughts.
// We don't know which organism the accessionVersion belongs to, | ||
// so we just try all of them until we get a success. | ||
const organisms = getConfiguredOrganisms(); | ||
const results = await Promise.all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking because it's an existing issue but while reading I noticed that this Promise.all
isn't ideal. If one LAPIS instance for one organism is unhealthy and takes 10 secs to respond it will make all organisms take 10 seconds to respond. We use better logic here:
export async function findOrganismAndData(accessionVersion: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer, I've made the change: be67e74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great feature!
be67e74
to
6aad7a7
Compare
6aad7a7
to
24b164d
Compare
resolves #2019
preview URL: https://feat-2019-download-indivi.loculus.org/ [Edited by Theo: fyi this gets truncated so you probably need to look it up in ArgoCD - ping on Slack if you don't have the credentials to access that]
Summary
Turn the download button into a selection dropdown instead, where you can select to either download FASTA or a Metadata TSV.
Screenshot
PR Checklist