<@ULVA73B9P> Prefect v3.5 - I believe we are able ...
# ask-marvin
d
@Marvin Prefect v3.5 - I believe we are able to make non-breaking changes to a flow in a script that is being served, and the changes would be honoured without requiring a restart of the process that's serving the flow, is this correct?
m
thought for 307.0 seconds
Short answer: not for a local script. In Prefect 3.5, a process started with either
flow.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:
Copy code
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?