Feature/gallery upload routing rsdev 1192#56
Open
tilorspace wants to merge 3 commits into
Open
Conversation
When a file is uploaded to a Gallery folder in the wrong media-type section, the RSpace API rejects it and the client raised an opaque ApiError. Re-raise as GallerySectionMismatch naming the folder's section (and the file's guessed media type) with the original error preserved. Detection is reactive: the enriched error is only produced after a real server rejection of a folder-targeted upload, so the best-effort filename classifier can never block an otherwise-valid upload. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an on_mismatch policy to GalleryFilesystem: "raise" (default, the clear error from the previous change) or "reroute", which on a section mismatch re-uploads with no folderId so the server places the file in the correct section's inbox. The policy is set filesystem-wide in the constructor (so it also applies to generic PyFilesystem operations that call upload/openbin) and can be overridden per upload() call. upload() now returns a Placement describing where the file landed (global id, section, human-readable path, and whether it was rerouted). Reroutes are logged at INFO. Document the behaviour in the usage guide. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…EV-1192) Galaxy's RSpace file source monkeypatches eln_client.upload_file with a wrapper that captures the response and returns None, then calls GalleryFilesystem.upload via super(). Change 2 started consuming upload_file's return value to build a Placement, which crashed on that None with AttributeError, breaking every Galaxy->RSpace export. Make _placement tolerate a non-dict/None response and make the best-effort folder-lookup helpers never raise, so a successful upload can never fail during Placement construction. Direct callers still receive a full Placement. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The changes look ok to me. Thanks a lot @tilorspace |
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
Makes the RSpace Gallery a friendlier upload target for
GalleryFilesystem(PyFilesystem) by handling the Gallery's media-type section rule instead of
failing opaquely. Two separable changes plus a Galaxy-compatibility fix.
Jira: RSDEV-1192
Background
The Gallery is split into media-type sections (Images, Audios, Videos,
Documents, Chemistry, ...). A file can only be uploaded into a folder whose
section matches its media type; a mismatched folder is rejected by the API.
Previously
upload()passed the folder straight through, so a mismatch surfacedas an opaque
ApiErrorand the file was lost.What changed (three commits, reviewable in order)
Clearer error (
8bb9e2a) — on a folder-targeted upload the serverrejects, re-raise a
GallerySectionMismatchnaming the folder's section (andthe file's guessed media type), with the original error preserved. Detection
is reactive: it only enriches after a real server rejection, so the
best-effort filename classifier can never block a valid upload.
Opt-in auto-reroute (
7e8e07e) — add anon_mismatchpolicy:"raise"(default) or
"reroute". On reroute, the file is re-uploaded with nofolderIdso the server places it in the correct section's inbox. The policyis set filesystem-wide in the constructor (so it also applies to generic
PyFilesystem operations that call
upload/openbin) and can be overriddenper
upload()call.upload()now returns aPlacementdescribing where thefile landed (global id, section, human-readable path,
reroutedflag).Galaxy-compatibility fix (
6cb1f60) — Galaxy's RSpace file sourcemonkeypatches
eln_client.upload_filewith a wrapper that returnsNone,then calls our
upload()viasuper(). Commit 2 started consuming thatreturn value to build the
Placement, which crashed onNone._placementnow tolerates a non-dict/
Noneresponse and the folder-lookup helpers neverraise, so a successful upload can never fail during
Placementconstruction.API / behaviour