From 87928dc82526e03e41396d213933490e4b2d931f Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 2 Jan 2025 12:21:44 -0500 Subject: [PATCH] When reopening a zarr sink, validate it Also, write the metadata after fundamental changes so that anything that reopens the file after that point will see those changes. --- sources/zarr/large_image_source_zarr/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sources/zarr/large_image_source_zarr/__init__.py b/sources/zarr/large_image_source_zarr/__init__.py index 43925be65..be1d280b5 100644 --- a/sources/zarr/large_image_source_zarr/__init__.py +++ b/sources/zarr/large_image_source_zarr/__init__.py @@ -158,6 +158,11 @@ def _initNew(self, path, **kwargs): self._frameValues = None self._frameAxes = None self._frameUnits = None + if not self._created: + try: + self._validateZarr() + except Exception: + pass def __del__(self): if not hasattr(self, '_derivedSource'): @@ -809,6 +814,7 @@ def addTile(self, tile, x=0, y=0, mask=None, axes=None, **kwargs): self._levels = None self.levels = int(max(1, math.ceil(math.log(max( self.sizeX / self.tileWidth, self.sizeY / self.tileHeight)) / math.log(2)) + 1)) + updateMetadata = True if updateMetadata: self._writeInternalMetadata()