Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
chore: change method name
  • Loading branch information
Joan Fontanals Martinez committed Jun 22, 2023
commit 2a0b302f638febf9119128a9f216d3d4eeaa1cb4
4 changes: 2 additions & 2 deletions docarray/utils/create_dynamic_doc_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict, List, Any, Union, Optional, Type


def create_new_model_cast_doclist_to_list(model: Any) -> BaseDoc:
def create_pure_python_type_model(model: Any) -> BaseDoc:
"""
Take a Pydantic model and cast DocList fields into List fields.

Expand Down Expand Up @@ -206,7 +206,7 @@ class MyDoc(BaseDoc):
texts: DocList[TextDoc]


MyDocCorrected = create_new_model_cast_doclist_to_list(CustomDoc)
MyDocCorrected = create_pure_python_type_model(CustomDoc)
new_my_doc_cls = create_base_doc_from_schema(CustomDocCopy.schema(), 'MyDoc')
```

Expand Down
14 changes: 7 additions & 7 deletions tests/units/util/test_create_dynamic_code_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List, Dict, Union, Any
from docarray.utils.create_dynamic_doc_class import (
create_base_doc_from_schema,
create_new_model_cast_doclist_to_list,
create_pure_python_type_model,
)
import numpy as np
from typing import Optional
Expand All @@ -26,7 +26,7 @@ class CustomDoc(BaseDoc):
lu: List[Union[str, int]] = [0, 1, 2]
tags: Optional[Dict[str, Any]] = None

CustomDocCopy = create_new_model_cast_doclist_to_list(CustomDoc)
CustomDocCopy = create_pure_python_type_model(CustomDoc)
new_custom_doc_model = create_base_doc_from_schema(
CustomDocCopy.schema(), 'CustomDoc', {}
)
Expand Down Expand Up @@ -95,7 +95,7 @@ class CustomDoc(BaseDoc):
class TextDocWithId(BaseDoc):
ia: str

TextDocWithIdCopy = create_new_model_cast_doclist_to_list(TextDocWithId)
TextDocWithIdCopy = create_pure_python_type_model(TextDocWithId)
new_textdoc_with_id_model = create_base_doc_from_schema(
TextDocWithIdCopy.schema(), 'TextDocWithId', {}
)
Expand Down Expand Up @@ -125,7 +125,7 @@ class TextDocWithId(BaseDoc):
class ResultTestDoc(BaseDoc):
matches: DocList[TextDocWithId]

ResultTestDocCopy = create_new_model_cast_doclist_to_list(ResultTestDoc)
ResultTestDocCopy = create_pure_python_type_model(ResultTestDoc)
new_result_test_doc_with_id_model = create_base_doc_from_schema(
ResultTestDocCopy.schema(), 'ResultTestDoc', {}
)
Expand Down Expand Up @@ -171,7 +171,7 @@ class CustomDoc(BaseDoc):
tags: Optional[Dict[str, Any]] = None
lf: List[float] = [3.0, 4.1]

CustomDocCopy = create_new_model_cast_doclist_to_list(CustomDoc)
CustomDocCopy = create_pure_python_type_model(CustomDoc)
new_custom_doc_model = create_base_doc_from_schema(
CustomDocCopy.schema(), 'CustomDoc'
)
Expand All @@ -196,7 +196,7 @@ class CustomDoc(BaseDoc):
class TextDocWithId(BaseDoc):
ia: str

TextDocWithIdCopy = create_new_model_cast_doclist_to_list(TextDocWithId)
TextDocWithIdCopy = create_pure_python_type_model(TextDocWithId)
new_textdoc_with_id_model = create_base_doc_from_schema(
TextDocWithIdCopy.schema(), 'TextDocWithId', {}
)
Expand All @@ -219,7 +219,7 @@ class TextDocWithId(BaseDoc):
class ResultTestDoc(BaseDoc):
matches: DocList[TextDocWithId]

ResultTestDocCopy = create_new_model_cast_doclist_to_list(ResultTestDoc)
ResultTestDocCopy = create_pure_python_type_model(ResultTestDoc)
new_result_test_doc_with_id_model = create_base_doc_from_schema(
ResultTestDocCopy.schema(), 'ResultTestDoc', {}
)
Expand Down