You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
Sometimes it can be useful to dynamically create a BaseDoc from a given schema of an original BaseDoc. Using the methods create_pure_python_type_model and create_base_doc_from_schema you can make sure to reconstruct the BaseDoc.
fromdocarray.utils.create_dynamic_doc_classimport (
create_base_doc_from_schema,
create_pure_python_type_model,
)
fromtypingimportOptionalfromdocarrayimportBaseDoc, DocListfromdocarray.typingimportAnyTensorfromdocarray.documentsimportTextDocclassMyDoc(BaseDoc):
tensor: Optional[AnyTensor]
texts: DocList[TextDoc]
MyDocPurePython=create_pure_python_type_model(MyDoc) # Due to limitation of DocList as Pydantic List, we need to have the MyDoc `DocList` converted to `List`.NewMyDoc=create_base_doc_from_schema(
MyDocPurePython.schema(), 'MyDoc', {}
)
new_doc=NewMyDoc(tensor=None, texts=[TextDoc(text='text')])
馃悶 Bug Fixes
Better error message when DocVec is unusable (#1675)
After calling doc_list = doc_vec.to_doc_list(), doc_vec ends up in an unusable state since its data has been transferred to doc_list. This fix gives users a more informative error message when they try to interact with doc_vec after it has been made unusable.
Activity