Closed teddygroves closed 1 year ago
Seems reasonable to me. Feel free to send a PR with a newer requirement. That way we will see if the CI passes.
Maybe just >=1.6 would allow both users of <2 and >2 to happily use cobrapy.
The PR above just changes the ~
here to a >
as @Midnighter suggests.
I think the CI is just waiting for a maintainer to approve before it sets off.
Now fixed in 0.27.0.
Problem description
From a quick look I don't think cobrapy uses pydantic except for in this file, which I think is compatible with pydantic version 2 as is. It therefore doesn't seem like a very hard bug to fix: just remove the pin or change it to a version greater than 2.
@teddygroves or @cdiener, did you test whether the file referenced is compatible with pydantic v2? I ask because when setting up a new environment with conda, I get the following import error when importing cobra (cobra=0.29.0, pydantic=2.5.6):
Traceback (most recent call last): File "
", line 1, in File "/home/a/.conda/envs/cobra/lib/python3.12/site-packages/cobra/init.py", line 17, in from cobra import io File "/home/a/.conda/envs/cobra/lib/python3.12/site-packages/cobra/io/init.py", line 9, in from cobra.io.web import AbstractModelRepository, BiGGModels, BioModels, load_model File "/home/a/.conda/envs/cobra/lib/python3.12/site-packages/cobra/io/web/init.py", line 6, in from .biomodels_repository import BioModels File "/home/a/.conda/envs/cobra/lib/python3.12/site-packages/cobra/io/web/biomodels_repository.py", line 14, in class BioModelsFile(pydantic.BaseModel): ^^^^^^^^^^^^^^^^^^ File "/home/a/.conda/envs/cobra/lib/python3.12/site-packages/pydantic/init.py", line 372, in getattr module = import_module(module_name, package=package) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/a/.conda/envs/cobra/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/a/.conda/envs/cobra/lib/python3.12/site-packages/pydantic/main.py", line 13, in from pydantic_core import PydanticUndefined ImportError: cannot import name 'PydanticUndefined' from 'pydantic_core' (unknown location)
I forced conda to install pydantic-1.10.0 and import cobra
works fine. I do not have experience with pydantic, so I'm not clear if this is an issue with the requirements or not, but it appears that something does break when upgrading to pydantic v2.
Hi this error seems to be raised in pydantic itself and there seems to have been a bug in the conda package. Can you update your pedantic in the environment to a newer build and try again?
Problem description
I would like my project to have both the latest versions of cobrapy and pydantic as dependencies.
However this isn't currently possible as cobrapy pins pydantic version 1.6.
This is a problem because pydantic version 2 introduced some breaking changes, so would take a lot of work to make my project compatible with version 1.6.
Code Sample
Here is a minimal
pyproject.toml
that demonstrates the problemand here is the error message when I run
pip install -e .
in an empty folder containing thispyproject.toml
:From a quick look I don't think cobrapy uses pydantic except for in this file, which I think is compatible with pydantic version 2 as is. It therefore doesn't seem like a very hard bug to fix: just remove the pin or change it to a version greater than 2.
Context
Not relevant as the bug happens before cobra is installed