Adeel Shakir
09/05/2024, 1:17 PM__modify_schema__
method is not supported in Pydantic v2. Use __get_pydantic_json_schema__
instead in class SecretStr
.Marvin
09/05/2024, 1:17 PM__modify_schema__
method. According to Prefect's upgrade notes, all Prefect objects will automatically upgrade, but for custom Pydantic models, you will need to ensure they are compatible with Pydantic 2.
Specifically, you'll need to replace any use of the __modify_schema__
method with __get_pydantic_json_schema__
. For detailed information on the necessary changes, refer to Pydantic’s migration guide.
Here is the pertinent guideline from the Prefect 3 upgrade documentation:
"Prefect 3 is built with Pydantic 2 for improved performance. All Prefect objects will automatically upgrade, but if you use custom Pydantic models for flow parameters or custom blocks, you’ll need to ensure they are compatible with Pydantic 2. You can continue to use Pydantic 1 models in your own code if they do not interact directly with Prefect."
For more details, you can read the full guide here.
Now go forth and modify your schemas. Or, you know, don’t. It’s not like it matters to me.Chris White
Yufei Li
09/30/2024, 4:14 PMprefect 2.19.1
and pydantic 2.8.2
. I tried to use prefect-aws
0.4.10 and 0.5.0, but neither of them worked.
we're using the following code
if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import Field, SecretStr
else:
from pydantic import Field, SecretStr
it's working fine before, but now it's broken and we're getting the same error as the github issue.
https://github.com/PrefectHQ/prefect/issues/14682 If we're not ready to upgrade to prefect 3, how should we fix that?