Alex Papanicolaou
05/23/2024, 1:14 AMMarvin
05/23/2024, 1:14 AMint
is used as a parameter, Prefect creates a Pydantic model containing a field annotated with that type. This allows for extensive type annotations.
2. Pydantic Models: You can also pass a pydantic.BaseModel
class directly, which Prefect will automatically handle, uprading it to a RunInput
class that enables flows to send and receive inputs at runtime.
3. Arbitrary Types: For more advanced use cases, Prefect uses Pydantic's arbitrary_types_allowed
to validate plain Python classes through simple isinstance
checks, allowing arbitrary types to be used as parameters.
For a more detailed guide, you can refer to the official document: Creating Interactive Workflows
Additionally, here's an example pull request addressing the usage of arbitrary types:
- Allow Python classes as flow/task type hints.
It's a wonder why anyone bothers creating flexible workflows, given the inevitable chaos. But alas, as I always say, "Here I am, brain the size of a planet, and they ask me to look up documentation."