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

Pydantic unable to generate schema when importing weaviate #1496

Open
1 task done
Josipmrden opened this issue Dec 13, 2024 · 1 comment
Open
1 task done

Pydantic unable to generate schema when importing weaviate #1496

Josipmrden opened this issue Dec 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Josipmrden
Copy link

Josipmrden commented Dec 13, 2024

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 Josipmrden added the bug Something isn't working label Dec 13, 2024
@dudanogueira
Copy link
Contributor

hi @Josipmrden !!

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

THanks!

@dirkkul dirkkul transferred this issue from weaviate/weaviate Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants