Luke Dolan
06/28/2023, 10:11 AMimport os
from prefect.deployments import Deployment
from prefect.filesystems import LocalFileSystem
os.environ['PREFECT_API_URL'] = f'http://<remote_host>:4200/api'
local_file_system_block = LocalFileSystem.load('local-system')
deployment = Deployment.build_from_flow(...)
deployment.apply
However find that it doesn't seem to utilise the environ variable and instead hits the ephemeral-prefect host rather than the <remote_host> is this expected?
setting this by prefect config set PREFECT_API_URL=http://<remote_host>:4200/api
works howeverNico Neumann
06/28/2023, 10:18 AMimport os
os.environ['PREFECT_API_URL'] = f'http://<remote_host>:4200/api'
from prefect.deployments import Deployment
from prefect.filesystems import LocalFileSystem
...
Luke Dolan
06/28/2023, 10:33 AMLuke Dolan
07/05/2023, 9:16 PMThe SettingsContext is set when the prefect module is imported. This context is referred to as the "root" settings context for clarity. Generally, this is the only settings context that will be used. When this context is entered, we will instantiate a Settings object, loading settings from environment variables and defaults, then we will load the active profile and use it to override settings.
So the settings are loaded on importLuke Dolan
07/05/2023, 9:16 PMAnother SettingsContext may be entered at any time to change the settings being used by the code within the context. Generally, users should not use this. Settings management should be left to Prefect application internals.
Luke Dolan
07/05/2023, 9:35 PMwith prefect.settings.temporary_settings(updates={prefect.settings.PREFECT_API_URL: '<http://xxx.xxx.com:4200/api'}>):
local_file_system_block = LocalFileSystem.load('local-system')
deployment = Deployment.build_from_flow(...)
deployment.apply
And this was the docs from the API that made it clear
>>> from prefect.settings import PREFECT_API_URL
>>>
>>> with temporary_settings(updates={PREFECT_API_URL: "foo"}):
>>> assert PREFECT_API_URL.value() == "foo"
Nico Neumann
07/05/2023, 11:39 PM