HI! I would like to ask if parameters passed to a task in Prefect 2.0 are also validated with pydantic or is this the case only in the flow level. (For example if I have provided pydantic annotations/field types or a pydantic model to a downstream task will prefect still check the data the upstream task passes to the downstream task in runtime?)
06/08/2022, 10:54 AM
For now, we only support pydantic type validation in flows, not in tasks. There are some reasons for that:
• This validation is mainly needed so that when you create your run, e.g. via UI or API call, you can pass custom parameter values and this way, they will be validated/type-checked
• this level of validation is not that needed for tasks since you can write arbitrary Python within your flow and tasks to perform validation
Having said that, I will add your request to a backlog and perhaps sometime later this year, we can consider adding pydantic to tasks as well
@Marvin open "Backlog: add Pydantic type validation to the task decorator"