Amith M
09/17/2025, 10:37 AMflow.from_source(
source=source,
entrypoint="src/app/workflows/prefect_flows/mdm_mcp_ingestion_flow.py:mdm_mcp_ingestion_flow",
).to_deployment(
name="mdm_mcp_ingestion_flow",
description="Ingest MDM and MCP data into the database",
tags=["etl", "mdm", "mcp", "ingestion"],
version=version,
work_pool_name=work_pool_name,
job_variables=job_variables,
).apply()
how do i specify a env var to say PYTHONPATH=src/app, like i want to set the pathsMarvin
09/17/2025, 10:38 AMMarvin
09/17/2025, 10:41 AMenv
dict to job_variables
like this:
flow.from_source(
source=source,
entrypoint="src/app/workflows/prefect_flows/mdm_mcp_ingestion_flow.py:mdm_mcp_ingestion_flow",
).to_deployment(
name="mdm_mcp_ingestion_flow",
description="Ingest MDM and MCP data into the database",
tags=["etl", "mdm", "mcp", "ingestion"],
version=version,
work_pool_name=work_pool_name,
job_variables={
"env": {
"PYTHONPATH": "src/app"
},
# optional: ensure the relative path resolves the way you expect
# "working_dir": "/absolute/path/to/your/project"
},
).apply()
Notes:
- For the Process worker, job_variables.env
maps to ProcessVariables.env
, which is exactly for environment variables.
- If you use a relative PYTHONPATH
like src/app
, it’s resolved relative to the process working directory. Either set an absolute path or also set working_dir
in job_variables
so it resolves correctly.
- Alternative options:
- Set env vars at the work pool level using a base job template so all deployments inherit them.
- Export PYTHONPATH
in the environment where you start the worker (e.g., export PYTHONPATH=src/app && prefect worker start ...
).
Docs for more detail:
- Customize job variables
- Process worker variables
Quick check: which work pool type are you using (Process, Docker, Kubernetes)? The exact job_variables
schema differs per pool, but they all support an env
section.