Skip to content

Commit 574b7e1

Browse files
committed
Added one data
1 parent 0a9d0a0 commit 574b7e1

File tree

7 files changed

+74
-5
lines changed

7 files changed

+74
-5
lines changed

lib/galaxy/dependencies/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ def check_fs_googledrivefs(self):
238238
def check_fs_gcsfs(self):
239239
return 'googlecloudstorage' in self.file_sources
240240

241+
def check_fs_onedatafs(self):
242+
return 'onedata' in self.file_sources
243+
241244
def check_watchdog(self):
242245
install_set = {'auto', 'True', 'true', 'polling', True}
243246
return (self.config['watch_tools'] in install_set

lib/galaxy/dependencies/conditional-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ s3fs # type: s3fs
2222
fs.anvilfs # type: anvil
2323
fs.googledrivefs # type: googledrive
2424
fs-gcsfs # type: googlecloudstorage
25+
fs-onedatafs # type: onedata
2526

2627
# Chronos client
2728
chronos-python==1.2.1
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
try:
2+
from fs.onedatafs import OnedataFS
3+
except ImportError:
4+
OnedataFS = None
5+
6+
from ._pyfilesystem2 import PyFilesystem2FilesSource
7+
8+
9+
class OneDataFilesSource(PyFilesystem2FilesSource):
10+
plugin_type = 'onedata'
11+
required_module = OnedataFS
12+
required_package = "fs-onedatafs"
13+
14+
def _open_fs(self, user_context):
15+
props = self._serialization_props(user_context)
16+
handle = OnedataFS(**props)
17+
return handle
18+
19+
20+
__all__ = ('OneDataFilesSource',)

test/unit/files/_util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def user_context_fixture(user_ftp_dir=None, role_names=None, group_names=None, i
6060
'googledrive|client_id': os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_CLIENT_ID'),
6161
'googledrive|client_secret': os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_CLIENT_SECRET'),
6262
'googlecloudstorage|project': os.environ.get('GALAXY_TEST_GCS_PROJECT'),
63-
'googlecloudstorage|bucket_name': 'genomics-public-data'
63+
'googlecloudstorage|bucket_name': 'genomics-public-data',
64+
'onedata|provider_host': os.environ.get('GALAXY_TEST_ONEDATA_PROVIDER_HOST'),
65+
'onedata|access_token': os.environ.get('GALAXY_TEST_ONEDATA_ACCESS_TOKEN'),
6466
},
6567
role_names=role_names or set(),
6668
group_names=group_names or set(),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- type: onedata
2+
id: test1
3+
doc: Test access to a OneData host
4+
provider_host: ${user.preferences['onedata|provider_host']}
5+
access_token: ${user.preferences['onedata|access_token']}

test/unit/files/test_googledrive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
skip_if_no_google_drive_access_token = pytest.mark.skipif(
1515
not os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_ACCESS_TOKEN')
16-
and os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_REFRESH_TOKEN')
17-
and os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_CLIENT_ID')
18-
and os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_CLIENT_SECRET'),
19-
reason="GALAXY_TEST_GOOGLE_DRIVE_ACCESS_TOKEN not set"
16+
and not os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_REFRESH_TOKEN')
17+
and not os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_CLIENT_ID')
18+
and not os.environ.get('GALAXY_TEST_GOOGLE_DRIVE_CLIENT_SECRET'),
19+
reason="GALAXY_TEST_GOOGLE_DRIVE_ACCESS_TOKEN and related vars not set"
2020
)
2121

2222

test/unit/files/test_onedata.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
3+
import pytest
4+
5+
from galaxy.files import ConfiguredFileSources, ConfiguredFileSourcesConfig
6+
from ._util import (
7+
assert_realizes_as,
8+
find_file_a,
9+
user_context_fixture,
10+
)
11+
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
12+
FILE_SOURCES_CONF = os.path.join(SCRIPT_DIRECTORY, "onedata_file_sources_conf.yml")
13+
14+
skip_if_no_onedata_access_token = pytest.mark.skipif(
15+
not os.environ.get('GALAXY_TEST_ONEDATA_PROVIDER_HOST')
16+
and not os.environ.get('GALAXY_TEST_ONEDATA_ACCESS_TOKEN'),
17+
reason="GALAXY_TEST_ONEDATA_PROVIDER_HOST and GALAXY_TEST_ONEDATA_ACCESS_TOKEN not set"
18+
)
19+
20+
21+
@skip_if_no_onedata_access_token
22+
def test_file_source():
23+
user_context = user_context_fixture()
24+
file_sources = _configured_file_sources()
25+
file_source_pair = file_sources.get_file_source_path("gxfiles://test1")
26+
27+
assert file_source_pair.path == "/"
28+
file_source = file_source_pair.file_source
29+
res = file_source.list("/", recursive=False, user_context=user_context)
30+
a_file = find_file_a(res)
31+
assert a_file
32+
33+
assert_realizes_as(file_sources, "gxfiles://test1/a", "a\n", user_context=user_context)
34+
35+
36+
def _configured_file_sources(conf_file=FILE_SOURCES_CONF):
37+
file_sources_config = ConfiguredFileSourcesConfig()
38+
return ConfiguredFileSources(file_sources_config, conf_file=conf_file)

0 commit comments

Comments
 (0)