Jeff Kehler
03/28/2022, 8:31 AMParameter
into the class constructor __init__
of a task that has been subclassed from prefect.Task
I am receiving a prefect.Task
object instead of the value from the Parameter itself. I can't seem to figure out what I'm doing wrong.Sylvain Hazard
03/28/2022, 8:45 AMParameters
should be passed as runtime field values for other tasks. Tasks are initialized at registering time which means your parameter does not have a value yet.Anna Geller
03/28/2022, 9:36 AMrun()
method of your task, as the run method, in contrast to __init__
, gets evaluated at runtime. Something like:
import prefect
from prefect import Task
class YourCustomTask(Task):
def run(self):
param = prefect.context["parameters"].get("parameter_name")
print(f"Got parameter value: {param}")
Sylvain Hazard
03/28/2022, 9:43 AMJeff Kehler
03/28/2022, 10:08 AM