Jenia Varavva
08/01/2022, 1:16 AMSettings
values? E.g. I want to set PREFECT_API_URL
from inside the python script?Khuyen Tran
08/01/2022, 1:19 AMPREFECT_API_URL
from the command line. You could try to use os.system
to run the command in your Python scriptJenia Varavva
08/01/2022, 1:32 AMimport os
from prefect.settings import PREFECT_API_URL, get_default_settings, Settings
os.system("prefect config set PREFECT_API_URL=<http://prefect-orion.prefect/api>")
print(PREFECT_API_URL.value())
print(get_default_settings().PREFECT_API_URL)
print(Settings().PREFECT_API_URL)
I’m seeing:
None
None
None
If I add os.environ["PREFECT_API_URL"] = "foo"
the last line switches to the desired value, but when I run a flow
it seems to still use the local/sqlite APIJenia Varavva
08/01/2022, 1:42 AMcontext.use_profile
is almost what I wanted:
import prefect.context
from prefect.settings import Profile
p = Profile(
name="default",
settings={
"PREFECT_API_URL": "<http://prefect-orion.prefect/api>"
},
)
with prefect.context.use_profile(p):
run_my_flow()
Now I just need a way to install this profile as the default..Khuyen Tran
08/01/2022, 1:45 AMfrom prefect.settings import update_current_profile
from prefect.settings import PREFECT_API_URL
update_current_profile(settings={PREFECT_API_URL: "foo"})
assert PREFECT_API_URL.value() == "foo"
Jenia Varavva
08/01/2022, 1:47 AMJenia Varavva
08/01/2022, 1:47 AMvalue()
is None
Jenia Varavva
08/01/2022, 1:48 AMwith prefect.context.use_profile(p):
print(PREFECT_API_URL.value())
shows the expected valueKhuyen Tran
08/01/2022, 1:49 AMKhuyen Tran
08/01/2022, 1:49 AMJenia Varavva
08/01/2022, 1:50 AMJenia Varavva
08/01/2022, 1:51 AMKhuyen Tran
08/02/2022, 3:14 PMJenia Varavva
08/02/2022, 4:17 PM