linkml / schema-automator

Automated assistance for the schema development lifecycle
https://linkml.io/schema-automator/
BSD 3-Clause "New" or "Revised" License
33 stars 12 forks source link

problem caused by bioregistry pydantic usage #120

Closed manulera closed 5 months ago

manulera commented 8 months ago

Describe the bug When installing the package and using schemauto import-json-schema, you get

File "....convert_json_schema/.venv/lib/python3.11/site-packages/bioregistry/utils.py", line 25, in <module>
    from pydantic.json import ENCODERS_BY_TYPE
ImportError: cannot import name 'ENCODERS_BY_TYPE' from 'pydantic.json' (....convert_json_schema/.venv/lib/python3.11/site-packages/pydantic/json.py)

Probably related to https://github.com/biopragmatics/bioregistry/issues/899

To Reproduce

python -m venv .venv
source .venv/bin/activate
pip install schema-automator
schemauto import-json-schema original_json_schema.json
manulera commented 8 months ago

The error goes away when downgrading to pydantic 1.10

cthoyt commented 8 months ago

@manulera are you using a recent version of the Bioregistry?

manulera commented 8 months ago

You can't use the latest release because of schema-automator restrictions:

$ poetry add bioregistry@0.10.65

Updating dependencies
Resolving dependencies... (0.2s)

Because schema-automator (0.3.0) depends on bioregistry (>=0.5.87,<0.6.0)
 and no versions of schema-automator match >0.3.0,<0.4.0, schema-automator (>=0.3.0,<0.4.0) requires bioregistry (>=0.5.87,<0.6.0).
So, because convert-json-schema depends on both schema-automator (^0.3.0) and bioregistry (0.10.65), version solving failed.
cthoyt commented 8 months ago

@manulera the issue here is that the Bioregistry version number is way overspecified in schema-automator, just unpin it

manulera commented 8 months ago

Hi @cthoyt I got it to work using pydantic 1, so that's solved for me, but shouldn't something be done at the package so that the "to reproduce" above works?

cthoyt commented 8 months ago

If you want to capture exactly the environment that made this work using code that's over a year old before a massive refactoring to make pydantic 1/2 work, I think this is the responsibility of the requirements file in schema-automator

cthoyt commented 8 months ago

The funny thing is that this repo doesn't even use the Bioregistry. In #121, I simply removed that requirement. Should solve your issue.