Skip to content

Commit 8657a6f

Browse files
committed
Fix coordinateTransformations of Zenodo OME-Zarrs (ref #420)
1 parent b310ce5 commit 8657a6f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/conftest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
import os
34
import shutil
45
from pathlib import Path
@@ -92,6 +93,30 @@ def zenodo_zarr(testdata_path, tmpdir_factory):
9293
)
9394
shutil.move(str(rootfolder / zarrname), str(folder))
9495

96+
# Fix a wrong piece of metadata
97+
zattrs_path = folder / "B/03/0/.zattrs"
98+
logging.warning(
99+
f"Update coordinateTransformations in {str(zattrs_path)}, "
100+
"see https://github.com/fractal-analytics-platform/"
101+
"fractal-tasks-core/issues/420."
102+
)
103+
with zattrs_path.open("r") as f:
104+
zattrs = json.load(f)
105+
for ind, ds in enumerate(zattrs["multiscales"][0]["datasets"]):
106+
new_ds = ds.copy()
107+
old_transf = ds["coordinateTransformations"][0]
108+
new_transf = old_transf.copy()
109+
assert old_transf["type"] == "scale"
110+
assert len(old_transf["scale"]) == 3
111+
new_transf["scale"] = [1.0, *old_transf["scale"]]
112+
new_ds["coordinateTransformations"][0] = new_transf
113+
assert len(new_transf["scale"]) == len(
114+
zattrs["multiscales"][0]["axes"]
115+
)
116+
zattrs["multiscales"][0]["datasets"][ind] = new_ds
117+
with zattrs_path.open("w") as f:
118+
json.dump(zattrs, f)
119+
95120
folders = [str(f) for f in folders]
96121

97122
return folders

0 commit comments

Comments
 (0)