Fix manual file upload and improve FLASHTnT parsing - #97
Merged
Conversation
Uploading result files in the "Manual Result Upload" tab crashed with
AttributeError: 'UploadedFile' object has no attribute 'suffix'
FileManager.store_file derived the stored file name from `file.suffix`,
which only exists on Path inputs - Streamlit's UploadedFile is a BytesIO
subclass that carries the original file name in `name`.
Two things kept the tab from working once past the crash:
- The dataset id was the part of the file name in front of the known
suffix. FLASHDeconv names its results `out_deconv.mzML` and
`anno_annotated.mzML`, so the two halves of one run were filed under the
datasets "out" and "anno" and never parsed together. Files with the
unchanged tool output names now go to a common dataset, renamed files
(`sample_deconv.mzML`) keep their experiment name as before.
- parseDeconv was called by its pre-refactor signature
(`parseDeconv(**results)`); it writes into the FileManager itself and
needs it plus the dataset id and a logger.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RAyRJPFo13Xn4w8b4B8ju6
The FLASHTnT tab had the same three problems as the FLASHDeconv one: storing an UploadedFile crashed in FileManager.store_file (fixed in the previous commit), the dataset id was the part of the file name in front of the known suffix, and the parsers were called by a signature that no longer exists. FLASHDeconv and FLASHTnT name their results 'out_deconv.mzML', 'anno_annotated.mzML', 'tags.tsv' and 'protein.tsv', so the files of one run were filed under the datasets "out", "anno" and (for the tsv files) not at all - the tab only matched '*_tagged.tsv' and '*_protein.tsv', which FLASHTnT never writes. Files with the unchanged output names now go to a common dataset and 'tags.tsv' is accepted next to the previously expected '*_tagged.tsv'; renamed files keep their experiment name. parseTnT no longer returns dataframes, it writes into the FileManager and needs it plus the dataset id and a logger, and it reads the deconvolution tolerance - so, as in Workflow.execution(), parseDeconv runs first unless the dataset was deconvolved before. Incomplete uploads are reported instead of raising a KeyError. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RAyRJPFo13Xn4w8b4B8ju6
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical bug in manual result upload that prevented Streamlit
UploadedFileobjects from being stored, and refactors the upload workflows to handle tool-generated file names correctly. Also improves FLASHTnT to parse deconvolution data before tag matching.Key Changes
FileManager fix (src/workflow/FileManager.py)
FileManager.store_file()now handles file-like objects (Streamlit'sUploadedFile) that lack asuffixattribute by falling back to extracting the extension from thenameattributeAttributeError: 'UploadedFile' object has no attribute 'suffix'FLASHDeconv upload workflow (content/FLASHDeconv/FLASHDeconvWorkflow.py)
process_uploaded_files()to use a declarativeUPLOAD_FILE_TYPEStuple mapping file suffixes to name tags and tool prefixesdefault_dataset(timestamped) to group files with tool-generated names (out_deconv.mzML,anno_annotated.mzML) that would otherwise split into separate datasetsFLASHTnT upload workflow (content/FLASHTnT/FLASHTnTWorkflow.py)
UPLOAD_FILE_TYPESanddefault_dataset_tagged.tsvfile name (maps totags_tsv)parseDeconv()beforeparseTnT()to ensure deconvolution data is available for tag matchingpartial=Truetoget_results()calls to allow processing with incomplete file setsdeconv_mzML,anno_annotated_mzML,tags_tsv,protein_tsv) before processingTest coverage (tests/test_manual_upload.py)
UploadedFileobjectsPathinputImplementation Details
UPLOAD_FILE_TYPEStuples are defined locally in each workflow page (cannot be imported without Streamlit runtime) and reproduced in tests as literalsexperiment = file.name[:-len(suffix)].rstrip('_')extracts the experiment name, then falls back todefault_datasetif the result is empty or matches the tool prefixdefault_datasetusestime.strftime('uploaded_%Y%m%d-%H%M%S')to create unique, human-readable dataset names for ungrouped uploadshttps://claude.ai/code/session_01RAyRJPFo13Xn4w8b4B8ju6