Unable to add custom values to prefect.context #3224
Answered
by
cicdw
sierrezinal
asked this question in
Q&A
-
with Flow("myflow", schedule=schedule) as flow:
jobid = Parameter("jobid")
prefect.context.update({'jobid': jobid})Later on in my task, reading from the context returns |
Beta Was this translation helpful? Give feedback.
Answered by
cicdw
Aug 26, 2020
Replies: 1 comment 1 reply
-
|
If you are using flow.run(context={'jobid': jobid})If you are using Prefect Cloud or Server, the API allows you to provide new key / value pairs for each ad-hoc run. Also, it appears that you are using context incorrectly. You should never place tasks in context; if you are interested in passing data from one task to another, you should do so explicitly: with Flow("myflow", schedule=schedule) as flow:
jobid = Parameter("jobid")
another_task(jobid=jobid) # will pass the jobid value to the task |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sierrezinal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you are using
flow.run, the correct way to specify new context key / value pairs is via thecontextkeyword argument:If you are using Prefect Cloud or Server, the API allows you to provide new key / value pairs for each ad-hoc run.
Also, it appears that you are using context incorrectly. You should never place tasks in context; if you are interested in passing data from one task to another, you should do so explicitly: