:wave: hullo! curious, in prefect 2 is there a way...
# prefect-community
j
👋 hullo! curious, in prefect 2 is there a way to set some flow-level context that are accessible by all sub-flows/tasks?
basically something like:
Copy code
@flow
def my_flow():
    context["my_cool_variable"] = "blah"
    my_subflow()


@flow
def my_subflow():
    print(context["my_cool_variable"])
    my_task()


@task
def my_task():
    print(context["my_cool_variable"])
should have the output
Copy code
[my_subflow] blah
[my_task]    blah
k
What happens if you define it outside tasks and flows? I think it might work
j
I would guess that does, but what if everything isn't colocated? i guess some funny things can happen there
another piece is...execution isn't guaranteed on the same instance right? so that adds some complexity
k
Well yes it might run into problems if things aren’t colocated but I think in general this global variable might be bad practice
j
yeah 😞
we definitely can get around it by just passing things around in the arguments for tasks, but was curious