Skip to content
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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

fhennig
Copy link
Contributor

@fhennig fhennig commented Oct 15, 2024

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

image

PR Checklist

  • All necessary documentation has been adapted.
  • The implemented feature is covered by an appropriate test.

@fhennig fhennig added the preview Triggers a deployment to argocd label Oct 15, 2024
@fhennig fhennig self-assigned this Oct 15, 2024
Comment on lines +60 to +64
// 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));
Copy link
Contributor Author

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.

Copy link
Member

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

>
<span class='hidden sm:inline'>Download FASTA</span>
<span class='sm:hidden inline text-xl'>
showDownload && (
Copy link
Contributor Author

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.

Copy link
Member

@theosanderson theosanderson left a 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.

@fhennig fhennig changed the title feat: Allow downloading metadata in the sequence preview modal feat: Allow downloading metadata in the sequence detail view Oct 17, 2024
@fhennig fhennig marked this pull request as ready for review October 17, 2024 08:59
// 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(
Copy link
Member

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) {
. If you are willing to do that while touching this code, great, if not we can make an issue

Copy link
Contributor Author

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

Copy link
Member

@theosanderson theosanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great feature!

@corneliusroemer corneliusroemer force-pushed the feat/2019-download-individual-metadata branch from be67e74 to 6aad7a7 Compare October 17, 2024 12:02
@fhennig fhennig force-pushed the feat/2019-download-individual-metadata branch from 6aad7a7 to 24b164d Compare October 17, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Triggers a deployment to argocd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to download individual metadata?
2 participants