Hey guys, is it "prefect legal" to inject context ...
# prefect-community
k
Hey guys, is it "prefect legal" to inject context into
prefect.context
at runtime? More concretely, can I do something like this:
Copy code
with Flow('test') as flow:
    do_stuff()

with prefect.context(foo='bar'):
    flow.run()
and if not what would be the correct way to inject context after defining a flow?
n
Hi @kevin - that's perfectly valid! The docs have some advanced use cases of that exactly.
k
oh that's great, as a corollary if I'm assuming it would be valid to do something like this:
Copy code
with Flow('test') as flow:
    do_stuff()
def stuff_wrapper(foobar):
    with prefect.context(foo=foobar):
        flow.run()
and call
stuff_wrapper
but I want to make sure.
n
I imagine that would work just fine 👍
k
thanks! appreciate the quick response