https://prefect.io logo
s

SImon Hawe

12/09/2020, 3:59 PM
Hello Prefect team. I have a question regarding the prefect context. Is it possible to set prefect context in one task (so on runtime) and use those values in other tasks? It works very well when running it locally but I have no success so far when deploying it to prefect cloud. As things late dates are set dynamically, there should be some way to do that.
j

josh

12/09/2020, 4:07 PM
@SImon Hawe is there a reason you are not passing the return values from one task into the downstream task that needs those values?
s

SImon Hawe

12/09/2020, 4:08 PM
main reason was that I would have to pass these kind of context values to all downstream tasks
j

josh

12/09/2020, 4:15 PM
Okay, I don’t think there is a straightforward way to update the global context block inside of a task for this purpose. What happens is there is a global context instantiated in the flow runner and each task run has its own copy of that context object. When the tasks update that context it is the context for that task only and will not propagate to the other tasks in the flow. If you don’t want to pass the values to all downstream tasks that need it then maybe you should use some external location where you can write/read the data from
s

SImon Hawe

12/09/2020, 4:19 PM
ok, hm lets see
thanks for the help