Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dimension separator when downloading files #419

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading