dandi / dandi-cli

DANDI command line client to facilitate common operations
https://dandi.readthedocs.io/
Apache License 2.0
22 stars 26 forks source link

no_heavy_import test fails on `=dandi-cli-0.59.0` due to numpy #1394

Closed TheChymera closed 1 month ago

TheChymera commented 9 months ago

Full build log → https://ppb.chymera.eu/6b5527.log

yarikoptic commented 9 months ago

since it doesn't fail for us here -- would be for you to figure out I am afraid. I usually do something like (didn't test -- just typing but you will get the idea)

mkdir evilmods
echo "raise ImportError('gotcha')" >| evilmods/numpy.py
PYTHONPATH=$PWD/evilmods:$PYTHONPATH python -c "import dandi.cli.command"

and look at traceback on what imports that numpy and how come... e.g. do you patch anything?

yarikoptic commented 9 months ago

@TheChymera ping on this so we know how to proceed on this one

TheChymera commented 9 months ago

@yarikoptic haven't figured out what's happening yet, don't close it.

TheChymera commented 9 months ago
[deco]~/src/dandi-cli ❱ mkdir evilmods
[deco]~/src/dandi-cli ❱ echo "raise ImportError('gotcha')" >| evilmods/numpy.py
[deco]~/src/dandi-cli ❱ PYTHONPATH=$PWD/evilmods:$PYTHONPATH python -c "import dandi.cli.command"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chymera/src/dandi-cli/dandi/cli/command.py", line 143, in <module>
    from .cmd_download import download  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chymera/src/dandi-cli/dandi/cli/cmd_download.py", line 10, in <module>
    from ..dandiset import Dandiset
  File "/home/chymera/src/dandi-cli/dandi/dandiset.py", line 14, in <module>
    from .files import DandisetMetadataFile, LocalAsset, dandi_file, find_dandi_files
  File "/home/chymera/src/dandi-cli/dandi/files/__init__.py", line 23, in <module>
    from ._private import BIDSFileFactory, DandiFileFactory
  File "/home/chymera/src/dandi-cli/dandi/files/_private.py", line 18, in <module>
    from .bids import (
  File "/home/chymera/src/dandi-cli/dandi/files/bids.py", line 14, in <module>
    from .zarr import ZarrAsset
  File "/home/chymera/src/dandi-cli/dandi/files/zarr.py", line 17, in <module>
    from zarr_checksum.tree import ZarrChecksumTree
  File "/usr/lib/python3.11/site-packages/zarr_checksum/__init__.py", line 4, in <module>
    from zarr_checksum.generators import FileGenerator
  File "/usr/lib/python3.11/site-packages/zarr_checksum/generators.py", line 12, in <module>
    from zarr.storage import NestedDirectoryStore
  File "/usr/lib/python3.11/site-packages/zarr/__init__.py", line 2, in <module>
    from zarr.codecs import *
  File "/usr/lib/python3.11/site-packages/zarr/codecs.py", line 2, in <module>
    from numcodecs import *
  File "/usr/lib/python3.11/site-packages/numcodecs/__init__.py", line 27, in <module>
    from numcodecs.zlib import Zlib
  File "/usr/lib/python3.11/site-packages/numcodecs/zlib.py", line 5, in <module>
    from .compat import ndarray_copy, ensure_contiguous_ndarray
  File "/usr/lib/python3.11/site-packages/numcodecs/compat.py", line 8, in <module>
    import numpy as np
  File "/home/chymera/src/dandi-cli/evilmods/numpy.py", line 1, in <module>
    raise ImportError('gotcha')
ImportError: gotcha

It seems to be numcodecs which ultimately triggers this.

The import is here → https://github.com/zarr-developers/numcodecs/blob/0878717a3613d91a453fe3d3716aa9c67c023a8b/numcodecs/compat.py#L8 and all the imports that lead to it are at the top of their respective modules, not under if statements. So now I'm wondering why this doesn't trigger for anybody else 🤔

yarikoptic commented 9 months ago

zarr_checksum is kinda the lead of the show here -- and I think whenever

gets released - might self-resolve. But I am surprised (although didn't look in detail) that testing here doesn't pick it up. I guess for now for your gentoo package you could just skip that test

TheChymera commented 9 months ago

@yarikoptic

I guess for now for your gentoo package you could just skip that test

Oh yes, I already did that after I filed and referenced the issue. Just wanted to fix this now that I stumbled on it, but I guess it can wait...

yarikoptic commented 3 months ago

I believe that PR mentioned above was released in 0.4.0

@TheChymera does issue still persist for you?

yarikoptic commented 1 month ago

haven't heard back, let's assume the answer is "no"