As per the Prefect
Configuration guide I've set a local config file (i.e. in my current working directory) via export PREFECT__USER_CONFIG_PATH="./config.toml"
, however, this requires the environmental variable to be set each shell session.
I tried setting the config in a Python script with prefect.config.user_config_path = "./config.toml"
but this doesn't seem to load the config file in the same way as export
because:
(from docs) "The configuration file is parsed when Prefect is first imported and is available as a live object in prefect.config."
For my dummy config.toml
data:
[api]
host = "localhost"
port = "5432"
url = "https://${api.host}:${api.port}"
prefect.config
via environmental variable:
...'task_runner': {'default_class': 'prefect.engine.task_runner.TaskRunner'}}, 'api': {'host': 'localhost', 'port': 5432, 'url': 'https://localhost:5432'}, 'user_config_path': './config.toml'}>
prefect.config
via script:
...'task_runner': {'default_class': 'prefect.engine.task_runner.TaskRunner'}}, 'user_config_path': './config.toml'}>
So config.toml
variables aren't loaded in second case
Any ideas?
(Application: I want to set a 'Prefect' secret in my local config.toml
file hidden from source control)
Is there a reason you want the config.toml
file in your present working directory? The default location for user config files is ~/.prefect/config.toml
, so if you place your configuration there it will work with no additional setup.
If you do need the configuration file in your present working directory, you might try adding the export
statement to your ~/.bashrc
(or whatever shell equivalent you might need) so that it's always in your environment.