Skip to content

Commit

Permalink
Remove ability to write metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Dec 9, 2024
1 parent eacd067 commit a261d38
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ome_zarr_models/v04/image2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class Image2(BaseModel):
This is represented by a single zarr Group. To get the OME-zarr
metadata, use the `.attributes` property.
To modify the attributes, get a copy of them using the `.attributes`
property, modify them, and then set the attributes property with
the modified version.
"""

model_config = ConfigDict(arbitrary_types_allowed=True)
Expand All @@ -29,13 +25,18 @@ def attributes(self) -> ImageAttrs:
"""
return ImageAttrs(**self.group.attrs.asdict())

# TODO: before enabling this setter, check which fields of ImageAttrs
# we can change while still keeping a valid data structure
# (e.g., we can't just add extra channels without modifying the zarr data)
"""
@attributes.setter
def attributes(self, attrs: ImageAttrs) -> None:
if not isinstance(attrs, ImageAttrs):
raise ValueError(
f"attributes must by of type ImageAttrs (got type {type(attrs)})"
)
self.group.attrs.put(attrs.model_dump(exclude_none=True))
"""

@model_validator(mode="after")
def _check_multiscale_arrays(self) -> Self:
Expand Down

0 comments on commit a261d38

Please sign in to comment.