weaviate-python-client icon indicating copy to clipboard operation
weaviate-python-client copied to clipboard

Pydantic unable to generate schema when importing weaviate

Open Josipmrden opened this issue 1 year ago • 1 comments

How to reproduce this bug?

It happens during the loading the module for Memgraph. In the local environment, I'm able to add the module and do the code with it, which is a bit weird

[Please let me know if I need to submit this issue to some other repository]

What is the expected behavior?

Should work well with Pydantic

What is the actual behavior?

  File "/usr/local/lib/python3.9/dist-packages/weaviate/__init__.py", line 15, in <module>
    from .client import Client, WeaviateAsyncClient, WeaviateClient
  File "/usr/local/lib/python3.9/dist-packages/weaviate/client.py", line 13, in <module>
    from weaviate.backup.backup import _BackupAsync
  File "/usr/local/lib/python3.9/dist-packages/weaviate/backup/__init__.py", line 7, in <module>
    from weaviate.backup.backup import Backup
  File "/usr/local/lib/python3.9/dist-packages/weaviate/backup/backup.py", line 12, in <module>
    from weaviate.connect import Connection, ConnectionV4
  File "/usr/local/lib/python3.9/dist-packages/weaviate/connect/__init__.py", line 6, in <module>
    from .base import ConnectionParams, ProtocolParams
  File "/usr/local/lib/python3.9/dist-packages/weaviate/connect/base.py", line 13, in <module>
    from weaviate.config import Proxies
  File "/usr/local/lib/python3.9/dist-packages/weaviate/config.py", line 53, in <module>
    class Timeout(BaseModel):
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_model_construction.py", line 226, in __new__
      complete_model_class(
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_model_construction.py", line 658, in complete_model_class
    schema = cls.__get_pydantic_core_schema__(cls, handler)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/main.py", line 702, in __get_pydantic_core_schema__
    return handler(source)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_schema_generation_shared.py", line 84, in __call__
    schema = self._handler(source_type)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 612, in generate_schema
    schema = self._generate_schema_inner(obj)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 881, in _generate_schema_inner
    return self._model_schema(obj)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 693, in _model_schema
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 693, in <dictcomp>
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 1073, in _generate_md_field_schema
    common_field = self._common_field_schema(name, field_info, decorators)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 1265, in _common_field_schema
    schema = self._apply_annotations(
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 2062, in _apply_annotations
    schema = get_inner_schema(source_type)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_schema_generation_shared.py", line 84, in __call__
    schema = self._handler(source_type)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 2137, in new_handler
    schema = metadata_get_schema(source, get_inner_schema)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 2133, in <lambda>
    lambda source, handler: handler(source)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_schema_generation_shared.py", line 84, in __call__
    schema = self._handler(source_type)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 2043, in inner_handler
    schema = self._generate_schema_inner(obj)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 886, in _generate_schema_inner
    return self.match_type(obj)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 997, in match_type
    return self._unknown_type_schema(obj)
  File "/usr/local/lib/python3.9/dist-packages/pydantic/_internal/_generate_schema.py", line 515, in _unknown_type_schema
    raise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.Union[int, float]. 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.

Supporting information

No response

Server Version

4.9.6 Python version of the client, not using Weaviate

Weaviate Setup

Single Node

Nodes count

x

Code of Conduct

Josipmrden avatar Dec 13 '24 11:12 Josipmrden

hi @Josipmrden !!

Can you give us some more context? It could really help to provide a way we could reproduce this.

THanks!

dudanogueira avatar Dec 16 '24 20:12 dudanogueira

Closign, because no context was given

dirkkul avatar Apr 22 '25 07:04 dirkkul