https://prefect.io logo
d

Daniel

09/13/2023, 2:47 PM
Hi all, new to prefect. I would like to load and apply profile / settings from a profile.toml and a logging.yml during runtime that is part of my repo, how would I best go about it / what is best practice? I've not found a viable solution via the docs or community threads. Any help is much appreciated.
r

Ryan Peden

09/13/2023, 7:44 PM
It sounds like the PREFECT_PROFILE_PATH and PREFECT_LOGGING_SETTINGS_PATH settings might be what you want. You could set them as environment variables on a deployment. One thing to watch out for is if you're using a process worker to run deployments. By default, it will create a temporary directory to run your flow, making it difficult to choose a settings directory ahead of time. If it works for your use case, you could set the working directory on the worker to get around this. I know that's not quite setting them at runtime; but using these env vars makes it easy to use different profile and logging config files from one deployment run to the next
🙏 1
If you're using
flow.serve
it might be more difficult. You can use the
temporary_settings
context manager to alter many settings at runtime, but last time I tried, it didn't work with logging settings