Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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 Jun 15, 2023
30a8c17
feat: make some progress
samsja Jun 15, 2023
ee347b0
fix: fix test update
samsja Jun 15, 2023
64216c7
fix: fix refactoring validation
samsja Jun 15, 2023
8989d82
fix: fix ndarray and doclist
samsja Jun 15, 2023
e2082d9
fix: move to var
samsja Jun 15, 2023
c20f49b
fix: fix some stuff
samsja Jun 16, 2023
b55005f
fix: fix some stuff on v1
samsja Jun 16, 2023
1d7097c
feat: pass half of the test
samsja Jun 16, 2023
addf361
fix: add schema to doc vec
samsja Jun 16, 2023
168163b
feat: fix anyurl
samsja Jun 16, 2023
a7d30ed
fix: remove useles try catch
samsja Jun 19, 2023
979edc7
refactor: use _docarray_fields everywhere
samsja Jun 19, 2023
0d1e194
fix: fix is required
samsja Jun 19, 2023
f370888
fix: fix validation of any url
samsja Jun 19, 2023
dd0f96a
fix: make dict and json pydantic v1 only for now
samsja Jun 22, 2023
aaf47d0
fix: use string as id in tests
samsja Jun 22, 2023
46d15d2
fix: doc view
samsja Jun 22, 2023
a06b778
fix: test traverse test
samsja Jun 22, 2023
9f5098d
fix: fix any url
samsja Jun 22, 2023
6f69a64
fix: type_
samsja Jun 22, 2023
7856e11
fix: outer type pb
samsja Jun 22, 2023
140158c
fix: .type_
samsja Jun 22, 2023
2d3bdb9
fix: add pydantic extra to from view
samsja Jun 22, 2023
6059add
fix: fix smth
samsja Jun 22, 2023
7bf8874
refactor: rename get fild type
samsja Jun 22, 2023
083415e
refactor: fix field type
samsja Jun 22, 2023
3de330d
chore: bump fastapi
samsja Jul 20, 2023
fb91500
chore: fix test audio tensor
samsja Jul 20, 2023
ae2855c
chore: fix field set warning
samsja Jul 20, 2023
afb15b5
chore: fix shallow copy
samsja Jul 20, 2023
8f4814f
fix: fix smth
samsja Jul 20, 2023
aaaf17e
fix: fix smth
samsja Jul 20, 2023
e6f0748
fix: fix recursion schem display
samsja Jul 20, 2023
9a4a5b1
fix: fix rsmth
samsja Jul 20, 2023
98a4507
fix: fix id
samsja Jul 20, 2023
2212b48
fix: fix json
samsja Jul 20, 2023
2cc068a
fix: fix tests
samsja Jul 20, 2023
3909184
fix: fix msht
samsja Jul 21, 2023
0e23c67
fix: fix dump
samsja Aug 3, 2023
e46764d
feat: add tests
samsja Aug 3, 2023
71978a4
fix: fix tests
samsja Aug 3, 2023
ef4f916
fix: fix tests
samsja Aug 3, 2023
8acda4e
fix: fix proto
samsja Aug 3, 2023
c75f02d
fix: fix proto
samsja Aug 3, 2023
41be289
fix: fix dict any doc
samsja Aug 3, 2023
97ba6a2
fix: fix smth
samsja Aug 4, 2023
0bddc8b
fix: fix some other tests
samsja Aug 7, 2023
3d96901
fix: skip failing v2 tests for later
samsja Aug 7, 2023
4b4031c
fix: pass video tensor
samsja Aug 7, 2023
0267c43
feat: wip add json support for tensor
samsja Aug 9, 2023
076f4eb
feat: add orjsons support for tensor
samsja Aug 9, 2023
eac18fa
fix: merege in progress
samsja Aug 22, 2023
efb2109
fix: image url proto
samsja Aug 23, 2023
72eae9f
fix: fix some tests
samsja Aug 23, 2023
e1b5868
fix: fix some tests
samsja Aug 23, 2023
88be3be
fix: fix some tests
samsja Aug 23, 2023
efcc877
fix: fix some tests regarding anyurl
samsja Aug 23, 2023
94f7e13
fix: fix any url problem
samsja Aug 23, 2023
448fa32
fix: add missing method
samsja Aug 23, 2023
47b86a5
fix: fix json
samsja Aug 25, 2023
193ec11
fix: fix some tests
samsja Aug 28, 2023
d952729
fix: fix some tests
samsja Aug 28, 2023
8dba04e
fix: fix some tests
samsja Aug 28, 2023
6e1241c
fix: fix some tests
samsja Aug 28, 2023
db0768d
fix: fix some tests
samsja Aug 28, 2023
d32b3ed
fix: fix tests
samsja Aug 28, 2023
bc24031
chore: update ci#
samsja Aug 29, 2023
c57067b
chore: add gitnignore
samsja Aug 29, 2023
386b25f
fix: fix code to be compatible with python 3.8
samsja Aug 29, 2023
4e01dc0
chore: install v2 in c
samsja Aug 29, 2023
71f5645
Merge branch 'main' into feat-full-pydantic-v2-support
samsja Aug 29, 2023
8db8da3
chore: install v2 in c
samsja Aug 29, 2023
c639703
fix: fix some tests
samsja Aug 29, 2023
f25ff1a
chore: fix pydantic v2 install
samsja Aug 30, 2023
57097fe
fix: fix some integration tests
samsja Aug 30, 2023
568e7d3
fix: fix mesh 3d val
samsja Aug 30, 2023
99f675a
fix: fix spcript
samsja Aug 30, 2023
d1142e3
chore: fix smth
samsja Aug 30, 2023
6bcf372
chore: fix smth
samsja Aug 30, 2023
ed231a0
fix: fix import
samsja Aug 31, 2023
e7364a8
fix: fix audio test v2
samsja Aug 31, 2023
62f48b6
fix: fix some tests integrations
samsja Aug 31, 2023
5042293
fix: fix some integrations tests
samsja Aug 31, 2023
3d0dbfe
fix: fix some mesh tests
samsja Aug 31, 2023
24c4bb1
fix: fix point cloud
samsja Aug 31, 2023
e105146
fix: fix some tests
samsja Aug 31, 2023
d86d196
chore: add marker
samsja Aug 31, 2023
de03e81
fix: fix some tests
samsja Aug 31, 2023
3383a52
fix: pass tests for now
samsja Aug 31, 2023
9ecf204
fix: issue with id json schema
samsja Sep 1, 2023
9054727
chore: do pydantic v2 test everywhere
samsja Sep 1, 2023
c910887
fix: fix poetry lock
samsja Sep 5, 2023
6a3dd8a
fix: update qdrant
samsja Sep 5, 2023
580832e
fix: wip fix pydantic v2 index tests
samsja Sep 5, 2023
ad46ab7
fix: fix pydantic v2 index test
samsja Sep 5, 2023
4ff7eae
fix: fix redis tests
samsja Sep 5, 2023
38a6982
fix: fix el v7 tests
samsja Sep 5, 2023
cd56d8c
fix: fix el v8 tests
samsja Sep 5, 2023
610a3aa
Merge branch 'main' into feat-full-pydantic-v2-support
samsja Sep 5, 2023
9aa12e1
fix: last tests
samsja Sep 5, 2023
8f2ee87
fix: tensorflow pydantic v2 tests
samsja Sep 6, 2023
cf5654b
fix: fix jax with pydantic v
samsja Sep 6, 2023
4613e20
fix: silence on last test
samsja Sep 6, 2023
4134da5
fix: silence on last test
samsja Sep 6, 2023
c259b09
fix: docstring validate
samsja Sep 7, 2023
02b2b61
fix: docstring validate
samsja Sep 7, 2023
cbf7a87
fix: put back cast
samsja Sep 7, 2023
5e2378e
feat: apply johannes suggestion
samsja Sep 7, 2023
19e444b
feat: add comment
samsja Sep 7, 2023
a16018a
feat: add comment
samsja Sep 7, 2023
863e0b8
fix: skip docstrng tet for pydantic v2 for now
samsja Sep 7, 2023
d7a7a49
fix: skip docstrng tet for pydantic v2 for now
samsja Sep 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: use _docarray_fields everywhere
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
  • Loading branch information
