-
Notifications
You must be signed in to change notification settings - Fork 190
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 #1748
Merged
Merged
Migrate to Pydantic v2 #1748
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jesse-c
commented
May 8, 2024
jesse-c
commented
May 8, 2024
jesse-c
commented
May 8, 2024
Closed
> Pydantic V1 Pydantic V2 > .. > parse_obj() model_validate() [1] [1] https://docs.pydantic.dev/latest/migration/#changes-to-pydanticbasemodel
> underscore_attrs_are_private — the Pydantic V2 behavior is now the same as if this was always set to True in Pydantic V1. [1] [1] https://docs.pydantic.dev/latest/migration/#changes-to-config
> In Pydantic V2, the performance gap between BaseModel.__init__ and BaseModel.model_construct has been narrowed considerably. For simple models, calling BaseModel.__init__ may even be faster. If you are using model_construct() for performance reasons, you may want to profile your use case before assuming that model_construct() is faster. [1] [1] https://docs.pydantic.dev/latest/concepts/models/#creating-models-without-validation
It was previously a `MagicMock` for the model's `predict` function response. This ensures that there's a dummy value available.
This class only has these 2 fields [1]. The class it's coming from has different ones [2]. [1] https://github.com/jesse-c/MLServer/blob/c4e3719fab419480ec87d1482deccb1c93ba16a6/mlserver/types/dataplane.py#L64-L66 [2] https://github.com/jesse-c/MLServer/blob/c4e3719fab419480ec87d1482deccb1c93ba16a6/mlserver/types/dataplane.py#L109
I've changed tasks as well avoid a `can_generate` error on the default chosen model for the question-answering task. ``` E ValueError: Asked to export a gpt2 model for the task question-answering, but the Optimum ONNX exporter only supports the tasks feature-extraction, feature-extraction-with-past, text-generation, text-generation-with-past, text-classification, token-classification for gpt2. Please use a supported task. Please open an issue at https://github.com/huggingface/optimum/issues if you would like the task question-answering to be supported in the ONNX export for gpt2. ```
mauicv
approved these changes
May 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor questions but otherwise LGTM!
Ran some manual smoke tests with no issues. |
jesse-c
pushed a commit
that referenced
this pull request
May 13, 2024
) These were missed in #1748.
Closed
23 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're going for a wholesale update to Pydantic v2. Whilst I've tried to be as minimal as possible [1], I've fixed some things that were exposed during the migration [2]. Since we plan on this being a minor release, I've avoided any breaking changes in MLServer's interfaces.
It's a hefty PR. Each commit is an attempt at a self-contained part of the migration, and thus is best reviewed commit-by-commit. In saying that, it is of course a holistic change and a long line of dominoes.
For many of the commits, I've linked to the relevant part of the Pydantic v2 (migration) docs.
There will be manual integration testing as well.
[1] There's some deprecation warnings for v3 that I've looked past
[2] Example: Some incorrect tests
FIXES #1419