Skip to content

Commit

Permalink
Update for zarr_checksum 0.2.12
Browse files Browse the repository at this point in the history
- 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.)
  • Loading branch information
jwodder committed Nov 27, 2023
1 parent 0f7ee2a commit c8dfd9e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
5 changes: 1 addition & 4 deletions dandi/files/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions dandi/support/digests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -216,10 +216,6 @@ ignore_missing_imports = True
# <https://github.com/zarr-developers/zarr-python/issues/1566>
ignore_missing_imports = True

[mypy-zarr_checksum.*]
# <https://github.com/dandi/zarr_checksum/issues/5>
ignore_missing_imports = True

[pydantic-mypy]
init_forbid_extra = True
warn_untypes_fields = True

0 comments on commit c8dfd9e

Please sign in to comment.