Skip to content
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

PydanticSchemaGenerationError #2

Open
uzumakinaruto19 opened this issue May 8, 2024 · 0 comments
Open

PydanticSchemaGenerationError #2

uzumakinaruto19 opened this issue May 8, 2024 · 0 comments

Comments

@uzumakinaruto19
Copy link

Hi,

when i tried this

from neo4j_haystack import Neo4jDocumentStore

I'm getting this error

{ "name": "PydanticSchemaGenerationError", "message": "Unable to generate pydantic-core schema for <class 'pandas.core.frame.DataFrame'>. Setarbitrary_types_allowed=Truein the model_config to ignore this error or implementget_pydantic_core_schema` on your type to fully support it.

If you got this error by calling handler() within __get_pydantic_core_schema__ then you likely need to call handler.generate_schema(<some type>) since we do not call __get_pydantic_core_schema__ on <some type> otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.4/u/schema-for-unknown-type",
"stack": "---------------------------------------------------------------------------
PydanticSchemaGenerationError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from neo4j_haystack import Neo4jDocumentStore

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/neo4j_haystack/init.py:1
----> 1 from neo4j_haystack.client import Neo4jClient, Neo4jClientConfig, VectorStoreIndexInfo
2 from neo4j_haystack.components import (
3 Neo4jDynamicDocumentRetriever,
4 Neo4jEmbeddingRetriever,
5 )
6 from neo4j_haystack.document_stores import Neo4jDocumentStore

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/neo4j_haystack/client/init.py:1
----> 1 from neo4j_haystack.client.neo4j_client import (
2 Neo4jClient,
3 Neo4jClientConfig,
4 Neo4jRecord,
5 VectorStoreIndexInfo,
6 )
8 all = (
9 "Neo4jClient",
10 "Neo4jClientConfig",
11 "Neo4jRecord",
12 "VectorStoreIndexInfo",
13 )

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/neo4j_haystack/client/neo4j_client.py:17
3 from dataclasses import dataclass, field
4 from typing import (
5 Any,
6 Callable,
(...)
14 cast,
15 )
---> 17 from haystack import default_from_dict, default_to_dict
18 from neo4j import (
19 Auth,
20 GraphDatabase,
(...)
26 unit_of_work,
27 )
29 from neo4j_haystack.errors import Neo4jClientError

File ~/.local/lib/python3.11/site-packages/haystack/init.py:10
6 version: str = str(metadata.version("farm-haystack"))
9 import haystack.silenceable_tqdm # Needs to be imported first to wrap TQDM for all following modules
---> 10 from haystack.schema import Document, Answer, Label, MultiLabel, Span, EvaluationResult, TableCell
11 from haystack.nodes.base import BaseComponent
12 from haystack.pipelines.base import Pipeline

File ~/.local/lib/python3.11/site-packages/haystack/schema.py:41
36 FilterType = Dict[str, Union[Dict[str, Any], List[Any], str, int, float, bool]]
38 LABEL_DATETIME_FORMAT: str = "%Y-%m-%d %H:%M:%S"
---> 41 @DataClass
42 class Document:
43 id: str
44 content: Union[str, DataFrame]

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/dataclasses.py:213, in dataclass(_cls, init, repr, eq, order, unsafe_hash, frozen, config, validate_on_init, kw_only, slots)
210 if _cls is None:
211 return create_dataclass
--> 213 return create_dataclass(_cls)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/dataclasses.py:204, in dataclass..create_dataclass(cls)
202 cls.module = original_cls.module
203 cls.qualname = original_cls.qualname
--> 204 pydantic_complete = _pydantic_dataclasses.complete_dataclass(
205 cls, config_wrapper, raise_errors=False, types_namespace=None
206 )
207 cls.pydantic_complete = pydantic_complete # type: ignore
208 return cls

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_dataclasses.py:152, in complete_dataclass(cls, config_wrapper, raise_errors, types_namespace)
143 schema = get_core_schema(
144 cls,
145 CallbackGetCoreSchemaHandler(
(...)
149 ),
150 )
151 else:
--> 152 schema = gen_schema.generate_schema(cls, from_dunder_get_core_schema=False)
153 except PydanticUndefinedAnnotation as e:
154 if raise_errors:

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:452, in GenerateSchema.generate_schema(self, obj, from_dunder_get_core_schema)
449 schema = from_property
451 if schema is None:
--> 452 schema = self._generate_schema(obj)
454 metadata_js_function = _extract_get_pydantic_json_schema(obj, schema)
455 if metadata_js_function is not None:

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:684, in GenerateSchema._generate_schema(self, obj)
682 needs_apply_discriminated_union = self._needs_apply_discriminated_union
683 self._needs_apply_discriminated_union = False
--> 684 schema = self._post_process_generated_schema(self._generate_schema_inner(obj))
685 self._has_invalid_schema = self._has_invalid_schema or has_invalid_schema
686 self._needs_apply_discriminated_union = self._needs_apply_discriminated_union or needs_apply_discriminated_union

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:711, in GenerateSchema._generate_schema_inner(self, obj)
708 if isinstance(obj, PydanticRecursiveRef):
709 return core_schema.definition_reference_schema(schema_ref=obj.type_ref)
--> 711 return self.match_type(obj)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:785, in GenerateSchema.match_type(self, obj)
782 return get_enum_core_schema(obj, self._config_wrapper.config_dict)
784 if _typing_extra.is_dataclass(obj):
--> 785 return self._dataclass_schema(obj, None)
787 res = self._get_prepare_pydantic_annotations_for_known_type(obj, ())
788 if res is not None:

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:1348, in GenerateSchema._dataclass_schema(self, dataclass, origin)
1345 decorators = dataclass.dict.get('pydantic_decorators') or DecoratorInfos.build(dataclass)
1346 # Move kw_only=False args to the start of the list, as this is how vanilla dataclasses work.
1347 # Note that when kw_only is missing or None, it is treated as equivalent to kw_only=True
-> 1348 args = sorted(
1349 (self._generate_dc_field_schema(k, v, decorators) for k, v in fields.items()),
1350 key=lambda a: a.get('kw_only') is not False,
1351 )
1352 has_post_init = hasattr(dataclass, 'post_init')
1353 has_slots = hasattr(dataclass, 'slots')

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:1349, in (.0)
1345 decorators = dataclass.dict.get('pydantic_decorators') or DecoratorInfos.build(dataclass)
1346 # Move kw_only=False args to the start of the list, as this is how vanilla dataclasses work.
1347 # Note that when kw_only is missing or None, it is treated as equivalent to kw_only=True
1348 args = sorted(
-> 1349 (self._generate_dc_field_schema(k, v, decorators) for k, v in fields.items()),
1350 key=lambda a: a.get('kw_only') is not False,
1351 )
1352 has_post_init = hasattr(dataclass, 'post_init')
1353 has_slots = hasattr(dataclass, 'slots')

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:887, in GenerateSchema._generate_dc_field_schema(self, name, field_info, decorators)
880 def _generate_dc_field_schema(
881 self,
882 name: str,
883 field_info: FieldInfo,
884 decorators: DecoratorInfos,
885 ) -> core_schema.DataclassField:
886 """Prepare a DataclassField to represent the parameter/field, of a dataclass."""
--> 887 common_field = self._common_field_schema(name, field_info, decorators)
888 return core_schema.dataclass_field(
889 name,
890 common_field['schema'],
(...)
897 metadata=common_field['metadata'],
898 )

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:923, in GenerateSchema._common_field_schema(self, name, field_info, decorators)
921 schema = self._apply_annotations(source_type, annotations, transform_inner_schema=set_discriminator)
922 else:
--> 923 schema = self._apply_annotations(
924 source_type,
925 annotations,
926 )
928 # This V1 compatibility shim should eventually be removed
929 # push down any each_item=True validators
930 # note that this won't work for any Annotated types that get wrapped by a function validator
931 # but that's okay because that didn't exist in V1
932 this_field_validators = filter_field_decorator_info_by_field(decorators.validators.values(), name)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:1592, in GenerateSchema._apply_annotations(self, source_type, annotations, transform_inner_schema)
1587 continue
1588 get_inner_schema = self._get_wrapped_inner_schema(
1589 get_inner_schema, annotation, pydantic_js_annotation_functions
1590 )
-> 1592 schema = get_inner_schema(source_type)
1593 if pydantic_js_annotation_functions:
1594 metadata = CoreMetadataHandler(schema).metadata

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py:82, in CallbackGetCoreSchemaHandler.call(self, _CallbackGetCoreSchemaHandler__source_type)
81 def call(self, __source_type: Any) -> core_schema.CoreSchema:
---> 82 schema = self._handler(__source_type)
83 ref = schema.get('ref')
84 if self._ref_mode == 'to-def':

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:1573, in GenerateSchema._apply_annotations..inner_handler(obj)
1571 from_property = self._generate_schema_from_property(obj, obj)
1572 if from_property is None:
-> 1573 schema = self._generate_schema(obj)
1574 else:
1575 schema = from_property

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:684, in GenerateSchema._generate_schema(self, obj)
682 needs_apply_discriminated_union = self._needs_apply_discriminated_union
683 self._needs_apply_discriminated_union = False
--> 684 schema = self._post_process_generated_schema(self._generate_schema_inner(obj))
685 self._has_invalid_schema = self._has_invalid_schema or has_invalid_schema
686 self._needs_apply_discriminated_union = self._needs_apply_discriminated_union or needs_apply_discriminated_union

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:711, in GenerateSchema._generate_schema_inner(self, obj)
708 if isinstance(obj, PydanticRecursiveRef):
709 return core_schema.definition_reference_schema(schema_ref=obj.type_ref)
--> 711 return self.match_type(obj)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:794, in GenerateSchema.match_type(self, obj)
792 origin = get_origin(obj)
793 if origin is not None:
--> 794 return self._match_generic_type(obj, origin)
796 if self._arbitrary_types:
797 return self._arbitrary_type_schema(obj)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:818, in GenerateSchema._match_generic_type(self, obj, origin)
815 return from_property
817 if _typing_extra.origin_is_union(origin):
--> 818 return self._union_schema(obj)
819 elif origin in TUPLE_TYPES:
820 return self._tuple_schema(obj)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:1006, in GenerateSchema._union_schema(self, union_type)
1004 nullable = True
1005 else:
-> 1006 choices.append(self.generate_schema(arg))
1008 if len(choices) == 1:
1009 first_choice = choices[0]

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:452, in GenerateSchema.generate_schema(self, obj, from_dunder_get_core_schema)
449 schema = from_property
451 if schema is None:
--> 452 schema = self._generate_schema(obj)
454 metadata_js_function = _extract_get_pydantic_json_schema(obj, schema)
455 if metadata_js_function is not None:

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:684, in GenerateSchema._generate_schema(self, obj)
682 needs_apply_discriminated_union = self._needs_apply_discriminated_union
683 self._needs_apply_discriminated_union = False
--> 684 schema = self._post_process_generated_schema(self._generate_schema_inner(obj))
685 self._has_invalid_schema = self._has_invalid_schema or has_invalid_schema
686 self._needs_apply_discriminated_union = self._needs_apply_discriminated_union or needs_apply_discriminated_union

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:711, in GenerateSchema._generate_schema_inner(self, obj)
708 if isinstance(obj, PydanticRecursiveRef):
709 return core_schema.definition_reference_schema(schema_ref=obj.type_ref)
--> 711 return self.match_type(obj)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:798, in GenerateSchema.match_type(self, obj)
796 if self._arbitrary_types:
797 return self._arbitrary_type_schema(obj)
--> 798 return self._unknown_type_schema(obj)

File ~/anaconda3/envs/KG/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py:366, in GenerateSchema._unknown_type_schema(self, obj)
365 def _unknown_type_schema(self, obj: Any) -> CoreSchema:
--> 366 raise PydanticSchemaGenerationError(
367 f'Unable to generate pydantic-core schema for {obj!r}. '
368 'Set arbitrary_types_allowed=True in the model_config to ignore this error'
369 ' or implement __get_pydantic_core_schema__ on your type to fully support it.'
370 '

If you got this error by calling handler() within'
371 ' __get_pydantic_core_schema__ then you likely need to call'
372 ' handler.generate_schema(<some type>) since we do not call'
373 ' __get_pydantic_core_schema__ on <some type> otherwise to avoid infinite recursion.'
374 )

PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'pandas.core.frame.DataFrame'>. Set arbitrary_types_allowed=True in the model_config to ignore this error or implement __get_pydantic_core_schema__ on your type to fully support it.

If you got this error by calling handler() within __get_pydantic_core_schema__ then you likely need to call handler.generate_schema(<some type>) since we do not call __get_pydantic_core_schema__ on <some type> otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.4/u/schema-for-unknown-type"
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant