Andrew Said
08/05/2025, 5:23 PMEXECUTION_ENVIRONMENT
is not being set once the flow is deployed. I see an empty job_variables
object in the deployment configuration in Prefect Cloud.
- name: flow-name
description: Description
entrypoint: "main.py:entrypoint"
path: "/app"
parameters: {}
schedule: {}
work_pool:
name: managed-pool
job_variables:
image: prefecthq/prefect:2-latest
env:
EXECUTION_ENVIRONMENT: 'dev'
Marvin
08/05/2025, 5:23 PMMarvin
08/05/2025, 5:24 PMbash
prefect deploy
This should properly set your environment variables. You can verify the environment variables are set correctly by:
1. Checking the deployment configuration in the UI under the Configuration tab
2. Adding a simple print statement or log in your flow to output the environment variable value
If you're still having issues after making these changes, let me know and I can help troubleshoot further!Andrew Said
08/05/2025, 5:25 PMprefect deploy
but the environment is still empty in the deployment.Marvin
08/05/2025, 5:25 PMMarvin
08/05/2025, 5:26 PMbash
prefect deployment inspect "your-flow-name/deployment-name"
3. Let's also try to set the environment variable explicitly when deploying. Try:
bash
EXECUTION_ENVIRONMENT=dev prefect deploy
4. Another approach would be to modify your flow code to verify the environment variable is accessible. Add this to your flow:
python
from prefect import flow
import os
@flow
def your_flow():
print("Environment variables:", os.environ)
print("EXECUTION_ENVIRONMENT:", os.environ.get("EXECUTION_ENVIRONMENT"))
5. If none of the above work, try creating a new deployment from scratch:
bash
rm prefect.yaml # Remove existing deployment file
prefect deploy --help # Get the latest syntax
Could you try these steps and let me know:
1. What does the deployment inspection show?
2. If you add the environment variable printing to your flow, what does it output?
3. Are you seeing any error messages when running prefect deploy
?
This will help us narrow down where exactly the environment variable setting is failing.