Dan Morris
12/09/2025, 2:54 PMMarvin
12/09/2025, 2:54 PMMarvin
12/09/2025, 2:59 PMflow.serve() or prefect flow serve ./file.py:my_flow does not hot‑reload your local code. Any changes to the Python file won’t be picked up until you restart the serving process.
However, there is one workflow that does pick up changes without a restart: if you serve a flow from remote source code (e.g., Git) using Flow.from_source(...). In that case, the runner polls the remote storage and pulls updated code between runs; subsequent runs will use the new code without restarting the serving process. This only affects future runs; any run that is already in progress continues with the code it started with.
Key points:
- Local entrypoints (file on disk): no auto-reload; restart required.
- From remote source via `from_source(...)`: code is re-pulled on an interval; updates are honored for subsequent runs without a restart.
- There is no `--reload`/`--watch` flag for prefect flow serve.
Example of serving from a Git repo so changes are picked up between runs:
from prefect import flow
@flow
def my_flow():
...
if __name__ == "__main__":
my_flow = my_flow.from_source(
source="<https://github.com/org/repo>",
entrypoint="flows/my_flow.py:my_flow",
# optional: configure branch, access token via env, etc.
)
my_flow.serve(
name="my-deployment",
# optional schedule args...
)
Caveats:
- Only future runs use the updated code; there is no live in-process reload.
- Be cautious with breaking changes (e.g., parameter schema/signature): older scheduled runs may fail if the deployment’s expectations change.
Docs and references:
- How to run flows in local processes: Run flows in local processes
- Serving flows in Docker: Serve flows in Docker
- CLI reference (prefect flow serve options): prefect flow CLI
If you’re serving from a Podman container with a local file, you’ll need to restart that container to pick up changes (or use a Git source via from_source so the runner pulls updates). Want help switching your current serve setup to use a Git source so changes are picked up between runs?