Skip to content

Commit

Permalink
Merge pull request #781 from fractal-analytics-platform/780_mip
Browse files Browse the repository at this point in the history
Fixes for MIP task
  • Loading branch information
jluethi committed Jul 4, 2024
2 parents 674dcac + d2b8644 commit 2a3ae6b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Refactor Cellpose Task inputs: Support independent normalization of 2 input channels in the Cellpose task (\#738).
* Rename `task.cellpose_transforms` into `tasks.cellpose_utils` (\#738).
* Fix wrong repeated overlap checks for bounding-boxes in Cellpose task (\#778).
* Fix minor MIP issues related to plate metadata and expecting acquisition metadata in all NGFF plates(\#781).
* Add chi2_shift option to Calculate Registration (image-based) task(\#741).
* Development:
* Switch to transitional pydantic.v1 imports, changes pydantic requirement to `==1.10.16` or `>=2.6.3` (\#760).
* Support JSON-Schema generation for `Enum` task arguments (\#749).
Expand All @@ -22,6 +24,8 @@
* Improve/extend page showing tasks from other packages (\#759, \#777).
* JSON Schema generation:
* Test manifest creation for three other tasks packages (\#763).
* NGFF subpackage
* Fix Plate model to correspond better to 0.4.0 NGFF spec: Now makes acquisition metadata optional (\#781).

# 1.0.2

Expand Down
2 changes: 1 addition & 1 deletion fractal_tasks_core/ngff/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class Plate(BaseModel):
See https://ngff.openmicroscopy.org/0.4/#plate-md.
"""

acquisitions: list[AcquisitionInPlate]
acquisitions: Optional[list[AcquisitionInPlate]]
columns: list[ColumnInPlate]
field_count: Optional[int]
name: Optional[str]
Expand Down
3 changes: 1 addition & 2 deletions fractal_tasks_core/tasks/copy_ome_zarr_hcs_plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import logging
from typing import Any

import zarr
from pydantic.v1.decorator import validate_arguments

import fractal_tasks_core
Expand Down Expand Up @@ -274,7 +273,7 @@ def copy_ome_zarr_hcs_plate(

# Write well groups:
for well_sub_url in new_well_image_attrs[old_plate_url]:
new_well_group = zarr.group(f"{zarrurl_new}/{well_sub_url}")
new_well_group = new_plate_group.create_group(f"{well_sub_url}")
well_attrs = dict(
well=dict(
images=[
Expand Down
19 changes: 14 additions & 5 deletions tests/tasks/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def test_MIP(
):

# Init
zarr_path = tmp_path / "tmp_out/"
zarr_path = tmp_path / "tmp_out"
debug(zarr_path)

# Load zarr array from zenodo
zenodo_zarr_3D, zenodo_zarr_2D = zenodo_zarr[:]
Expand All @@ -324,15 +325,15 @@ def test_MIP(

parallelization_list = copy_ome_zarr_hcs_plate(
zarr_urls=zarr_urls,
zarr_dir="tmp_out",
zarr_dir=str(zarr_path),
overwrite=True,
)["parallelization_list"]
debug(parallelization_list)

# Run again, with overwrite=True
parallelization_list_2 = copy_ome_zarr_hcs_plate(
zarr_urls=zarr_urls,
zarr_dir="tmp_out",
zarr_dir=str(zarr_path),
overwrite=True,
)["parallelization_list"]
assert parallelization_list_2 == parallelization_list
Expand All @@ -341,7 +342,7 @@ def test_MIP(
with pytest.raises(OverwriteNotAllowedError):
_ = copy_ome_zarr_hcs_plate(
zarr_urls=zarr_urls,
zarr_dir="tmp_out",
zarr_dir=str(zarr_path),
overwrite=False,
)

Expand Down Expand Up @@ -399,6 +400,14 @@ def test_MIP(
assert table_attrs["type"] == "roi_table"
assert table_attrs["fractal_table_version"] == "1"

# Check correct zarr metadata for row folder (issue #780): Checks that
# the one well expected to be in the Zarr plate is discoverable by the
# Zarr API
plate_zarr_group = zarr.open(plate_zarr)
assert len(plate_zarr_group) == 1
row_zarr_group = zarr.open(plate_zarr / "B")
assert len(row_zarr_group) == 1


def test_MIP_subset_of_images(
tmp_path: Path,
Expand Down Expand Up @@ -441,7 +450,7 @@ def test_MIP_subset_of_images(
# Replicate
parallelization_list = copy_ome_zarr_hcs_plate(
zarr_urls=zarr_urls,
zarr_dir="tmp_out",
zarr_dir=str(zarr_dir),
overwrite=True,
)["parallelization_list"]
debug(parallelization_list)
Expand Down

0 comments on commit 2a3ae6b

Please sign in to comment.