samsja committed Jun 19, 2023
commit 979edc74ac0eb78ef5e1dbabcf2abc462d1278da
2 changes: 1 addition & 1 deletion docarray/array/any_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]):
class _DocArrayTyped(cls): # type: ignore
doc_type: Type[BaseDoc] = cast(Type[BaseDoc], item)

for field in _DocArrayTyped.doc_type.__fields__.keys():
for field in _DocArrayTyped.doc_type._docarray_fields.keys():

def _property_generator(val: str):
def _getter(self):
Expand Down
2 changes: 1 addition & 1 deletion docarray/array/doc_list/doc_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]):

if (
not is_union_type(field_type)
and self.__class__.doc_type.__fields__[field].required
and self.__class__.doc_type._docarray_fields[field].required
and isinstance(field_type, type)
and issubclass(field_type, BaseDoc)
):
Expand Down
6 changes: 3 additions & 3 deletions docarray/array/doc_vec/doc_vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ def __init__(
else DocList.__class_getitem__(self.doc_type)(docs)
)

for field_name, field in self.doc_type.__fields__.items():
for field_name, field in self.doc_type._docarray_fields.items():
# here we iterate over the field of the docs schema, and we collect the data
# from each document and put them in the corresponding column
field_type = self.doc_type._get_field_type(field_name)

