diff --git a/lib/galaxy/config/sample/file_sources_conf.yml.sample b/lib/galaxy/config/sample/file_sources_conf.yml.sample index e8fdf524b5d9..d9032e0bfe88 100644 --- a/lib/galaxy/config/sample/file_sources_conf.yml.sample +++ b/lib/galaxy/config/sample/file_sources_conf.yml.sample @@ -197,3 +197,10 @@ doc: Invenio RDM turn-key research data management repository label: Invenio RDM Demo Repository url: https://inveniordm.web.cern.ch/ + +- type: onedata + id: onedata1 + label: Onedata + doc: Your Onedata files - configure an access token via user preferences + accessToken: ${user.preferences['onedata|access_token']} + onezoneDomain: ${user.preferences['onedata|onezone_domain']} diff --git a/lib/galaxy/config/sample/user_preferences_extra_conf.yml.sample b/lib/galaxy/config/sample/user_preferences_extra_conf.yml.sample index 51d5aa8b9aa4..068c92918c3e 100644 --- a/lib/galaxy/config/sample/user_preferences_extra_conf.yml.sample +++ b/lib/galaxy/config/sample/user_preferences_extra_conf.yml.sample @@ -111,3 +111,16 @@ preferences: label: Whether to make draft records publicly available or restricted. type: boolean required: False + + # Used in file_sources_conf.yml + onedata: + description: Your Onedata account + inputs: + - name: onezone_domain + label: Domain of the Onezone service (e.g. "demo.onedata.org") + type: text + required: False + - name: access_token + label: Your access token, suitable for REST API access in a Oneprovider service + type: password + required: False diff --git a/lib/galaxy/dependencies/__init__.py b/lib/galaxy/dependencies/__init__.py index 1530b48fb3cd..aca4c3fd8e84 100644 --- a/lib/galaxy/dependencies/__init__.py +++ b/lib/galaxy/dependencies/__init__.py @@ -265,7 +265,7 @@ def check_fs_gcsfs(self): def check_google_cloud_storage(self): return "googlecloudstorage" in self.file_sources - def check_fs_onedatafs(self): + def check_fs_onedatarestfs(self): return "onedata" in self.file_sources def check_fs_basespace(self): diff --git a/lib/galaxy/dependencies/conditional-requirements.txt b/lib/galaxy/dependencies/conditional-requirements.txt index 6c7a0cc38f35..52278d07cbd3 100644 --- a/lib/galaxy/dependencies/conditional-requirements.txt +++ b/lib/galaxy/dependencies/conditional-requirements.txt @@ -24,7 +24,7 @@ fs.googledrivefs # type: googledrive fs-gcsfs # type: googlecloudstorage # fs-gcsfs doesn't pin google-cloud-storage, and old versions log noisy exceptions and break test discovery google-cloud-storage>=2.8.0 # type: googlecloudstorage -fs-onedatafs # type: onedata +fs.onedatarestfs # type: onedata fs-basespace # type: basespace # Vault backend diff --git a/lib/galaxy/files/sources/onedata.py b/lib/galaxy/files/sources/onedata.py index 78f04230d5e0..986ca0feec4e 100644 --- a/lib/galaxy/files/sources/onedata.py +++ b/lib/galaxy/files/sources/onedata.py @@ -1,30 +1,32 @@ try: - from fs.onedatafs import OnedataFS + from fs.onedatarestfs import OnedataRESTFS except ImportError: - OnedataFS = None + OnedataRESTFS = None -from typing import ( - Optional, - Union, -) +from typing import Optional -from . import ( - FilesSourceOptions, - FilesSourceProperties, -) +from . import FilesSourceOptions from ._pyfilesystem2 import PyFilesystem2FilesSource -class OneDataFilesSource(PyFilesystem2FilesSource): +def remove_prefix(prefix, string): + if string.startswith(prefix): + string = string[len(prefix) :] + return string + + +class OnedataFilesSource(PyFilesystem2FilesSource): plugin_type = "onedata" - required_module = OnedataFS - required_package = "fs-onedatafs" + required_module = OnedataRESTFS + required_package = "fs.onedatarestfs" def _open_fs(self, user_context=None, opts: Optional[FilesSourceOptions] = None): props = self._serialization_props(user_context) - extra_props: Union[FilesSourceProperties, dict] = opts.extra_props or {} if opts else {} - handle = OnedataFS(**{**props, **extra_props}) + onezone_domain = props.pop("onezoneDomain", "") or "" + onezone_domain = remove_prefix("http://", remove_prefix("https://", onezone_domain)) + access_token = props.pop("accessToken", "") or "" + handle = OnedataRESTFS(onezone_domain, access_token) return handle -__all__ = ("OneDataFilesSource",) +__all__ = ("OnedataFilesSource",)