Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for pydantic 2 compatibility #189

Conversation

caufieldjh
Copy link
Member

@caufieldjh caufieldjh commented Aug 31, 2023

This updates the Makefile to ensure that linkml's gen-pydantic produces pydantic 2 classes.
Pydantic imports elsewhere in the project have been updated accordingly.

This also involves skipping export tests and removing full exports from make all, as templates prepared with a Pydantic version differing from that expected by linkml (which is not specifically pinned to pydantic 2) will cause errors when exporting to OWL, RDF, etc. This isn't essential to core functionality of OntoGPT, though it's otherwise useful, so it will soon return.

@caufieldjh
Copy link
Member Author

Unit tests are failing because they rely on pickled fixtures (ooh, that's a good tongue twister):

======================================================================
ERROR: test_export (tests.unit.test_exporters.test_html_exporter.TestExportHTML)
Test export.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/harry/ontogpt/tests/unit/test_exporters/test_html_exporter.py", line 17, in setUp
    self.extraction_result = pickle.load(f)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/pydantic/main.py", line 816, in __setstate__
    _object_setattr(self, '__pydantic_fields_set__', state['__pydantic_fields_set__'])
KeyError: '__pydantic_fields_set__'

======================================================================
ERROR: test_export (tests.unit.test_exporters.test_markdown_exporter.TestExport)
Test export.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/harry/ontogpt/tests/unit/test_exporters/test_markdown_exporter.py", line 17, in setUp
    self.extraction_result = pickle.load(f)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/pydantic/main.py", line 816, in __setstate__
    _object_setattr(self, '__pydantic_fields_set__', state['__pydantic_fields_set__'])
KeyError: '__pydantic_fields_set__'

======================================================================
ERROR: test_export (tests.unit.test_exporters.test_owl_exporter.TestExportOWL)
Test export.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/harry/ontogpt/tests/unit/test_exporters/test_owl_exporter.py", line 21, in setUp
    self.extraction_result = pickle.load(f)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/pydantic/main.py", line 816, in __setstate__
    _object_setattr(self, '__pydantic_fields_set__', state['__pydantic_fields_set__'])
KeyError: '__pydantic_fields_set__'

======================================================================
ERROR: test_export2 (tests.unit.test_exporters.test_owl_exporter.TestExportOWL)
Test export.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/harry/ontogpt/tests/unit/test_exporters/test_owl_exporter.py", line 21, in setUp
    self.extraction_result = pickle.load(f)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/pydantic/main.py", line 816, in __setstate__
    _object_setattr(self, '__pydantic_fields_set__', state['__pydantic_fields_set__'])
KeyError: '__pydantic_fields_set__'

======================================================================
ERROR: test_export (tests.unit.test_exporters.test_rdf_exporter.TestExportRDF)
Test export.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/harry/ontogpt/tests/unit/test_exporters/test_rdf_exporter.py", line 21, in setUp
    self.extraction_result = pickle.load(f)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/pydantic/main.py", line 816, in __setstate__
    _object_setattr(self, '__pydantic_fields_set__', state['__pydantic_fields_set__'])
KeyError: '__pydantic_fields_set__'

----------------------------------------------------------------------
Ran 19 tests in 23.257s

FAILED (errors=5, skipped=3)

@caufieldjh caufieldjh marked this pull request as ready for review August 31, 2023 16:03
@caufieldjh caufieldjh merged commit 901b661 into main Sep 1, 2023
2 checks passed
@caufieldjh caufieldjh deleted the 188-typeerror-configuredbasemodel__init_subclass__-takes-no-keyword-arguments branch September 1, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: ConfiguredBaseModel.__init_subclass__() takes no keyword arguments
2 participants