Hi, I wonder whether it is possible to set dynamic...
# ask-community
d
Hi, I wonder whether it is possible to set dynamic context / environment variables during flow runs? (This context is only known at run time)
k
Hey @Dan Zhao, how big is it? Maybe you can use the KV Store to store it? There is a 10 KB limit, maybe you can hold it there. Are parameters not a good use for this?
d
it's just some strings and integers - but it's related to the executing environment (e.g. available RAM)
k
Do you have access to it in the Python process? And you want to load them and then add them to context?
d
yes to both questions.
k
Gotcha so not 100% this will work but maybe you can store the Flow as a script, and then at the top, do
Copy code
get_env_vars_somehow()
os.environ = new_env_vars #using the context

import prefect
so that when prefect gets imported and the context gets created, the env vars will exist. does that make sense? kind of a hack though and I think the KV Store might be the cleaner approach