-
Notifications
You must be signed in to change notification settings - Fork 1k
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
eLabFTW file source from file source templates #19493
base: dev
Are you sure you want to change the base?
Conversation
def get_prefix(self) -> Optional[str]: | ||
return None | ||
def get_prefix(self, user_context: OptionalUserContext = None) -> Optional[str]: | ||
endpoint: ParseResult = self._get_endpoint(user_context=user_context) | ||
return self.id if self.scheme not in {"elabftw", DEFAULT_SCHEME} else (endpoint.netloc or None) | ||
# it would make better sense to return | ||
# `self.id if self.scheme == USER_FILE_SOURCES_SCHEME else (endpoint.netloc or None)`, where | ||
# `USER_FILE_SOURCES_SCHEME` comes from `galaxy.managers.file_source_instances`; however, that would lead to a | ||
# circular import (maybe `USER_FILE_SOURCES_SCHEME` should be moved to a module in a layer deeper than | ||
# `galaxy.managers`) | ||
|
||
def get_scheme(self) -> str: | ||
return "elabftw" | ||
return self.scheme if self.scheme and self.scheme != DEFAULT_SCHEME else "elabftw" | ||
# it would make better sense to return `self.scheme if self.scheme == USER_FILE_SOURCES_SCHEME else "elabftw"`, | ||
# but the same circular import issue as above arises |
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.
If this ended up being so weird there must be something I am not getting about the scheme... Where are schemes other than "gxfiles" and "gxuserfiles" coming from? The design intended in #19319 with a URI that only depends on the configured endpoint is not how things are supposed to work, right?
File sources reference files via a URI, while eLabFTW uses auto-incrementing positive integers. For more details read #18665 [5]. This leads to the need to declare a mapping between said identifiers and Galaxy URIs.
Those take the form
elabftw://demo.elabftw.net/entity_type/entity_id attachment_id
, where:
entity_type
is either 'experiments' or 'resources'entity_id
is the id (an integer in string form) of an experiment or resourceattachment_id
is the id (an integer in string form) of an attachmentFor the user-defined file sources use case (when users configure one or more instances of the FilesSource via a file source template), Galaxy URIs have a different scheme and authority, taking the form
gxuserfiles://file_source_id/entity_type/entity_id/attachment_id
, where:
file_source_id
is the file source identifier assigned by Galaxy
FYI @bgruening |
@@ -804,7 +849,7 @@ def _write_from( | |||
entity_type, entity_id, attachment_id = match.groups() | |||
entity_type = entity_type.replace("items", "resources") | |||
|
|||
return f"elabftw://{location.netloc}/{entity_type}/{entity_id}/{attachment_id}" | |||
return f"/{entity_type}/{entity_id}/{attachment_id}" |
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.
Should've been part of #19319 (bugfix).
Support user-defined file sources based on `eLabFTWFilesSource`. Add a file source template for eLabFTW and the required documentation.
cf60ef4
to
f0e4866
Compare
Support user-defined file sources based on
eLabFTWFilesSource
. Add a file source template for eLabFTW and the required documentation.How to test the changes?
(Select all options that apply)
License