Skip to content

Commit

Permalink
Merge pull request #419 from dstansby/check-downloaded-files
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmoore authored Jan 8, 2025
2 parents 6ac9989 + d6a822b commit 6d95fa2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ome_zarr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
28 changes: 28 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -40,6 +50,24 @@ def test_astronaut_download(self, tmpdir):
main(["download", filename, f"--output={out}"])
main(["info", f"{out}/{basename}"])

assert directory_items(Path(out) / "data-3") == [
Path(".zattrs"),
Path(".zgroup"),
Path("0"),
Path("1"),
Path("2"),
Path("3"),
Path("4"),
Path("labels"),
]

assert directory_items(Path(out) / "data-3" / "1") == [
Path(".zarray"),
Path("0"),
Path("1"),
Path("2"),
]

def test_s3_info(self, s3_address):
main(["info", s3_address])

Expand Down

0 comments on commit 6d95fa2

Please sign in to comment.