Repository: Project-MONAI/MONAI
File: monai/inferers/merger.py (Python)

Code before:
        self.store = store
        self.tmpdir: TemporaryDirectory | None
        if version_geq(get_package_version("zarr"), "3.0.0"):
            if value_store is None:
                self.tmpdir = TemporaryDirectory()
                self.value_store = zarr.storage.LocalStore(self.tmpdir.name)  # type: ignore
            else:
                self.value_store = value_store  # type: ignore
            if count_store is None:
                self.tmpdir = TemporaryDirectory()
                self.count_store = zarr.storage.LocalStore(self.tmpdir.name)  # type: ignore
            else:
                self.count_store = count_store  # type: ignore
        else:
            self.tmpdir = None
            self.value_store = zarr.storage.TempStore() if value_store is None else value_store  # type: ignore
            self.count_store = zarr.storage.TempStore() if count_store is None else count_store  # type: ignore
        self.chunks = chunks
        self.compressor = compressor
        self.value_compressor = value_compressor
        self.count_compressor = count_compressor
        self.output = zarr.empty(
            shape=self.merged_shape,
            chunks=self.chunks,
            dtype=self.output_dtype,
            compressor=None,
            store=self.store,
            overwrite=True,
        )
        self.values = zarr.zeros(
            shape=self.merged_shape,
            chunks=self.chunks,
            dtype=self.value_dtype,
            compressor=None,
            store=self.value_store,
            overwrite=True,
        )
        self.counts = zarr.zeros(
            shape=self.merged_shape,
            chunks=self.chunks,
            dtype=self.count_dtype,
            compressor=None,
            store=self.count_store,
            overwrite=True,
        )
        self.lock: threading.Lock | nullcontext
        if thread_locking:
            # use lock to protect the in-place addition during aggregation
            self.lock = threading.Lock()
        else:
            # use nullcontext to avoid the locking if not needed

Review comment (suggestion):
Hi @kolasaniv1996, thanks for the fix!
Could you please add a `deprecated_arg` on this `compressor`, since 1.5 and removed in 1.7?
Also could you please also add `codecs` which suggested from zarr format 3?
https://zarr.readthedocs.io/en/stable/api/zarr/api/asynchronous/index.html#zarr.api.asynchronous.create

Code after:
        removed="1.7.0",
        new_name="value_codecs",
        msg_suffix="Please use 'value_codecs' instead.",
    )
    @deprecated_arg(
        name="count_compressor",
        since="1.5.0",
        removed="1.7.0",
        new_name="count_codecs",
        msg_suffix="Please use 'count_codecs' instead.",
    )
    def __init__(
        self,
        merged_shape: Sequence[int],
        cropped_shape: Sequence[int] | None = None,
        dtype: np.dtype | str = "float32",
        value_dtype: np.dtype | str = "float32",
        count_dtype: np.dtype | str = "uint8",
        store: zarr.storage.Store | str = "merged.zarr",  # type: ignore
        value_store: zarr.storage.Store | str | None = None,  # type: ignore
        count_store: zarr.storage.Store | str | None = None,  # type: ignore
        compressor: str | None = None,
        value_compressor: str | None = None,
        count_compressor: str | None = None,
        codecs: list | None = None,
        value_codecs: list | None = None,
        count_codecs: list | None = None,
        chunks: Sequence[int] | bool = True,
        thread_locking: bool = True,
    ) -> None:
        super().__init__(merged_shape=merged_shape, cropped_shape=cropped_shape)
        if not self.merged_shape:
            raise ValueError(f"`merged_shape` must be provided for `ZarrAvgMerger`. {self.merged_shape} is give.")
        self.output_dtype = dtype
        self.value_dtype = value_dtype
        self.count_dtype = count_dtype
        self.store = store
        self.tmpdir: TemporaryDirectory | None

        # Handle zarr v3 vs older versions
        is_zarr_v3 = version_geq(get_package_version("zarr"), "3.0.0")

        if is_zarr_v3:
            if value_store is None:
                self.tmpdir = TemporaryDirectory()
                self.value_store = zarr.storage.LocalStore(self.tmpdir.name)  # type: ignore
            else:
                self.value_store = value_store  # type: ignore
            if count_store is None:
                self.tmpdir = TemporaryDirectory()
                self.count_store = zarr.storage.LocalStore(self.tmpdir.name)  # type: ignore