Warning
This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
galaxy.files.sources package¶
- class galaxy.files.sources.FilesSourceProperties(**kwargs)[source]¶
Bases:
TypedDict
Initial set of properties used to initialize a filesource.
Filesources can extend this typed dict to define any additional filesource specific properties.
- file_sources_config: typing_extensions.NotRequired[ConfiguredFileSourcesConfig]¶
- class galaxy.files.sources.FilesSourceOptions(writeable: ~typing.Optional[bool] = False, extra_props: ~typing.Optional[~galaxy.files.sources.FilesSourceProperties] = <factory>)[source]¶
Bases:
object
Options to control behavior of file source operations, such as realize_to, write_from and list.
- extra_props: Optional[FilesSourceProperties]¶
- class galaxy.files.sources.SingleFileSource[source]¶
Bases:
object
Represents a protocol handler for a single remote file that can be read by or written to by Galaxy. A remote file source can typically handle a url like https://galaxyproject.org/myfile.txt or drs://myserver/123456. The filesource abstraction allows programmatic control over the specific source to access, injection of credentials and access control. Filesources are typically listed and configured through file_sources_conf.yml or programmatically, as required.
Filesources can be contextualized with a user_context, which contains information related to the current user attempting to access that filesource such as the username, preferences, roles etc., which can then be used by the filesource to make authorization decisions or inject credentials.
Filesources are loaded through Galaxy’s plugin system in galaxy.util.plugin_config.
- abstract user_has_access(user_context) bool [source]¶
Return a boolean indicating whether the user can access the FileSource.
- abstract realize_to(source_path: str, native_path: str, user_context=None, opts: Optional[FilesSourceOptions] = None)[source]¶
Realize source path (relative to uri root) to local file system path.
- Parameters:
source_path (str) – url of the source file to copy from. e.g. https://galaxyproject.org/myfile.txt
native_path (str) – local path to write to. e.g. /tmp/myfile.txt
user_context (FileSourceDictifiable, optional) – A user context , defaults to None
opts (Optional[FilesSourceOptions], optional) – A set of options to exercise additional control over the realize_to method. Filesource specific, defaults to None
- abstract write_from(target_path: str, native_path: str, user_context=None, opts: Optional[FilesSourceOptions] = None)[source]¶
Write file at native path to target_path (relative to uri root).
- Parameters:
target_path (str) – url of the target file to write to within the filesource. e.g. gxfiles://myftp1/myfile.txt
native_path (str) – The local file to read. e.g. /tmp/myfile.txt
user_context (_type_, optional) – A user context , defaults to None
opts (Optional[FilesSourceOptions], optional) – A set of options to exercise additional control over the write_from method. Filesource specific, defaults to None
- abstract score_url_match(url: str) int [source]¶
Return how well a given url matches this filesource. A score greater than zero indicates that this filesource is capable of processing the given url.
Scoring is based on the following rules: a. The maximum score will be the length of the url. b. The minimum score will be the length of the scheme if the filesource can handle the file. c. The score will be zero if the filesource cannot handle the file.
For example, given the following file source config: - type: webdav
id: cloudstor url: “https://cloudstor.aarnet.edu.au” root: “/plus/remote.php/webdav”
type: http id: generic_http
the generic http handler may return a score of 8 for the url https://cloudstor.aarnet.edu.au/plus/remote.php/webdav/myfolder/myfile.txt, as it can handle only the scheme part of the url. A webdav handler may return a score of 55 for the same url, as both the webdav url and root combined are a specific match.
- abstract to_relative_path(url: str) str [source]¶
Convert this url to a filesource relative path. For example, given the url gxfiles://mysource1/myfile.txt it will return /myfile.txt. Protocols directly understood by the handler need not be relativized. For example, the url s3://bucket/myfile.txt can be returned unchanged.
- abstract to_dict(for_serialization=False, user_context=None) FilesSourceProperties [source]¶
Return a dictified representation of this FileSource instance.
If
user_context
is supplied, properties should be written so user context doesn’t need to be present after the plugin is re-hydrated.
- class galaxy.files.sources.SupportsBrowsing[source]¶
Bases:
object
An interface indicating that this filesource is browsable.
Browsable filesources will typically have a root uri from which to start browsing. e.g. In an s3 bucket, the root uri may be gxfiles://bucket1/
They will also have a list method to list files in a specific path within the filesource.
- abstract list(path='/', recursive=False, user_context=None, opts: Optional[FilesSourceOptions] = None) dict [source]¶
Return dictionary of ‘Directory’s and ‘File’s.
- class galaxy.files.sources.FilesSource[source]¶
Bases:
SingleFileSource
,SupportsBrowsing
Represents a combined interface for single or browsable filesources. The get_browsable method can be used to determine whether the filesource is browsable and implements the SupportsBrowsing interface.
- class galaxy.files.sources.BaseFilesSource[source]¶
Bases:
FilesSource
- get_browsable() bool [source]¶
Return true if the filesource implements the SupportsBrowsing interface.
- user_has_access(user_context) bool [source]¶
Return a boolean indicating whether the user can access the FileSource.
- to_relative_path(url: str) str [source]¶
Convert this url to a filesource relative path. For example, given the url gxfiles://mysource1/myfile.txt it will return /myfile.txt. Protocols directly understood by the handler need not be relativized. For example, the url s3://bucket/myfile.txt can be returned unchanged.
- score_url_match(url: str) int [source]¶
Return how well a given url matches this filesource. A score greater than zero indicates that this filesource is capable of processing the given url.
Scoring is based on the following rules: a. The maximum score will be the length of the url. b. The minimum score will be the length of the scheme if the filesource can handle the file. c. The score will be zero if the filesource cannot handle the file.
For example, given the following file source config: - type: webdav
id: cloudstor url: “https://cloudstor.aarnet.edu.au” root: “/plus/remote.php/webdav”
type: http id: generic_http
the generic http handler may return a score of 8 for the url https://cloudstor.aarnet.edu.au/plus/remote.php/webdav/myfolder/myfile.txt, as it can handle only the scheme part of the url. A webdav handler may return a score of 55 for the same url, as both the webdav url and root combined are a specific match.
- to_dict(for_serialization=False, user_context=None) FilesSourceProperties [source]¶
Return a dictified representation of this FileSource instance.
If
user_context
is supplied, properties should be written so user context doesn’t need to be present after the plugin is re-hydrated.
- list(path='/', recursive=False, user_context=None, opts: Optional[FilesSourceOptions] = None)[source]¶
Return dictionary of ‘Directory’s and ‘File’s.
- write_from(target_path, native_path, user_context=None, opts: Optional[FilesSourceOptions] = None)[source]¶
Write file at native path to target_path (relative to uri root).
- Parameters:
target_path (str) – url of the target file to write to within the filesource. e.g. gxfiles://myftp1/myfile.txt
native_path (str) – The local file to read. e.g. /tmp/myfile.txt
user_context (_type_, optional) – A user context , defaults to None
opts (Optional[FilesSourceOptions], optional) – A set of options to exercise additional control over the write_from method. Filesource specific, defaults to None
- realize_to(source_path, native_path, user_context=None, opts: Optional[FilesSourceOptions] = None)[source]¶
Realize source path (relative to uri root) to local file system path.
- Parameters:
source_path (str) – url of the source file to copy from. e.g. https://galaxyproject.org/myfile.txt
native_path (str) – local path to write to. e.g. /tmp/myfile.txt
user_context (FileSourceDictifiable, optional) – A user context , defaults to None
opts (Optional[FilesSourceOptions], optional) – A set of options to exercise additional control over the realize_to method. Filesource specific, defaults to None
Submodules¶
galaxy.files.sources.anvil module¶
galaxy.files.sources.basespace module¶
galaxy.files.sources.dropbox module¶
galaxy.files.sources.ftp module¶
galaxy.files.sources.galaxy module¶
Static Galaxy file sources - ftp and libraries.