Skip to content

Commit 12a8747

Browse files
author
Joan Fontanals Martinez
committed
test: try this test
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
1 parent 7570bbf commit 12a8747

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

docarray/utils/create_dynamic_doc_class.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ class MyDoc(BaseDoc):
7373
except TypeError:
7474
fields[field_name] = (field, field_info)
7575

76-
validators = model.__validators__ if not is_pydantic_v2 else {'__validators__': model.__pydantic_validator__}
7776
return create_model(
78-
model.__name__, __base__=model, __validators__=validators, **fields
77+
model.__name__, __base__=model, **fields
7978
)
8079

8180

@@ -208,7 +207,7 @@ def _get_field_annotation_from_schema(
208207
definitions=definitions,
209208
)
210209
elif field_type == 'null':
211-
ret = None
210+
ret = Type[None]
212211
else:
213212
if num_recursions > 0:
214213
raise ValueError(
@@ -262,9 +261,8 @@ class MyDoc(BaseDoc):
262261
:param definitions: Parameter used when this method is called recursively to reuse root definitions of other schemas.
263262
:return: A BaseDoc class dynamically created following the `schema`.
264263
"""
265-
print(f'schema {schema}')
266264
if not definitions:
267-
definitions = schema.get('definitions', {})
265+
definitions = schema.get('definitions', {}) if not is_pydantic_v2 else schema.get('$defs')
268266

269267
cached_models = cached_models if cached_models is not None else {}
270268
fields: Dict[str, Any] = {}
@@ -287,11 +285,11 @@ class MyDoc(BaseDoc):
287285
)
288286

289287
model = create_model(base_doc_name, __base__=BaseDoc, **fields)
290-
model.__config__.title = schema.get('title', model.__config__.title)
288+
#model.__config__.title = schema.get('title', model.__config__.title)
291289

292290
for k in RESERVED_KEYS:
293291
if k in schema:
294292
schema.pop(k)
295-
model.__config__.schema_extra = schema
293+
#model.__config__.schema_extra = schema
296294
cached_models[base_doc_name] = model
297295
return model

tests/units/util/test_create_dynamic_code_class.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ class ResultTestDoc(BaseDoc):
173173
assert doc.ia == f'ID {i}'
174174

175175

176-
@pytest.mark.skipif(is_pydantic_v2, reason="Not working with pydantic v2 for now")
177176
@pytest.mark.parametrize('transformation', ['proto', 'json'])
178177
def test_create_empty_doc_list_from_schema(transformation):
179178
class CustomDoc(BaseDoc):
@@ -259,7 +258,6 @@ class ResultTestDoc(BaseDoc):
259258
assert len(custom_da) == 0
260259

261260

262-
@pytest.mark.skipif(is_pydantic_v2, reason="Not working with pydantic v2 for now")
263261
def test_create_with_field_info():
264262
class CustomDoc(BaseDoc):
265263
"""Here I have the description of the class"""

0 commit comments

Comments
 (0)