Skip to content

Commit fd8ca84

Browse files
committed
Create subdirectories
1 parent 82a8cec commit fd8ca84

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

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: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
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

@@ -71,9 +83,31 @@ def test_python_nested_bundle_upload_download(self):
7183
downloaded_file_paths = [object_name_builder(p, dest_dir) for p in downloaded_file_names]
7284
self.assertEqual(uploaded_files.sort(), downloaded_file_paths.sort())
7385

86+
@unittest.skipIf(os.name is 'nt', 'Unable to test on Windows') # TODO windows testing refactor
87+
def test_python_exclamation_replacement(self):
88+
bundle_path = os.path.join(TEST_DIR, "res", "nested_bundle")
89+
uploaded_files = set(get_uploaded_file_names(bundle_path))
90+
91+
bundle_output = self.client.upload(src_dir=bundle_path,
92+
replica="aws",
93+
staging_bucket=self.staging_bucket)
94+
95+
bundle_uuid = bundle_output['bundle_uuid']
96+
bundle_version = bundle_output['version']
97+
bundle_fqid = "{}.{}".format(bundle_uuid, bundle_version)
98+
99+
manifest_files = bundle_output['files']
100+
self.assertEqual({file['name'] for file in manifest_files}, uploaded_files)
101+
102+
with tempfile.TemporaryDirectory() as dest_dir:
103+
self.client.download(bundle_uuid=bundle_output['bundle_uuid'], replica="aws", download_dir=dest_dir)
104+
nested_downloaded_files = [file.name for file in os.scandir('{}/{}/zarr'.format(dest_dir, bundle_fqid))]
105+
for file in ['exclamation.zattrs', 'nested.zattrs']:
106+
self.assertIn(file, nested_downloaded_files)
107+
74108
def test_python_upload_download(self):
75109
bundle_path = os.path.join(TEST_DIR, "res", "bundle")
76-
uploaded_files = set(os.listdir(bundle_path))
110+
uploaded_files = set(get_uploaded_file_names(bundle_path))
77111

78112
manifest = self.client.upload(src_dir=bundle_path,
79113
replica="aws",
@@ -139,7 +173,7 @@ def test_python_upload_download(self):
139173

140174
def test_python_manifest_download(self):
141175
bundle_path = os.path.join(TEST_DIR, "res", "bundle")
142-
uploaded_files = set(os.listdir(bundle_path))
176+
uploaded_files = set(get_uploaded_file_names(bundle_path))
143177

144178
manifest = self.client.upload(src_dir=bundle_path,
145179
replica="aws",
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+
}
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)