-
Notifications
You must be signed in to change notification settings - Fork 234
feat: hybrid pydantic support for both v1 and v2 #1652
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
e26c6c5
feat: init commit on adding v2 support
samsja 30a8c17
feat: make some progress
samsja ee347b0
fix: fix test update
samsja 64216c7
fix: fix refactoring validation
samsja 8989d82
fix: fix ndarray and doclist
samsja e2082d9
fix: move to var
samsja c20f49b
fix: fix some stuff
samsja b55005f
fix: fix some stuff on v1
samsja 1d7097c
feat: pass half of the test
samsja addf361
fix: add schema to doc vec
samsja 168163b
feat: fix anyurl
samsja a7d30ed
fix: remove useles try catch
samsja 979edc7
refactor: use _docarray_fields everywhere
samsja 0d1e194
fix: fix is required
samsja f370888
fix: fix validation of any url
samsja dd0f96a
fix: make dict and json pydantic v1 only for now
samsja aaf47d0
fix: use string as id in tests
samsja 46d15d2
fix: doc view
samsja a06b778
fix: test traverse test
samsja 9f5098d
fix: fix any url
samsja 6f69a64
fix: type_
samsja 7856e11
fix: outer type pb
samsja 140158c
fix: .type_
samsja 2d3bdb9
fix: add pydantic extra to from view
samsja 6059add
fix: fix smth
samsja 7bf8874
refactor: rename get fild type
samsja 083415e
refactor: fix field type
samsja 3de330d
chore: bump fastapi
samsja fb91500
chore: fix test audio tensor
samsja ae2855c
chore: fix field set warning
samsja afb15b5
chore: fix shallow copy
samsja 8f4814f
fix: fix smth
samsja aaaf17e
fix: fix smth
samsja e6f0748
fix: fix recursion schem display
samsja 9a4a5b1
fix: fix rsmth
samsja 98a4507
fix: fix id
samsja 2212b48
fix: fix json
samsja 2cc068a
fix: fix tests
samsja 3909184
fix: fix msht
samsja 0e23c67
fix: fix dump
samsja e46764d
feat: add tests
samsja 71978a4
fix: fix tests
samsja ef4f916
fix: fix tests
samsja 8acda4e
fix: fix proto
samsja c75f02d
fix: fix proto
samsja 41be289
fix: fix dict any doc
samsja 97ba6a2
fix: fix smth
samsja 0bddc8b
fix: fix some other tests
samsja 3d96901
fix: skip failing v2 tests for later
samsja 4b4031c
fix: pass video tensor
samsja 0267c43
feat: wip add json support for tensor
samsja 076f4eb
feat: add orjsons support for tensor
samsja eac18fa
fix: merege in progress
samsja efb2109
fix: image url proto
samsja 72eae9f
fix: fix some tests
samsja e1b5868
fix: fix some tests
samsja 88be3be
fix: fix some tests
samsja efcc877
fix: fix some tests regarding anyurl
samsja 94f7e13
fix: fix any url problem
samsja 448fa32
fix: add missing method
samsja 47b86a5
fix: fix json
samsja 193ec11
fix: fix some tests
samsja d952729
fix: fix some tests
samsja 8dba04e
fix: fix some tests
samsja 6e1241c
fix: fix some tests
samsja db0768d
fix: fix some tests
samsja d32b3ed
fix: fix tests
samsja bc24031
chore: update ci#
samsja c57067b
chore: add gitnignore
samsja 386b25f
fix: fix code to be compatible with python 3.8
samsja 4e01dc0
chore: install v2 in c
samsja 71f5645
Merge branch 'main' into feat-full-pydantic-v2-support
samsja 8db8da3
chore: install v2 in c
samsja c639703
fix: fix some tests
samsja f25ff1a
chore: fix pydantic v2 install
samsja 57097fe
fix: fix some integration tests
samsja 568e7d3
fix: fix mesh 3d val
samsja 99f675a
fix: fix spcript
samsja d1142e3
chore: fix smth
samsja 6bcf372
chore: fix smth
samsja ed231a0
fix: fix import
samsja e7364a8
fix: fix audio test v2
samsja 62f48b6
fix: fix some tests integrations
samsja 5042293
fix: fix some integrations tests
samsja 3d0dbfe
fix: fix some mesh tests
samsja 24c4bb1
fix: fix point cloud
samsja e105146
fix: fix some tests
samsja d86d196
chore: add marker
samsja de03e81
fix: fix some tests
samsja 3383a52
fix: pass tests for now
samsja 9ecf204
fix: issue with id json schema
samsja 9054727
chore: do pydantic v2 test everywhere
samsja c910887
fix: fix poetry lock
samsja 6a3dd8a
fix: update qdrant
samsja 580832e
fix: wip fix pydantic v2 index tests
samsja ad46ab7
fix: fix pydantic v2 index test
samsja 4ff7eae
fix: fix redis tests
samsja 38a6982
fix: fix el v7 tests
samsja cd56d8c
fix: fix el v8 tests
samsja 610a3aa
Merge branch 'main' into feat-full-pydantic-v2-support
samsja 9aa12e1
fix: last tests
samsja 8f2ee87
fix: tensorflow pydantic v2 tests
samsja cf5654b
fix: fix jax with pydantic v
samsja 4613e20
fix: silence on last test
samsja 4134da5
fix: silence on last test
samsja c259b09
fix: docstring validate
samsja 02b2b61
fix: docstring validate
samsja cbf7a87
fix: put back cast
samsja 5e2378e
feat: apply johannes suggestion
samsja 19e444b
feat: add comment
samsja a16018a
feat: add comment
samsja 863e0b8
fix: skip docstrng tet for pydantic v2 for now
samsja d7a7a49
fix: skip docstrng tet for pydantic v2 for now
samsja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: fix some stuff
Signed-off-by: samsja <[email protected]>
- Loading branch information
commit c20f49baf01ef5649471145a8841a1e1307a6b07
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| from abc import abstractmethod | ||
| from typing import TYPE_CHECKING, Any, Type, TypeVar | ||
|
|
||
| from pydantic import parse_obj_as | ||
|
|
||
| from docarray.typing.abstract_type import AbstractType | ||
| from docarray.utils._internal.pydantic import bytes_validator, is_pydantic_v2 | ||
|
|
||
| if is_pydantic_v2: | ||
| from pydantic_core import core_schema | ||
|
|
||
| if TYPE_CHECKING: | ||
| from docarray.proto import NodeProto | ||
|
|
||
| if is_pydantic_v2: | ||
| from pydantic import GetCoreSchemaHandler | ||
|
|
||
| T = TypeVar('T', bound='BaseBytes') | ||
|
|
||
|
|
||
| class BaseBytes(bytes, AbstractType): | ||
| """ | ||
| Bytes type for docarray | ||
| """ | ||
|
|
||
| @classmethod | ||
| def _docarray_validate( | ||
| cls: Type[T], | ||
| value: Any, | ||
| ) -> T: | ||
| value = bytes_validator(value) | ||
| return cls(value) | ||
|
|
||
| @classmethod | ||
| def from_protobuf(cls: Type[T], pb_msg: T) -> T: | ||
| return parse_obj_as(cls, pb_msg) | ||
|
|
||
| def _to_node_protobuf(self: T) -> 'NodeProto': | ||
| from docarray.proto import NodeProto | ||
|
|
||
| return NodeProto(blob=self, type=self._proto_type_name) | ||
|
|
||
| if is_pydantic_v2: | ||
|
|
||
| @classmethod | ||
| @abstractmethod | ||
| def __get_pydantic_core_schema__( | ||
| cls, _source_type: Any, _handler: 'GetCoreSchemaHandler' | ||
| ) -> 'core_schema.CoreSchema': | ||
| return core_schema.general_after_validator_function( | ||
| cls.validate, | ||
| core_schema.bytes_schema(), | ||
| ) |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
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.
Am I understanding correctly that we are falling back to the bytes validator of v1 even if pydantic v2 is used? What is the reason behind this?
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.
?