-
Notifications
You must be signed in to change notification settings - Fork 15
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 #504
Closed
Leobouloc
wants to merge
65
commits into
feature/enforce-scopes
from
structure/migrate-to-pydantic-v2
Closed
Migrate to pydantic v2 #504
Leobouloc
wants to merge
65
commits into
feature/enforce-scopes
from
structure/migrate-to-pydantic-v2
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
Some tests in edx to xapi converters were named without a pattern. The path pattern used in other tests is applied for these tests.
`school`, `course` and `module` context extensions used in base edx-to-xapi converter can no longer be used. The tracking of the course information depends on the target statements templates used in xAPI profiles.
| datasource | package | from | to | | ---------- | --------------- | ------ | ------ | | pypi | hypothesis | 6.87.1 | 6.87.3 | | pypi | mkdocs-material | 9.4.2 | 9.4.4 | | pypi | pylint | 2.17.7 | 3.0.1 |
We intend to unify the storage and database backend interfaces into a single data backend interface. We also want to separate LRS-specific methods into a dedicated lrs backend interface that extends the data interface.
We add the FileSystem data backend implementation that is mostly taken from the existing FSStorage backend.
Updating List type to use List of Pydantic and handle Python3.8
Add Mongo backend under the new common 'data' interface. With Mongo under the new data interface, tests are updated as well. Storage and Database backends had similar interfaces and usage, so a new Data Backend interface has been created.
We add the OpenStack Swift data backend implementation. With the `data` parameter changed to an Iterable, we cannot use high level SwiftService API to upload files anymore (it needs a file object source, not an iterable). Changing to Connection lower-level API, which is more flexible.
We add the LDP data backend implementation that is mostly taken from the existing LDPStorage backend.
Add S3 backend under the new common `data` interface
Add ClickHouse backend under the new common 'data' interface. With ClickHouse under the new data interface, tests are updated as well. Storage and Database backends had similar interfaces and usage, so a new Data Backend interface has been created.
We want to simplify our tests that are mocking the request package. Therefore we choose to use the `request_mock` library.
We add the ES data backend implementation that is mostly taken from the existing ESDatabase backend.
We want to provide an LRS backend that could be added to Ralph's LRS without any additional dependencies.
Methods `read_raw` and `parse_bytes_to_dict` are generic and used by multiple backends. Moving them to file `utils.py`.
Add asynchronous base interface for async backends such as async_es or async_mongo
We add the Async elasticsearch data backend mostly taken from the sync backend using the async elasticsearch methods.
We want to improve the current mongo data backend implementation to align it more with other unified data backends.
We want to provide an async version of our MongoDatabase backend.
- `get_query` method for Elasticsearch would be better namespaced under the ESLRSBackend. Changing it to a static method instead of a global function. - At initialization, data backends can either take settings or None. Setting `settings_class` to Optional to anticipate mypy warning when mypy will be added. - Piping x|None is preferred since Python 3.10, changing from Optional to Union[x|None] for backends as it would be easier to switch to pipes. - Changes to backend methods docstrings - Rename variable `new_documents` to be more explicit
Synchronous backends such as Elasticsearch or Mongo need their connection to be closed when finished. This commits adds an abstract method close to the BaseDataBackend interface, and implements it for backends that need it.
The update to a recent version of `motor` highlighted a bug on our side when listing collections. Now asynchronously iterate over collections list.
With the new data backend interface, settings are now close to each backend and not under general conf.py. Unifying stream backend WS to have the same architecture as data backends.
With the new data backend interface, settings are now close to each backend and not under general conf.py. Unifying HTTP backends to have the same architecture as data backends.
After unifying database and storage backends under a common interface, backends settings are now handled directly alongside the backends classes. Modifying the CLI to support new settings and new backends interfaces.
With the addition of new asynchronous backends, it could be useful to be able to use them in the CLI.
Adding a default value for ClickHouse client option `allow_experimental_object_type` highlights a pydantic validation error with type `Literal[0,1]`. Switching to `coint`.
With addition of unified backends and changes to the conf files, API router needs some changes to be able to get the backends instance.
With addition of unified backends, API router needs some changes to be able to use asynchronous backends.
Tests using filesystem failed with pyfakefs in the CI as pyfakefs does not succeed on creating requesting files in the default directory path. The latter is then defined specifically for these tests and forced to be used in the ralph command.
| datasource | package | from | to | | ---------- | ---------------- | -------- | --------- | | pypi | black | 23.10.0 | 23.10.1 | | pypi | cachetools | 5.3.1 | 5.3.2 | | pypi | cryptography | 41.0.4 | 41.0.5 | | pypi | mkdocs-material | 9.4.6 | 9.4.7 | | pypi | moto | 4.2.6 | 4.2.7 | | pypi | mypy | 1.2.0 | 1.6.1 | | pypi | pytest | 7.4.2 | 7.4.3 | | pypi | types-cachetools | 5.3.0.6 | 5.3.0.7 | | pypi | types-requests | 2.31.0.6 | 2.31.0.10 |
Changed: - Upgrade `cachetools` to `5.3.2`
Leobouloc
commented
Nov 10, 2023
@@ -41,13 +42,13 @@ class CorrectMap(BaseModelWithConfig): | |||
queuestate (json): see QueueStateField. | |||
""" | |||
|
|||
answervariable: Union[Literal[None], None, str] | |||
answervariable: Union[Literal[None], None, str] = None |
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.
"I wonder if setting a default value for this field makes it not required" Originally commented by @quitterie-lcs
Leobouloc
changed the base branch from
master
to
feature/api/allow-multiple-auth-after-unification
November 10, 2023 09:29
Leobouloc
force-pushed
the
feature/api/allow-multiple-auth-after-unification
branch
from
November 10, 2023 10:05
02ab20a
to
d62f720
Compare
Leobouloc
force-pushed
the
feature/api/allow-multiple-auth-after-unification
branch
7 times, most recently
from
November 15, 2023 15:49
1fe8b22
to
e1889d2
Compare
Base automatically changed from
feature/api/allow-multiple-auth-after-unification
to
master
November 15, 2023 15:57
Closing as it is done in #550 |
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.
Purpose
As mentionned in #401 , upgrading to pydantic 2 should greatly improve performances. Also it would allow projects depending on
ralph
(such aswarren
) to upgrade more easily.Dealing with common errors when migrating
ERROR: Extra not permitted
In
conf.py
, errors such as:may be due to a change in default behavior in models
extra=ignore
toextra=failure
. We may set this parameter manually to fix this issue.ERROR: Unable to generate pydantic-core schema
To fix this we change the way we define classes.
Previously in Ralph
New in Ralph
ERROR: Missing values
A recurrent error is the one below, which should be linked to the change of behavior when using
Optional[...]
in Pydantic V2. Previously, it would assign a default value ofNone
, which is no longer the case. This should have been dealt with bybump-pydantic
but was not always the case. It would be nice to know why before confirming this solution.Previously in Ralph
New in Ralph