opencobra / memote

memote – the genome-scale metabolic model test suite
https://memote.readthedocs.io/
Apache License 2.0
128 stars 28 forks source link

Getting error with Numpy #765

Open carolinasisco opened 5 months ago

carolinasisco commented 5 months ago

hello,

Code used: memote report snapshot --filename "report_model.html" ~/Desktop//model.xml Error: Traceback (most recent call last): File "/home/carol/miniconda3/envs/metabolic_model_env/bin/memote", line 5, in from memote.suite.cli.runner import cli File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/memote/suite/cli/runner.py", line 42, in import memote.suite.cli.callbacks as callbacks File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/memote/suite/cli/callbacks.py", line 30, in from memote.experimental import ExperimentConfiguration File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/memote/experimental/init.py", line 22, in from memote.experimental.config import File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/memote/experimental/config.py", line 39, in from memote.experimental.essentiality import EssentialityExperiment File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/memote/experimental/essentiality.py", line 25, in import pandera as pa File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/init.py", line 5, in import pandera.backends File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/backends/init.py", line 4, in import pandera.backends.base.builtin_checks File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/backends/base/builtin_checks.py", line 14, in from pandera.api.checks import Check File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/api/checks.py", line 17, in from pandera.strategies.base_strategies import SearchStrategy File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/strategies/init.py", line 3, in from pandera.strategies.pandas_strategies import File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/strategies/pandas_strategies.py", line 42, in from pandera.engines import numpy_engine, pandas_engine File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/pandera/engines/pandasengine.py", line 757, in np.string, ^^^^^^^^^^ File "/home/carol/miniconda3/envs/metabolic_model_env/lib/python3.11/site-packages/numpy/init.py", line 397, in getattr raise AttributeError(

Any suggestions?

Thanks!

Midnighter commented 5 months ago

Hi,

Thanks for the report. You have cut off the most important part of the error message, i.e., what comes after AttributeError. Also, please provide version information like we ask for in the bug report template.

jjkoehorst commented 5 months ago

I might have the same issue after a pip install in a clean venv

memote report snapshot --filename "test_report.html" ~/Documents/protein_model_carve 
Traceback (most recent call last):
  File "/home/peiyi/venv_memote/bin/memote", line 5, in <module>
    from memote.suite.cli.runner import cli
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/memote/suite/cli/runner.py", line 42, in <module>
    import memote.suite.cli.callbacks as callbacks
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/memote/suite/cli/callbacks.py", line 30, in <module>
    from memote.experimental import ExperimentConfiguration
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/memote/experimental/__init__.py", line 22, in <module>
    from memote.experimental.config import *
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/memote/experimental/config.py", line 39, in <module>
    from memote.experimental.essentiality import EssentialityExperiment
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/memote/experimental/essentiality.py", line 25, in <module>
    import pandera as pa
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/__init__.py", line 5, in <module>
    import pandera.backends
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/backends/__init__.py", line 4, in <module>
    import pandera.backends.base.builtin_checks
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/backends/base/builtin_checks.py", line 14, in <module>
    from pandera.api.checks import Check
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/api/checks.py", line 17, in <module>
    from pandera.strategies.base_strategies import SearchStrategy
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/strategies/__init__.py", line 3, in <module>
    from pandera.strategies.pandas_strategies import *
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/strategies/pandas_strategies.py", line 42, in <module>
    from pandera.engines import numpy_engine, pandas_engine
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/pandera/engines/pandas_engine.py", line 757, in <module>
    np.string_,
    ^^^^^^^^^^
  File "/home/peiyi/venv_memote/lib/python3.12/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?
jjkoehorst commented 5 months ago

pip install 'numpy<2.0.0' did the trick as this major release made some breaking changes (probably why its a major release).

Midnighter commented 5 months ago

This is coming from the pandera dependency and has already been addressed there. Hopefully, they will release the fix soon.

https://github.com/unionai-oss/pandera/issues/1656

HossFir commented 4 months ago

I encountered the same issue with NumPy regarding the deprecation and removal of the np.float alias in recent versions. Here's how I fixed it in the cobra library:

In the repository, locate the file cobra/io/dict.py.

Change this line:

value: Union[str, np.float, np.bool, Set, Dict]

to:

value: Union[str, float, bool, Set, Dict]

After making this change, Memote ran successfully. However, to ensure that CobraPy continues to work correctly, you need to revert this line back to its original state after running Memote.

Midnighter commented 4 months ago

Did anyone of you try this again with the recent pandera release 0.20.x? That should fix it on their end. Maybe there are further issues in cobrapy or optlang to consider.

HossFir commented 4 months ago

I have been using pandera 0.20.1 I got this with numpy: 0.2 when I used memote: The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Fixing that line in cobrapy will set the issue for now!