From e3afa41429f45c55e5110b65603e5e19b0974b53 Mon Sep 17 00:00:00 2001 From: Marwan Zouinkhi Date: Tue, 16 Apr 2024 10:03:33 -0400 Subject: [PATCH] mode property --- .../datasplits/datasets/arrays/zarr_array.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dacapo/experiments/datasplits/datasets/arrays/zarr_array.py b/dacapo/experiments/datasplits/datasets/arrays/zarr_array.py index 4812911c7..c976f7d96 100644 --- a/dacapo/experiments/datasplits/datasets/arrays/zarr_array.py +++ b/dacapo/experiments/datasplits/datasets/arrays/zarr_array.py @@ -104,7 +104,7 @@ def __init__(self, array_config): self.name = array_config.name self.file_name = array_config.file_name self.dataset = array_config.dataset - self.mode = array_config.mode + self._mode = array_config.mode self._attributes = self.data.attrs self._axes = array_config._axes self.snap_to_grid = array_config.snap_to_grid @@ -144,6 +144,14 @@ def __repr__(self): """ return f"ZarrArray({self.file_name}, {self.dataset})" + + @property + def mode(self): + if not hasattr(self, "_mode"): + self._mode = "a" + if self._mode not in ["r", "w", "a"]: + raise ValueError(f"Mode {self._mode} not in ['r', 'w', 'a']") + return self._mode @property def attrs(self): @@ -413,6 +421,7 @@ def create_from_array_identifier( num_channels, voxel_size, dtype, + mode = "a", write_size=None, name=None, overwrite=False,