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

Pydantic v2 #67

Merged
merged 14 commits into from
Sep 19, 2023
Merged

Pydantic v2 #67

merged 14 commits into from
Sep 19, 2023

Conversation

astronautas
Copy link
Contributor

@astronautas astronautas commented Sep 13, 2023

As requested in the issue, PR migrates the codebase to PydanticV2. PydanticV2 introduces a plethora of performance optimisations (e.g. by being Rust-backed for validations), and some APIs (like root models can wrap Python types now) have been refined.

Changes:

  • Applied official migration tool.
  • RootModel either now wraps a Python data structure or user classes have to inherit from RootModel (applied this). __root__ field got changed to root.

TODO:

  • Cleanup 🧹

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #67 (7aa698b) into main (d6884d2) will decrease coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
- Coverage   95.42%   95.31%   -0.12%     
==========================================
  Files          28       28              
  Lines        1531     1537       +6     
==========================================
+ Hits         1461     1465       +4     
- Misses         70       72       +2     
Files Changed Coverage
tests/test_metadata.py ø
databooks/data_models/base.py 100.00%
databooks/data_models/cell.py 100.00%
databooks/data_models/notebook.py 100.00%
tests/test_cli.py 100.00%
tests/test_conflicts.py 100.00%
tests/test_data_models/test_notebook.py 100.00%
tests/test_git_utils.py 100.00%

Copy link
Member

@murilo-cunha murilo-cunha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!
It looks great! I also like the overall improvements!
Some small questions and comments here and there. I can also take this up later if you'd like

pyproject.toml Outdated Show resolved Hide resolved
databooks/data_models/cell.py Outdated Show resolved Hide resolved
tests/test_data_models/test_notebook.py Outdated Show resolved Hide resolved
tests/test_data_models/test_notebook.py Outdated Show resolved Hide resolved
tests/test_cli.py Outdated Show resolved Hide resolved
@astronautas
Copy link
Contributor Author

astronautas commented Sep 15, 2023

Thanks for the contribution! It looks great! I also like the overall improvements! Some small questions and comments here and there. I can also take this up later if you'd like

All good, very glad - I am not too busy nowadays either way still, and it's fun to contribute to actual OSS for the first time.

Copy link
Member

@murilo-cunha murilo-cunha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! Thanks again for your time and effort!

I'd just look into the __eq__ and aside from that I think we're good to go!

@astronautas
Copy link
Contributor Author

astronautas commented Sep 18, 2023

Changes look good! Thanks again for your time and effort!

I'd just look into the __eq__ and aside from that I think we're good to go!

Looked at it. Had to dig very deep, but in essence, bumped Pydantic even more, and there was no need to keep any custom __eq__ anymore, and continue relying on BaseModel.__eq__, the way it was and should be.

Ready for review again!

Copy link
Member

@murilo-cunha murilo-cunha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome! Just one very small change - pedantry really
I can also make these small changes - but it'll be a bit later

databooks/data_models/notebook.py Outdated Show resolved Hide resolved
@astronautas
Copy link
Contributor Author

Updated!

Copy link
Member

@murilo-cunha murilo-cunha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks a lot!
Big improvements!!

@murilo-cunha murilo-cunha merged commit 9d46c23 into datarootsio:main Sep 19, 2023
8 checks passed
@astronautas
Copy link
Contributor Author

🤝

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.

None yet

2 participants