Hi, Can someone explain me how from we read config...
# prefect-community
Hi, Can someone explain me how from we read configuration in prefect 2 from config.toml file earlier we were using
from prefect import config
what do we use in prefect 2 ?
Hi Hamza, I'm not sure if this is exactly what you're looking for, but I've found it useful to look at the cli code in some cases. For example in
you'll see:
Copy code
context = prefect.context.get_settings_context()

    # Get settings at each level, converted to a flat dictionary for easy comparison
    default_settings = prefect.settings.get_default_settings()
    env_settings = prefect.settings.get_settings_from_env()
    current_profile_settings = context.settings
@Mark NS, i am specifically looking how i can read configuration from toml file in prefect 2, not sure if this allow us to do that but i can check and see if it works for me.
Well if you really only want to read the toml file, there is the direct approach: https://docs.python.org/3/library/tomllib.html
Hi! What are you trying to do more specifically?
Prefect 2 has profiles so the config is a little more complex
https://docs.prefect.io/api-ref/prefect/settings/#prefect.settings has a description explaining the implementation of settings
@Zanie, this means that toml files are depreciated in prefect2 ?
My prefect .toml file looks like this
Copy code
remote_path = "some_path"
host = "my_host"
port = 89
earliest_date = "2015-06-01"
Now i am upgrading to prefect2 how can i use this configuration in prefect2 This how I am reading them currently
Copy code
from prefect import config

#read config
The Prefect config cannot be used for storing arbitrary data, it’s for Prefect settings only. You can read a toml file as described by Mark above?