Chu
11/20/2025, 8:46 PMrun_deployment?Marvin
11/20/2025, 8:46 PMMarvin
11/20/2025, 8:49 PMPREFECT_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
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)
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
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