<@ULVA73B9P> I have flows deployed on several mach...
# ask-marvin
t
@Marvin I have flows deployed on several machine and would like to customise the result storage paths which may differ base on the machine. I see that there is a PREFECT_LOCAL_STORAGE_PATH environment variable. The docs says you should use prefect config set to modify it. Is this intended to be done on the prefect server environment? How can I just have the variable defined in the environment where the flow is deployed for it to be honoured?
m
thought for 248.9 seconds
Great question. Short answer: set it on the machines that execute your flow runs, not on the Prefect server. Details: - In Prefect 3.x, the local results path is read by the process that runs the flow (i.e., the worker and the flow-run environment it spawns), not by the API/Server. - You can configure it via either of these environment variables (both are supported): -
PREFECT_RESULTS_LOCAL_STORAGE_PATH
(preferred/explicit) -
PREFECT_LOCAL_STORAGE_PATH
(legacy alias) - You can also persist it in the active profile with: -
prefect config set results.local_storage_path=/path/on/this/machine
- or
prefect config set PREFECT_RESULTS_LOCAL_STORAGE_PATH=/path/on/this/machine
- Precedence: environment variables > profile config. Set it where the flow code actually runs. Common ways to apply per-machine paths: - Process worker (runs flows on the same host) - Shell/systemd:
Copy code
export PREFECT_RESULTS_LOCAL_STORAGE_PATH=/var/prefect/results
    prefect worker start -p my-process-pool
- Or persist it on that host:
Copy code
prefect config set results.local_storage_path=/var/prefect/results
- Docker/Kubernetes workers (flows run in new containers/pods) - Put the env var into the job template or deployment job_variables so it’s present in the flow-run container/pod, for example in your prefect.yaml:
Copy code
deployments:
    - name: my-deploy
      entrypoint: flows/my_flow.py:my_flow
      work_pool:
        name: my-docker-pool
        type: docker
        job_variables:
          env:
            PREFECT_RESULTS_LOCAL_STORAGE_PATH: /data/prefect/results
- For Kubernetes, add it to the base job template or job_variables env so each created pod sees it. Notes: - Setting this on the Prefect Server (or Prefect Cloud) won’t affect where results are written; only the execution environment matters. - If you want one consistent location across all machines, consider shared storage (NFS/SMB) or a remote storage block (e.g., S3/GCS) as your default result storage. Otherwise, per-machine env vars are the simplest way to diverge paths. Docs for reference: - Results (3.x) - Settings and profiles - Settings reference
1