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

Migrate to pydantic v2 #195

Closed
tstorek opened this issue Jul 3, 2023 · 8 comments
Closed

Migrate to pydantic v2 #195

tstorek opened this issue Jul 3, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request feature request Request a potential feature

Comments

@tstorek
Copy link
Collaborator

tstorek commented Jul 3, 2023

Is your feature request related to a problem? Please describe.
Pydantic V2 is out!
https://pypi.org/project/pydantic/
https://docs.pydantic.dev/latest/

It has a fresh core and promises to be multiple times faster! Hence, it would be great to migrate step by step.

Describe the solution you'd like
Migrate step by step and substitute the deprecated functions by the new once.
Pydantic provides a migration guide for this. https://docs.pydantic.dev/latest/migration/

The effort may be relatively small, but definitely worth it.
Otherwise, the library may be stuck in the past.

@djs0109 What do you think? It would definetly mean a major release to the whole library due to breaking changes.

@tstorek tstorek added feature request Request a potential feature enhancement New feature or request labels Jul 3, 2023
@djs0109
Copy link
Contributor

djs0109 commented Jul 3, 2023

Nice! I think we should definitely move forward. @tstorek Do you think it is worth waiting for the migration tool?

@tstorek
Copy link
Collaborator Author

tstorek commented Jul 8, 2023

This is connected to #197 as pydantic-settings is now a separated package. Hence, #197 will fix the symptoms but not the general problem. I suggest to do the migration relatively quickly. By setting up a project for this. @djs0109, if you require support, let me know. I can help out with answering questions on the original architecture and smaller issues, but cannot take the lead here.

Apparently they provide a migration-tool now https://github.com/pydantic/bump-pydantic

@tstorek
Copy link
Collaborator Author

tstorek commented Jul 8, 2023

@djs0109 I looked into a bit here is the strategy I suggest:

  1. Run bump_pydantic tool on the library
  2. Add `pydantic-settings to setup.py and requirements.txt
  3. Correct all imports for pydantic settings
  4. Run tests and fix deprecation all DeprecationWarnings
  5. Deploy something like black for code-formating. Maybe PyCharm will already help you here.
  6. Do a release and mark the merge as potentially BREAKING CHANGE (as we are not on v1, we can introduce this change as v0.3.0)

The pydantic developers did a very good job here. Hence, migration should not take longer than an hour or so. The good thing is that there a very few breaking changes that will affect further developments. They will see the DeprecationWarnings and need to apply the same strategy. I'd appreciate it if you could do it now than wait!

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Branch 195-Migrate-to-pydantic-v2 created!

@djs0109
Copy link
Contributor

djs0109 commented Jul 11, 2023

Cool! I will try this migration tool as soon as possible. Thanks again for providing the strategy!

@djs0109
Copy link
Contributor

djs0109 commented Jul 14, 2023

@tstorek do you know where the regex here comes from? Because Pydantic now also has some problems with it.

@tstorek
Copy link
Collaborator Author

tstorek commented Jul 14, 2023

@djs0109 that's exactly where I struggle right now see #199. They origin from making the headers fiware_safe. Apparently, they will require a little refactoring :/ That's gonna be a little hazzle.

@djs0109
Copy link
Contributor

djs0109 commented Jul 14, 2023

@tstorek Indeed, there are more works than we might think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request Request a potential feature
Projects
None yet
Development

No branches or pull requests

2 participants