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 Troubles with Prefect 3 #83

Closed
padioca opened this issue Oct 11, 2024 · 1 comment
Closed

Pydantic Troubles with Prefect 3 #83

padioca opened this issue Oct 11, 2024 · 1 comment

Comments

@padioca
Copy link

padioca commented Oct 11, 2024

I am trying to use prefect-airbyte with Prefect 3 and continue to run into issues with the Pydantic version. It seems like this package is maybe no longer being maintained, but posting here in the off chance someone has a solution. Here is the error I am receiving:

Traceback (most recent call last):
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/xyz-prefect/.venv/lib/python3.11/site-packages/prefect_airbyte/init.py", line 3, in
from prefect_airbyte.connections import AirbyteConnection # noqa F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/prefect_airbyte/connections.py", line 21, in
from prefect_airbyte.server import AirbyteServer
File "/xyz-prefect/.venv/lib/python3.11/site-packages/prefect_airbyte/server.py", line 16, in
class AirbyteServer(Block):
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 224, in new
complete_model_class(
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 577, in complete_model_class
schema = cls.get_pydantic_core_schema(cls, handler)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/main.py", line 671, in get_pydantic_core_schema
return handler(source)
^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in call
schema = self._handler(source_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 655, in generate_schema
schema = self._generate_schema_inner(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 924, in _generate_schema_inner
return self._model_schema(obj)
^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 739, in _model_schema
{k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 739, in
{k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1115, in _generate_md_field_schema
common_field = self._common_field_schema(name, field_info, decorators)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 1308, in _common_field_schema
schema = self._apply_annotations(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 2107, in _apply_annotations
schema = get_inner_schema(source_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in call
schema = self._handler(source_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 2091, in inner_handler
metadata_js_function = _extract_get_pydantic_json_schema(obj, schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/xyz-prefect/.venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py", line 2447, in _extract_get_pydantic_json_schema
raise PydanticUserError(
pydantic.errors.PydanticUserError: The __modify_schema__ method is not supported in Pydantic v2. Use __get_pydantic_json_schema__ instead in class SecretStr.

For further information visit https://errors.pydantic.dev/2.9/u/custom-json-schema

@zzstoatzz
Copy link
Contributor

hi @padioca - sorry, it looks like we forgot to update the readme here.

this collection is no longer maintained by Prefect and was not migrated to prefect 3.x (where notably, prefect 3.x uses pydantic 2 instead of using pydantic 1 like prefect 2.x did)

I will make sure this is updated so this is clear, sorry again about the confusion. in the meantime I would encourage you to:

  • yank any logic you find useful from this library and use it directly or fork this

I will say that I originally wrote this before airbyte released their cloud api, so the logic itself is likely outdated.

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

2 participants