David Beck10/19/2022, 9:39 PM
Ryan Peden10/19/2022, 10:04 PM
David Beck10/19/2022, 10:16 PM
import prefect.settings prefect.settings.PREFECT_API_KEY = "<https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]>"
Ryan Peden10/19/2022, 10:34 PM
import os import prefect import prefect.settings os.environ["PREFECT_API_KEY"] = "abc" print(prefect.settings.PREFECT_API_KEY.value())
because prefect was loaded before the environment variable was set. However, if you run:
import os os.environ["PREFECT_API_KEY"] = "abc" import prefect.settings print(prefect.settings.PREFECT_API_KEY.value())
because the environment variable was set before Prefect loaded. Another option would be to have your CI/CD tooling set the environment variables before you run your Python script. Most CI/CD tools I've worked with make that easy, but I know some make it more difficult than others.
David Beck10/20/2022, 3:10 PM