diff --git a/ome_zarr/utils.py b/ome_zarr/utils.py index 086ede3d..c929c283 100644 --- a/ome_zarr/utils.py +++ b/ome_zarr/utils.py @@ -129,7 +129,9 @@ def download(input_path: str, output_dir: str = ".") -> None: for dataset, data in reversed(list(zip(datasets, resolutions))): LOGGER.info("resolution %s...", dataset) with pbar: - data.to_zarr(str(target_path / dataset)) + data.to_zarr( + str(target_path / dataset), dimension_separator="/" + ) else: # Assume a group that needs metadata, like labels zarr.group(str(target_path)) diff --git a/tests/test_cli.py b/tests/test_cli.py index 59c4650f..b38aba46 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -8,6 +8,16 @@ from ome_zarr.utils import strip_common_prefix +def directory_items(directory: Path): + """ + Get all items (files and folders) in a directory, relative to that directory. + """ + if not directory.is_dir(): + raise ValueError(f"{directory} is not a directory") + + return sorted([p.relative_to(directory) for p in directory.glob("*")]) + + class TestCli: @pytest.fixture(autouse=True) def initdir(self, tmpdir): @@ -40,9 +50,7 @@ def test_astronaut_download(self, tmpdir): main(["download", filename, f"--output={out}"]) main(["info", f"{out}/{basename}"]) - out_path = Path(out) / "data-3" - paths = [p.relative_to(out_path) for p in out_path.glob("*")] - assert sorted(paths) == [ + assert directory_items(Path(out) / "data-3") == [ Path(".zattrs"), Path(".zgroup"), Path("0"), @@ -53,202 +61,11 @@ def test_astronaut_download(self, tmpdir): Path("labels"), ] - data_path = Path(out) / "data-3" / "1" - paths = [p.relative_to(data_path) for p in data_path.glob("*")] - assert sorted(paths) == [ + assert directory_items(Path(out) / "data-3" / "1") == [ Path(".zarray"), - Path("0.0.0"), - Path("0.0.1"), - Path("0.0.2"), - Path("0.0.3"), - Path("0.0.4"), - Path("0.0.5"), - Path("0.0.6"), - Path("0.0.7"), - Path("0.1.0"), - Path("0.1.1"), - Path("0.1.2"), - Path("0.1.3"), - Path("0.1.4"), - Path("0.1.5"), - Path("0.1.6"), - Path("0.1.7"), - Path("0.2.0"), - Path("0.2.1"), - Path("0.2.2"), - Path("0.2.3"), - Path("0.2.4"), - Path("0.2.5"), - Path("0.2.6"), - Path("0.2.7"), - Path("0.3.0"), - Path("0.3.1"), - Path("0.3.2"), - Path("0.3.3"), - Path("0.3.4"), - Path("0.3.5"), - Path("0.3.6"), - Path("0.3.7"), - Path("0.4.0"), - Path("0.4.1"), - Path("0.4.2"), - Path("0.4.3"), - Path("0.4.4"), - Path("0.4.5"), - Path("0.4.6"), - Path("0.4.7"), - Path("0.5.0"), - Path("0.5.1"), - Path("0.5.2"), - Path("0.5.3"), - Path("0.5.4"), - Path("0.5.5"), - Path("0.5.6"), - Path("0.5.7"), - Path("0.6.0"), - Path("0.6.1"), - Path("0.6.2"), - Path("0.6.3"), - Path("0.6.4"), - Path("0.6.5"), - Path("0.6.6"), - Path("0.6.7"), - Path("0.7.0"), - Path("0.7.1"), - Path("0.7.2"), - Path("0.7.3"), - Path("0.7.4"), - Path("0.7.5"), - Path("0.7.6"), - Path("0.7.7"), - Path("1.0.0"), - Path("1.0.1"), - Path("1.0.2"), - Path("1.0.3"), - Path("1.0.4"), - Path("1.0.5"), - Path("1.0.6"), - Path("1.0.7"), - Path("1.1.0"), - Path("1.1.1"), - Path("1.1.2"), - Path("1.1.3"), - Path("1.1.4"), - Path("1.1.5"), - Path("1.1.6"), - Path("1.1.7"), - Path("1.2.0"), - Path("1.2.1"), - Path("1.2.2"), - Path("1.2.3"), - Path("1.2.4"), - Path("1.2.5"), - Path("1.2.6"), - Path("1.2.7"), - Path("1.3.0"), - Path("1.3.1"), - Path("1.3.2"), - Path("1.3.3"), - Path("1.3.4"), - Path("1.3.5"), - Path("1.3.6"), - Path("1.3.7"), - Path("1.4.0"), - Path("1.4.1"), - Path("1.4.2"), - Path("1.4.3"), - Path("1.4.4"), - Path("1.4.5"), - Path("1.4.6"), - Path("1.4.7"), - Path("1.5.0"), - Path("1.5.1"), - Path("1.5.2"), - Path("1.5.3"), - Path("1.5.4"), - Path("1.5.5"), - Path("1.5.6"), - Path("1.5.7"), - Path("1.6.0"), - Path("1.6.1"), - Path("1.6.2"), - Path("1.6.3"), - Path("1.6.4"), - Path("1.6.5"), - Path("1.6.6"), - Path("1.6.7"), - Path("1.7.0"), - Path("1.7.1"), - Path("1.7.2"), - Path("1.7.3"), - Path("1.7.4"), - Path("1.7.5"), - Path("1.7.6"), - Path("1.7.7"), - Path("2.0.0"), - Path("2.0.1"), - Path("2.0.2"), - Path("2.0.3"), - Path("2.0.4"), - Path("2.0.5"), - Path("2.0.6"), - Path("2.0.7"), - Path("2.1.0"), - Path("2.1.1"), - Path("2.1.2"), - Path("2.1.3"), - Path("2.1.4"), - Path("2.1.5"), - Path("2.1.6"), - Path("2.1.7"), - Path("2.2.0"), - Path("2.2.1"), - Path("2.2.2"), - Path("2.2.3"), - Path("2.2.4"), - Path("2.2.5"), - Path("2.2.6"), - Path("2.2.7"), - Path("2.3.0"), - Path("2.3.1"), - Path("2.3.2"), - Path("2.3.3"), - Path("2.3.4"), - Path("2.3.5"), - Path("2.3.6"), - Path("2.3.7"), - Path("2.4.0"), - Path("2.4.1"), - Path("2.4.2"), - Path("2.4.3"), - Path("2.4.4"), - Path("2.4.5"), - Path("2.4.6"), - Path("2.4.7"), - Path("2.5.0"), - Path("2.5.1"), - Path("2.5.2"), - Path("2.5.3"), - Path("2.5.4"), - Path("2.5.5"), - Path("2.5.6"), - Path("2.5.7"), - Path("2.6.0"), - Path("2.6.1"), - Path("2.6.2"), - Path("2.6.3"), - Path("2.6.4"), - Path("2.6.5"), - Path("2.6.6"), - Path("2.6.7"), - Path("2.7.0"), - Path("2.7.1"), - Path("2.7.2"), - Path("2.7.3"), - Path("2.7.4"), - Path("2.7.5"), - Path("2.7.6"), - Path("2.7.7"), + Path("0"), + Path("1"), + Path("2"), ] def test_s3_info(self, s3_address):