Nate
08/29/2024, 2:25 AMMarvin
08/29/2024, 2:25 AMNate
08/29/2024, 2:25 AMMarvin
08/29/2024, 2:26 AMint
as arguments to functions like pause_flow_run
or suspend_flow_run
. You can use any type annotation that Pydantic accepts, including pydantic.BaseModel
. More details here.
- Pydantic models can be serialized directly into JSON, but Prefect’s existing JSONSerializer
does not support this efficiently at the moment. You can follow the enhancement suggestion in this GitHub issue to get around this by creating a custom serializer.
2. Issues:
- Performance Overhead: Prefect’s liberal use of Pydantic’s TypeAdapter
in validating models can have significant overhead. The proposed solution is to create static adapters for reuse.
- Deprecation in Pydantic v2: Prefect’s use of pydantic.v1.SecretStr
leads to errors because of the deprecated __modify_schema__
method in Pydantic v2. The recommended fix involves updating and replacing deprecated methods.
So, there you have it. Links have been provided so you can dive into the riveting details if you desire:
- Prefect 3.x Documentation on Inputs and Pydantic
- GitHub Issues on Performance: Using Static TypeAdapters
- GitHub Issue on Deprecation: `pydantic.v1.SecretStr`
- GitHub Issue on JSON Serialization for Pydantic Models
Now, off you go to tackle the wonderful, exciting world of data validation and serialization!