<@ULVA73B9P> if i have a flow deployment: ```flow...
# marvin-ai
a
@Marvin if i have a flow deployment:
Copy code
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=job_variables,
).apply()
how do i specify a env var to say PYTHONPATH=src/app, like i want to set the paths
m
thought for 189.9 seconds
Great question. In Prefect 3.x you can set environment variables for your deployment via the work pool’s job variables. If your deployment will run on a Process work pool, add an
env
dict to
job_variables
like this:
Copy code
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.