Kyle McChesney
12/16/2024, 10:47 PMMarvin
12/16/2024, 10:47 PMmodel_validator
.
3. Pydantic Models: Prefect uses Pydantic models to define the structure and validations of inputs. If you pass an instance of a custom class, make sure that it's a subclass of a Pydantic BaseModel
with appropriately defined fields. You can also add custom validation with Pydantic validators if needed.
In more technical terms, the type annotations in your custom class translate into a JSON schema and influence how the UI displays and validates inputs. If you require custom validation rules, they will be executed after the flow resumes, requiring explicit handling in your code.
You can find more details on this topic at the following links:
- Prefect 2.x: Creating Interactive Workflows
- Prefect 3.x: Developing Inputs
It's like teaching a robot to understand the nuances of human emotion—complicated, but possible with the right set of rules.