<@ULVA73B9P> How can I set PREFECT_LOCAL_STORAGE_P...
# marvin-ai
c
@Marvin How can I set PREFECT_LOCAL_STORAGE_PATH when running a Prefect deployment with
run_deployment
?
m
thought for 210.4 seconds
Short answer: set it in the environment of the flow’s execution environment (the worker/infrastructure), not in the caller process. In Prefect 3.x the canonical variable is
PREFECT_RESULTS_LOCAL_STORAGE_PATH
(with
PREFECT_LOCAL_STORAGE_PATH
kept as a backward-compatible alias). Ways to do it: - Per run (via run_deployment): pass it as an environment variable through
job_variables
so the worker sets it for the flow process
Copy code
from prefect.deployments import run_deployment

flow_run = await run_deployment(
    "my-flow/my-deployment",
    job_variables={
        "env": {
            "PREFECT_RESULTS_LOCAL_STORAGE_PATH": "/mnt/prefect-results"
            # "PREFECT_LOCAL_STORAGE_PATH" also works as a legacy alias
        }
    },
)
- For all runs on a worker: set it in the worker’s environment (or in the work pool/deployment infrastructure env)
Copy code
export PREFECT_RESULTS_LOCAL_STORAGE_PATH=/mnt/prefect-results
prefect worker start -p my-pool
- If you are running the flow inline in the same process (not via a worker), you can set it in-process before importing/running Prefect code
Copy code
import os
os.environ["PREFECT_RESULTS_LOCAL_STORAGE_PATH"] = "/mnt/prefect-results"
Note: setting the env var in the process that calls
run_deployment
won’t affect a remote worker on another machine/container. What it controls: this setting determines where Prefect persists results locally inside the flow run environment. If you’re on Prefect 2.x, the pattern is effectively the same: set the env var in the execution environment (worker/infrastructure or per-run overrides). In 3.x, prefer `PREFECT_RESULTS_LOCAL_STORAGE_PATH`;
PREFECT_LOCAL_STORAGE_PATH
remains supported as a compatibility alias. Docs for reference: - Settings overview: Prefect Settings - Results storage concept: Results in Prefect
🙌 1