Giskard-AI / giskard

🐒 Open-Source Evaluation & Testing for ML & LLM systems
https://docs.giskard.ai
Apache License 2.0
4.07k stars 267 forks source link

Limit numpy to less than 2 #1965

Closed Inokinoki closed 4 months ago

Inokinoki commented 4 months ago

Description

When install giskard and import, the release of numpy 2 will raise an error.

Related Issue

On Ubuntu 20.04, Python 3.9:

python --version
Python 3.9.5

Install through pip:

pip install giskard[llm]

During the installation:

  ERROR: Command errored out with exit status 1:
   command: /home/inoki/Builds/giskard-integrations/giskard-numpy2/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-es9acsrw/langdetect/setup.py'"'"'; __file__='"'"'/tmp/pip-install-es9acsrw/langdetect/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-1ify50c7
       cwd: /tmp/pip-install-es9acsrw/langdetect/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for langdetect
  Running setup.py clean for langdetect
  Building wheel for docopt (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/inoki/Builds/giskard-integrations/giskard-numpy2/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-es9acsrw/docopt/setup.py'"'"'; __file__='"'"'/tmp/pip-install-es9acsrw/docopt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7rlxcriz
       cwd: /tmp/pip-install-es9acsrw/docopt/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for docopt
  Running setup.py clean for docopt
Failed to build langdetect docopt
ERROR: scipy 1.11.4 has requirement numpy<1.28.0,>=1.21.6, but you'll have numpy 2.0.0 which is incompatible.
ERROR: opentelemetry-api 1.25.0 has requirement importlib-metadata<=7.1,>=6.0, but you'll have importlib-metadata 7.2.1 which is incompatible.
ERROR: datasets 2.20.0 has requirement fsspec[http]<=2024.5.0,>=2023.1.0, but you'll have fsspec 2024.6.0 which is incompatible.
ERROR: faiss-cpu 1.8.0.post1 has requirement numpy<2.0,>=1.0, but you'll have numpy 2.0.0 which is incompatible.
Installing collected packages: numpy, threadpoolctl, scipy, joblib, scikit-learn, certifi, urllib3, sentry-sdk, typing-extensions, annotated-types, pydantic-core, pydantic, charset-normalizer, idna, requests, six, mixpanel, xxhash, colorama, langdetect, cloudpickle, pyyaml, packaging, zipp, importlib-metadata, markdown, griffe, chardet, requests-toolbelt, zstandard, cachetools, entrypoints, pytz, smmap, gitdb, gitpython, click, wrapt, deprecated, opentelemetry-api, protobuf, opentelemetry-semantic-conventions, opentelemetry-sdk, sqlparse, mlflow-skinny, docopt, num2words, MarkupSafe, jinja2, tzdata, python-dateutil, pandas, sniffio, exceptiongroup, anyio, tqdm, h11, httpcore, httpx, distro, openai, multidict, attrs, frozenlist, aiosignal, async-timeout, yarl, aiohttp, fsspec, filelock, huggingface-hub, tokenizers, safetensors, regex, transformers, pyparsing, fonttools, cycler, importlib-resources, pillow, kiwisolver, contourpy, matplotlib, nvidia-nvjitlink-cu12, nvidia-cublas-cu12, nvidia-cusparse-cu12, nvidia-cusolver-cu12, nvidia-cuda-runtime-cu12, nvidia-cudnn-cu12, nvidia-nvtx-cu12, nvidia-cuda-nvrtc-cu12, networkx, nvidia-cuda-cupti-cu12, mpmath, sympy, triton, nvidia-curand-cu12, nvidia-nccl-cu12, nvidia-cufft-cu12, torch, bert-score, xyzservices, tornado, bokeh, dill, multiprocess, pyarrow-hotfix, pyarrow, datasets, evaluate, faiss-cpu, tenacity, llvmlite, numba, pynndescent, umap-learn, giskard

After installation:

>>> import giskard
/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/__init__.py:132: UserWarning: A NumPy version >=1.21.6 and <1.28.0 is required for this version of SciPy (detected version 2.0.0)
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/__init__.py", line 21, in <module>
    from .scanner import scan
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/__init__.py", line 9, in <module>
    from .scanner import Scanner
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/scanner.py", line 27, in <module>
    from .issues import DataLeakage, Issue, Stochasticity
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/issues.py", line 15, in <module>
    from ..slicing.text_slicer import MetadataSliceFunction
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/text_slicer.py", line 17, in <module>
    from .utils import get_slicer
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/utils.py", line 4, in <module>
    from .multiscale_slicer import MultiscaleSlicer
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/multiscale_slicer.py", line 3, in <module>
    from sklearn.tree import DecisionTreeRegressor
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/sklearn/__init__.py", line 82, in <module>
    import scipy.linalg  # noqa
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/__init__.py", line 206, in <module>
    from ._misc import *
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/_misc.py", line 3, in <module>
    from .blas import get_blas_funcs
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/blas.py", line 213, in <module>
    from scipy.linalg import _fblas
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/__init__.py", line 21, in <module>
    from .scanner import scan
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/__init__.py", line 9, in <module>
    from .scanner import Scanner
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/scanner.py", line 27, in <module>
    from .issues import DataLeakage, Issue, Stochasticity
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/issues.py", line 15, in <module>
    from ..slicing.text_slicer import MetadataSliceFunction
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/text_slicer.py", line 17, in <module>
    from .utils import get_slicer
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/utils.py", line 4, in <module>
    from .multiscale_slicer import MultiscaleSlicer
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/multiscale_slicer.py", line 3, in <module>
    from sklearn.tree import DecisionTreeRegressor
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/sklearn/__init__.py", line 82, in <module>
    import scipy.linalg  # noqa
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/__init__.py", line 206, in <module>
    from ._misc import *
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/_misc.py", line 3, in <module>
    from .blas import get_blas_funcs
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/blas.py", line 213, in <module>
    from scipy.linalg import _fblas
ImportError: numpy.core.multiarray failed to import
>>>
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/usr/lib/python3.9/threading.py", line 912, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/utils/analytics_collector.py", line 35, in inner_function
    return f(*args, **kwargs)
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/utils/analytics_collector.py", line 164, in _track
    self._lazy_init()
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/utils/analytics_collector.py", line 129, in _lazy_init
    self._initialize_giskard_version()
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/utils/analytics_collector.py", line 188, in _initialize_giskard_version
    import giskard
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/__init__.py", line 21, in <module>
    from .scanner import scan
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/__init__.py", line 9, in <module>
    from .scanner import Scanner
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/scanner.py", line 27, in <module>
    from .issues import DataLeakage, Issue, Stochasticity
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/scanner/issues.py", line 15, in <module>
    from ..slicing.text_slicer import MetadataSliceFunction
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/text_slicer.py", line 17, in <module>
    from .utils import get_slicer
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/utils.py", line 4, in <module>
    from .multiscale_slicer import MultiscaleSlicer
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/giskard/slicing/multiscale_slicer.py", line 3, in <module>
    from sklearn.tree import DecisionTreeRegressor
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/sklearn/__init__.py", line 82, in <module>
    import scipy.linalg  # noqa
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/__init__.py", line 206, in <module>
    from ._misc import *
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/_misc.py", line 3, in <module>
    from .blas import get_blas_funcs
  File "/home/inoki/Builds/giskard-integrations/giskard-numpy2/lib/python3.9/site-packages/scipy/linalg/blas.py", line 213, in <module>
    from scipy.linalg import _fblas
AttributeError: _ARRAY_API not found

Type of Change

Checklist

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud