object instead of the value from the Parameter itself. I can't seem to figure out what I'm doing wrong.
s
Sylvain Hazard
03/28/2022, 8:45 AM
Parameters
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.
upvote 1
a
Anna Geller
03/28/2022, 9:36 AM
Exactly as explained☝️ by Sylvain. I can only add: you could retrieve the parameter value from the context in the
run()
method of your task, as the run method, in contrast to
__init__
, gets evaluated at runtime. Something like:
Copy code
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}")
🙌 1
s
Sylvain Hazard
03/28/2022, 9:43 AM
Oh I didn't know you could access all parameters through the context. Could see that being useful !
Thanks Anna !
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.