I would like to pass a Callable
(i.e. a function) or even a Task
as a keyword argument to a Task
. This can’t be done by default because it is not JSON serializable, and Pydantic throws an error when creating the model parameters.
Are there any ways I can force Prefect to use a different serialization method? I see some documentation about a pickle serializer, but that only applies to the results and not the parameter creation.
from prefect import task, flow
@task
def add(x, y):
return x + y
@flow
def workflow(f=add):
return f(1, 2)
The above example runs if add
is a positional argument — just not as a keyword argument!