is_field_required = self.doc_type.__fields__[field_name].required
is_field_required = self.doc_type._docarray_fields[field_name].required

first_doc_is_none = getattr(docs[0], field_name) is None

Expand Down Expand Up @@ -538,7 +538,7 @@ def _set_data_column(
if col is not None:
validation_class = col.__unparametrizedcls__ or col.__class__
else:
validation_class = self.doc_type.__fields__[field].type_
validation_class = self.doc_type._docarray_fields[field].type_

# TODO shape check should be handle by the tensor validation

Expand Down
8 changes: 4 additions & 4 deletions docarray/base_doc/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def is_view(self) -> bool:
return isinstance(self.__dict__, ColumnStorageView)

def __getattr__(self, item) -> Any:
if item in self.__fields__.keys():
if item in self._docarray_fields.keys():
return self.__dict__[item]
else:
return super().__getattribute__(item)
Expand All @@ -184,10 +184,10 @@ def __eq__(self, other) -> bool:
if not isinstance(other, BaseDoc):
return False

if self.__fields__.keys() != other.__fields__.keys():
if self._docarray_fields.keys() != other._docarray_fields.keys():
return False

for field_name in self.__fields__:
for field_name in self._docarray_fields:
value1 = getattr(self, field_name)
value2 = getattr(other, field_name)

Expand Down Expand Up @@ -363,7 +363,7 @@ def _exclude_doclist(
self, exclude: ExcludeType
) -> Tuple[ExcludeType, ExcludeType, List[str]]:
doclist_exclude_fields = []
for field in self.__fields__.keys():
for field in self._docarray_fields.keys():
from docarray import DocList

type_ = self._get_field_type(field)
Expand Down
14 changes: 7 additions & 7 deletions docarray/base_doc/mixins/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class IOMixin(Iterable[Tuple[str, Any]]):
IOMixin to define all the bytes/protobuf/json related part of BaseDoc
"""

__fields__: Dict[str, 'ModelField']
_docarray_fields: Dict[str, 'ModelField']

class Config:
_load_extra_fields_from_protobuf: bool
Expand Down Expand Up @@ -235,7 +235,7 @@ def from_protobuf(cls: Type[T], pb_msg: 'DocProto') -> T:
for field_name in pb_msg.data:
if (
not (cls.Config._load_extra_fields_from_protobuf)
and field_name not in cls.__fields__.keys()
and field_name not in cls._docarray_fields.keys()
):
continue # optimization we don't even load the data if the key does not
# match any field in the cls or in the mapping
Expand Down Expand Up @@ -311,8 +311,8 @@ def _get_content_from_node_proto(

elif content_key in arg_to_container.keys():
field_type = (
cls.__fields__[field_name].type_
if field_name and field_name in cls.__fields__
cls._docarray_fields[field_name].type_
if field_name and field_name in cls._docarray_fields
else None
)
return_field = arg_to_container[content_key](
Expand All @@ -323,8 +323,8 @@ def _get_content_from_node_proto(
elif content_key == 'dict':
deser_dict: Dict[str, Any] = dict()
field_type = (
cls.__fields__[field_name].type_
if field_name and field_name in cls.__fields__
cls._docarray_fields[field_name].type_
if field_name and field_name in cls._docarray_fields
else None
)
for key_name, node in value.dict.data.items():
Expand Down Expand Up @@ -393,7 +393,7 @@ def _get_access_paths(cls) -> List[str]:
from docarray import BaseDoc

paths = []
for field in cls.__fields__.keys():
for field in cls._docarray_fields.keys():
field_type = cls._get_field_type(field)
if not is_union_type(field_type) and safe_issubclass(field_type, BaseDoc):
sub_paths = field_type._get_access_paths()
Expand Down
4 changes: 2 additions & 2 deletions docarray/base_doc/mixins/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class UpdateMixin:
__fields__: Dict[str, 'ModelField']
_docarray_fields: Dict[str, 'ModelField']

def _get_string_for_regex_filter(self):
return str(self)
Expand Down Expand Up @@ -104,7 +104,7 @@ def _group_fields(doc: 'UpdateMixin') -> _FieldGroups:
nested_docs_fields: List[str] = []
nested_docarray_fields: List[str] = []

for field_name, field in doc.__fields__.items():
for field_name, field in doc._docarray_fields.items():
if field_name not in FORBIDDEN_FIELDS_TO_UPDATE:
field_type = doc._get_field_type(field_name)

Expand Down
2 changes: 1 addition & 1 deletion docarray/display/document_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _get_schema(cls: Type['BaseDoc'], doc_name: Optional[str] = None) -> Tree:
root = cls.__name__ if doc_name is None else f'{doc_name}: {cls.__name__}'
tree = Tree(root, highlight=True)

for field_name, value in cls.__fields__.items():
for field_name, value in cls._docarray_fields.items():
if field_name != 'id':
field_type = value.annotation
field_cls = str(field_type).replace('[', '\[')
Expand Down
4 changes: 2 additions & 2 deletions docarray/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _get_field_type_by_access_path(
from docarray import BaseDoc, DocList

field, _, remaining = access_path.partition('__')
field_valid = field in doc_type.__fields__.keys()
field_valid = field in doc_type._docarray_fields.keys()

if field_valid:
if len(remaining) == 0:
Expand Down Expand Up @@ -249,7 +249,7 @@ def _shallow_copy_doc(doc):
field_set = set(doc.__fields_set__)
object.__setattr__(shallow_copy, '__fields_set__', field_set)

for field_name, field_ in doc.__fields__.items():
for field_name, field_ in doc._docarray_fields.items():
val = doc.__getattr__(field_name)
setattr(shallow_copy, field_name, val)

Expand Down
4 changes: 2 additions & 2 deletions docarray/index/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def _flatten_schema(
:return: A list of column names, types, and fields
"""
names_types_fields: List[Tuple[str, Type, 'ModelField']] = []
for field_name, field_ in schema.__fields__.items():
for field_name, field_ in schema._docarray_fields.items():
t_ = schema._get_field_type(field_name)
inner_prefix = name_prefix + field_name + '__'

Expand Down Expand Up @@ -1041,7 +1041,7 @@ def _convert_dict_to_doc(
:param schema: The schema of the Document object
:return: A Document object
"""
for field_name, _ in schema.__fields__.items():
for field_name, _ in schema._docarray_fields.items():
t_ = schema._get_field_type(field_name)

if not is_union_type(t_) and issubclass(t_, AnyDocArray):
Expand Down
2 changes: 1 addition & 1 deletion docarray/store/jac.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _get_raw_summary(self: 'DocList') -> List[Dict[str, Any]]:
),
dict(
name='Fields',
value=tuple(self[0].__class__.__fields__.keys()),
value=tuple(self[0].__class__._docarray_fields.keys()),
description='The fields of the Document',
),
dict(
Expand Down
30 changes: 15 additions & 15 deletions tests/index/base_classes/test_base_doc_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,21 @@ def test_parametrization():

index = DummyDocIndex[SubindexDoc]()
assert index._schema is SubindexDoc
assert list(index._subindices['d']._schema.__fields__.keys()) == [
assert list(index._subindices['d']._schema._docarray_fields.keys()) == [
'id',
'tens',
'parent_id',
]

index = DummyDocIndex[SubSubindexDoc]()
assert index._schema is SubSubindexDoc
assert list(index._subindices['d_root']._schema.__fields__.keys()) == [
assert list(index._subindices['d_root']._schema._docarray_fields.keys()) == [
'id',
'd',
'parent_id',
]
assert list(
index._subindices['d_root']._subindices['d']._schema.__fields__.keys()
index._subindices['d_root']._subindices['d']._schema._docarray_fields.keys()
) == [
'id',
'tens',
Expand Down Expand Up @@ -306,33 +306,33 @@ def test_create_columns():

def test_flatten_schema():
index = DummyDocIndex[SimpleDoc]()
fields = SimpleDoc.__fields__
fields = SimpleDoc._docarray_fields
assert set(index._flatten_schema(SimpleDoc)) == {
('id', ID, fields['id']),
('tens', AbstractTensor, fields['tens']),
}

index = DummyDocIndex[FlatDoc]()
fields = FlatDoc.__fields__
fields = FlatDoc._docarray_fields
assert set(index._flatten_schema(FlatDoc)) == {
('id', ID, fields['id']),
('tens_one', AbstractTensor, fields['tens_one']),
('tens_two', AbstractTensor, fields['tens_two']),
}

index = DummyDocIndex[NestedDoc]()
fields = NestedDoc.__fields__
fields_nested = SimpleDoc.__fields__
fields = NestedDoc._docarray_fields
fields_nested = SimpleDoc._docarray_fields
assert set(index._flatten_schema(NestedDoc)) == {
('id', ID, fields['id']),
('d__id', ID, fields_nested['id']),
('d__tens', AbstractTensor, fields_nested['tens']),
}

index = DummyDocIndex[DeepNestedDoc]()
fields = DeepNestedDoc.__fields__
fields_nested = NestedDoc.__fields__
fields_nested_nested = SimpleDoc.__fields__
fields = DeepNestedDoc._docarray_fields
fields_nested = NestedDoc._docarray_fields
fields_nested_nested = SimpleDoc._docarray_fields
assert set(index._flatten_schema(DeepNestedDoc)) == {
('id', ID, fields['id']),
('d__id', ID, fields_nested['id']),
Expand All @@ -341,7 +341,7 @@ def test_flatten_schema():
}

index = DummyDocIndex[SubindexDoc]()
fields = SubindexDoc.__fields__
fields = SubindexDoc._docarray_fields
assert set(index._flatten_schema(SubindexDoc)) == {
('id', ID, fields['id']),
('d', DocList[SimpleDoc], fields['d']),
Expand All @@ -360,7 +360,7 @@ def test_flatten_schema():
] == [ID, AbstractTensor, ID]

index = DummyDocIndex[SubSubindexDoc]()
fields = SubSubindexDoc.__fields__
fields = SubSubindexDoc._docarray_fields
assert set(index._flatten_schema(SubSubindexDoc)) == {
('id', ID, fields['id']),
('d_root', DocList[SubindexDoc], fields['d_root']),
Expand All @@ -384,8 +384,8 @@ class MyDoc(BaseDoc):
image: ImageDoc

index = DummyDocIndex[MyDoc]()
fields = MyDoc.__fields__
fields_image = ImageDoc.__fields__
fields = MyDoc._docarray_fields
fields_image = ImageDoc._docarray_fields

if torch_imported:
from docarray.typing.tensor.image.image_torch_tensor import ImageTorchTensor
Expand All @@ -409,7 +409,7 @@ class MyDoc3(BaseDoc):
tensor: Union[NdArray, ImageTorchTensor]

index = DummyDocIndex[MyDoc3]()
fields = MyDoc3.__fields__
fields = MyDoc3._docarray_fields
assert set(index._flatten_schema(MyDoc3)) == {
('id', ID, fields['id']),
('tensor', AbstractTensor, fields['tensor']),
Expand Down