Hello, I have a question about `prefect context` ....
# ask-community
h
Hello, I have a question about
prefect context
. It seems a powerful way to share common variables and objects among tasks. Is it possible to add new objects or variables inside the flow definition which then to be used by the tasks later? https://docs.prefect.io/core/concepts/execution.html#modifying-context-at-runtime such as
Copy code
with Flow('Flow with new context') as flow:
    # Could we add new objects to prefect.context here?

    task_1_use_new_context_object()
d
Hi @Hui Zheng! As long as you pass things into context before the flow run starts, we totally agree! We definitely suggest staying away from modifying context at runtime
👍 1
h
Hi Dylan, I just realized that the the context is not accessible at the scope of flow definition, it’s only accessible within tasks
d
You can pass additional objects to context at the beginning of a flow run, however
Check out the “Run” page in the UI for a flow