hi team, wondering if we could override/enrich the prefect context? i.e. I would like to have a task that does
Copy code
from prefect import context as prefect_context, task
@task
def enrich_context():
prefect_context["custom_key"] = 1
@task
def main_task():
value = prefect_context["custom_key"]
print(value)
with Flow("test-enrich_context") as flow:
_enrich_context_task = enrich_context()
main_task(upstream_tasks=[_enrich_context_task])
k
Kevin Kho
08/10/2021, 7:15 AM
Hey @haven, you can’t do this and have it carry to downstream tasks. I suggest you use the KV Store to persist small pieces of info. Have you seen the docs ?
h
haven
08/10/2021, 7:17 AM
ah I see. unfortunately the key-value pair that I'm trying to persist is a Python object. I'd probably try to build a local context then. Thanks!
k
Kevin Kho
08/10/2021, 7:18 AM
You can persist it and keep track of the location with the store maybe
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.