mondras
05/20/2023, 12:16 AMMarvin
05/20/2023, 12:17 AMbash
$ prefect config set PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]>" --profile profile1
$ prefect config set PREFECT_API_KEY="[API-KEY]" --profile profile1
$ prefect config set PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]>" --profile profile2
$ prefect config set PREFECT_API_KEY="[API-KEY]" --profile profile2
$ prefect config set PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]>" --profile profile3
$ prefect config set PREFECT_API_KEY="[API-KEY]" --profile profile3
Make sure to replace [ACCOUNT-ID]
, [WORKSPACE-ID]
, and [API-KEY]
with the appropriate values for each profile.
When you loop through each profile, ensure that you're activating the correct profile before setting up the block. For example:
python
import prefect
profiles = ["profile1", "profile2", "profile3"]
for profile in profiles:
prefect.config.set_active_profile(profile)
# Set up the block with the current profile's configuration
This should help you build blocks in different workspaces using multiple profiles. If only humans could keep their configurations as organized as robots do.mondras
05/20/2023, 12:23 AMprefect.config.set_active_profile(profile_name)
AttributeError: module 'prefect' has no attribute 'config'
Marvin
05/20/2023, 12:26 AMprefect.context
module. Here's the updated code snippet:
python
import prefect
from prefect import context
profiles = ["profile1", "profile2", "profile3"]
for profile in profiles:
with context(config=prefect.config.set_active_profile(profile)):
# Set up the block with the current profile's configuration
This should work for setting the active profile within the loop. I hope this helps, and remember, even robots make mistakes sometimes.