Skip to content

Commit e9fe6a3

Browse files
committed
Create subdirectories
1 parent 82a8cec commit e9fe6a3

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

hca/dss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def download_bundle(self, bundle_uuid, version="", metadata_filter=('*',), data_
505505

506506
for file_ in manifest['bundle']['files']:
507507
dss_file = DSSFile.from_dss_bundle_response(file_, self.replica)
508-
filename = file_.get("name", dss_file.uuid)
508+
filename = file_.get("name", dss_file.uuid).replace('!', '/')
509509
walking_dir = bundle_dir
510510

511511
globs = metadata_filter if file_['indexed'] else data_filter

test/integration/dss/test_dss_api.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,24 @@
2121
from test import reset_tweak_changes, TEST_DIR
2222

2323

24+
def get_uploaded_file_names(path: str):
25+
files = []
26+
for entry in os.scandir(path=path):
27+
if entry.is_file():
28+
files.append(entry.name)
29+
if entry.is_dir():
30+
nested_files = get_uploaded_file_names(entry.path)
31+
for file in nested_files:
32+
files.append('{}/{}'.format(entry.name, file))
33+
return files
34+
35+
2436
class TestDssApi(unittest.TestCase):
2537
staging_bucket = "org-humancellatlas-dss-cli-test"
2638

2739
@classmethod
2840
def setUpClass(cls):
29-
cls.client = hca.dss.DSSClient()
41+
cls.client = hca.dss.DSSClient(swagger_url="https://dss.dev.data.humancellatlas.org/v1/swagger.json")
3042

3143
def test_set_host(self):
3244
with tempfile.TemporaryDirectory() as home:
@@ -73,7 +85,7 @@ def test_python_nested_bundle_upload_download(self):
7385

7486
def test_python_upload_download(self):
7587
bundle_path = os.path.join(TEST_DIR, "res", "bundle")
76-
uploaded_files = set(os.listdir(bundle_path))
88+
uploaded_files = set(get_uploaded_file_names(bundle_path))
7789

7890
manifest = self.client.upload(src_dir=bundle_path,
7991
replica="aws",
@@ -139,7 +151,7 @@ def test_python_upload_download(self):
139151

140152
def test_python_manifest_download(self):
141153
bundle_path = os.path.join(TEST_DIR, "res", "bundle")
142-
uploaded_files = set(os.listdir(bundle_path))
154+
uploaded_files = set(get_uploaded_file_names(bundle_path))
143155

144156
manifest = self.client.upload(src_dir=bundle_path,
145157
replica="aws",
@@ -222,9 +234,14 @@ def test_python_bindings(self):
222234
bundle_path = os.path.join(TEST_DIR, "res", "bundle")
223235
bundle_output = self.client.upload(src_dir=bundle_path, replica="aws", staging_bucket=self.staging_bucket)
224236
bundle_uuid = bundle_output['bundle_uuid']
237+
bundle_version = bundle_output['version']
238+
bundle_fqid = "{}.{}".format(bundle_uuid, bundle_version)
225239

226240
with tempfile.TemporaryDirectory() as dest_dir:
227241
self.client.download(bundle_uuid=bundle_output['bundle_uuid'], replica="aws", download_dir=dest_dir)
242+
nested_downloaded_files = [file.name for file in os.scandir('{}/{}/zarr'.format(dest_dir, bundle_fqid))]
243+
for file in ['exclamation.zattrs', 'nested.zattrs']:
244+
self.assertIn(file, nested_downloaded_files)
228245

229246
# Test get-files and head-files
230247
file_ = bundle_output['files'][0]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"README": "The schema adopted in this zarr store may undergo changes in the future",
3+
"sample_id": "0432e9a5-604f-4cb7-8571-014eb5fd8ba2"
4+
}

test/res/bundle/zarr/nested.zattrs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"README": "The schema adopted in this zarr store may undergo changes in the future",
3+
"sample_id": "0432e9a5-604f-4cb7-8571-014eb5fd8ba2"
4+
}

0 commit comments

Comments
 (0)