CQCL/qnexus

pydantic v2.10.0 incompatibility

Opened this issue · 2 comments

I installed qnexus on Linux today and received an error on import qnexus. Using an earlier version of pydantic solved the issue.

.pyenv/versions/3.12.7/envs/qnexus-env/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 515, in _unknown_type_schema
    raise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'pytket._tket.architecture.Architecture'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.10/u/schema-for-unknown-type
>>> import pydantic
>>> pydantic.__version__
'2.10.0'
>>> quit()
(3.12.7/envs/qnexus-env) ~/Dropbox/qnexus/Hsim_H1 > python3 -m pip install pydantic --version=2.4.2

Thanks for reporting the issue @atlytle. We have been trying to replicate but with no luck, could you please share your environment (e.g. the output of pip freeze along with maybe your operating system version) so we could try and replicate the issue?

The pydantic version has been updated since I reported the issue and a clean install of qnexus works fine now. I verified that python3 -m pip install pedantic=2.10.0 replicates the issue on my OS.

(qnexus_tmp) ~/envs > cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
(qnexus_tmp) ~/envs > uname -r
6.6.50-05090-g02ec56928355
(qnexus_tmp) ~/envs > pip freeze
annotated-types==0.7.0
anyio==4.6.2.post1
certifi==2024.8.30
click==8.1.7
colorama==0.4.6
graphviz==0.20.3
h11==0.14.0
httpcore==1.0.7
httpx==0.25.2
idna==3.10
Jinja2==3.1.4
lark==1.2.2
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
mpmath==1.3.0
nest-asyncio==1.6.0
networkx==3.4.2
numpy==2.1.3
pandas==2.2.3
pydantic==2.10.0
pydantic-settings==2.6.1
pydantic_core==2.27.0
Pygments==2.18.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytket==1.35.0
pytz==2024.2
qnexus==0.9.0
quantinuum-schemas==1.0.0
qwasm==1.0.1
rich==13.9.4
scipy==1.14.1
setuptools==75.6.0
six==1.16.0
sniffio==1.3.1
sympy==1.13.3
typing_extensions==4.12.2
tzdata==2024.2
websockets==13.1