From c8dfd9e78a6d4f11524e1d11174a33e6e54c6eee Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Mon, 27 Nov 2023 08:12:13 -0500 Subject: [PATCH] Update for `zarr_checksum` 0.2.12 - We can't update to `zarr_checksum` 0.3.0 yet, as that requires Pydantic v2. - As `zarr_checksum` gained type annotations in dandi/zarr_checksum#21, we can remove its override from the mypy config. - Since dandi/zarr_checksum#17 was merged, it's now safe to import `zarr_checksum` at the top level of a module. - Fixed a typing error caused by importing `ZarrChecksumTree` from the top level of `zarr_checksum` despite it not being listed in `zarr_checksum.__all__`, which triggered a typing failure due to our mypy configuration containing `implicit_reexport = False`. (This error could only be detected after `zarr_checksum` started shipping a `py.typed` file.) --- dandi/files/zarr.py | 5 +---- dandi/support/digests.py | 5 +---- setup.cfg | 6 +----- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/dandi/files/zarr.py b/dandi/files/zarr.py index 48d8d3b97..8ea610df0 100644 --- a/dandi/files/zarr.py +++ b/dandi/files/zarr.py @@ -15,6 +15,7 @@ from dandischema.digests.zarr import get_checksum from dandischema.models import BareAsset, DigestType import requests +from zarr_checksum.tree import ZarrChecksumTree from dandi import get_logger from dandi.consts import ( @@ -287,10 +288,6 @@ def iter_upload( ``"done"`` and an ``"asset"`` key containing the resulting `RemoteAsset`. """ - # Importing zarr_checksum leads to importing numpy, which we want to - # avoid unless necessary - from zarr_checksum import ZarrChecksumTree - # So that older clients don't get away with doing the wrong thing once # Zarr upload to embargoed Dandisets is implemented in the API: if dandiset.embargo_status is EmbargoStatus.EMBARGOED: diff --git a/dandi/support/digests.py b/dandi/support/digests.py index 1748ad5cd..ad43c18be 100644 --- a/dandi/support/digests.py +++ b/dandi/support/digests.py @@ -24,6 +24,7 @@ from dandischema.digests.dandietag import DandiETag from fscacher import PersistentCache +from zarr_checksum.tree import ZarrChecksumTree from .threaded_walk import threaded_walk from ..utils import Hasher, exclude_from_zarr @@ -104,10 +105,6 @@ def get_zarr_checksum(path: Path, known: dict[str, str] | None = None) -> str: passed in the ``known`` argument, which must be a `dict` mapping slash-separated paths relative to the root of the Zarr to hex digests. """ - # Importing zarr_checksum leads to importing numpy, which we want to avoid - # unless necessary - from zarr_checksum import ZarrChecksumTree - if path.is_file(): s = get_digest(path, "md5") assert isinstance(s, str) diff --git a/setup.cfg b/setup.cfg index 8466de90e..6f806b9f0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,7 +56,7 @@ install_requires = semantic-version tenacity zarr ~= 2.10 - zarr_checksum + zarr_checksum ~= 0.2.12 zip_safe = False packages = find_namespace: include_package_data = True @@ -216,10 +216,6 @@ ignore_missing_imports = True # ignore_missing_imports = True -[mypy-zarr_checksum.*] -# -ignore_missing_imports = True - [pydantic-mypy] init_forbid_extra = True warn_untypes_fields = True