Skip to content

Update zenodo dataset for tests (ref #420) #454

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

Merged
merged 2 commits into from
Jun 29, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Update Zenodo datasets used in tests (\#454).

# 0.10.0

* Restructure the package and repository:
Expand Down
29 changes: 2 additions & 27 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import logging
import os
import shutil
from pathlib import Path
Expand Down Expand Up @@ -70,7 +69,7 @@ def zenodo_images_multiplex(testdata_path, zenodo_images):
@pytest.fixture(scope="session")
def zenodo_zarr(testdata_path, tmpdir_factory):

doi = "10.5281/zenodo.7674545"
doi = "10.5281/zenodo.8091756"
rootfolder = testdata_path / (doi.replace(".", "_").replace("/", "_"))
platenames = ["plate.zarr", "plate_mip.zarr"]
folders = [rootfolder / plate for plate in platenames]
Expand All @@ -86,37 +85,13 @@ def zenodo_zarr(testdata_path, tmpdir_factory):
]
for zarrname, folder in zip(zarrnames, folders):
zipname = f"{zarrname}.zip"
url = f"https://zenodo.org/record/7674545/files/{zipname}"
url = f"https://zenodo.org/record/8091756/files/{zipname}"
wget.download(url, out=str(tmp_path / zipname), bar=None)
shutil.unpack_archive(
str(tmp_path / zipname), extract_dir=rootfolder, format="zip"
)
shutil.move(str(rootfolder / zarrname), str(folder))

# Fix a wrong piece of metadata
zattrs_path = folder / "B/03/0/.zattrs"
logging.warning(
f"Update coordinateTransformations in {str(zattrs_path)}, "
"see https://github.com/fractal-analytics-platform/"
"fractal-tasks-core/issues/420."
)
with zattrs_path.open("r") as f:
zattrs = json.load(f)
for ind, ds in enumerate(zattrs["multiscales"][0]["datasets"]):
new_ds = ds.copy()
old_transf = ds["coordinateTransformations"][0]
new_transf = old_transf.copy()
assert old_transf["type"] == "scale"
assert len(old_transf["scale"]) == 3
new_transf["scale"] = [1.0, *old_transf["scale"]]
new_ds["coordinateTransformations"][0] = new_transf
assert len(new_transf["scale"]) == len(
zattrs["multiscales"][0]["axes"]
)
zattrs["multiscales"][0]["datasets"][ind] = new_ds
with zattrs_path.open("w") as f:
json.dump(zattrs, f, indent=2)

folders = [str(f) for f in folders]

return folders
Expand Down