Skip to content

Commit

Permalink
Merge pull request galaxyproject#16690 from lopiola/onedata-files-sou…
Browse files Browse the repository at this point in the history
…rce-plugin

 Use fs.onedatarestfs for Onedata files source plugin implementation
  • Loading branch information
bgruening authored Sep 29, 2023
2 parents 15414b2 + ffb7c76 commit d7cc3e8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
7 changes: 7 additions & 0 deletions lib/galaxy/config/sample/file_sources_conf.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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']}
13 changes: 13 additions & 0 deletions lib/galaxy/config/sample/user_preferences_extra_conf.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/galaxy/dependencies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/dependencies/conditional-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 18 additions & 16 deletions lib/galaxy/files/sources/onedata.py
Original file line number Diff line number Diff line change
@@ -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",)

0 comments on commit d7cc3e8

Please sign in to comment.