Janghoo Lee
03/06/2024, 5:18 AMMarvin
03/06/2024, 5:19 AMPREFECT_API_URL
value in a Python script, you can set it using environment variables, or configure it through the Prefect CLI.
Here is an example of how you might use environment variables in your script to access the `PREFECT_API_URL`:
python
import os
# Access the PREFECT_API_URL environment variable
prefect_api_url = os.getenv('PREFECT_API_URL')
print(prefect_api_url)
In the Prefect documentation, it suggests you can set the value from the command line by using:
shell
prefect config set PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]>"
Replace [ACCOUNT-ID]
and [WORKSPACE-ID]
with your actual account and workspace IDs. Once set, the value will be available as an environment variable that can be accessed from your Python script as shown above.
For more information, you can refer to the Prefect Cloud connection documentation.Nate
03/06/2024, 5:39 AMIn [1]: from prefect.settings import PREFECT_API_URL
In [2]: print(PREFECT_API_URL.value())
<https://api.prefect.cloud/api/accounts/xxx/workspaces/xxx>