serve
method.
This method creates a deployment for the flow and starts a long-running process
that monitors for work from the Prefect server.
When work is found, it is executed within its own isolated subprocess.
hello_world.py
- schedules
- event triggers
- metadata such as tags and description
- default parameter values
Schedules are auto-paused on shutdownBy default, stopping the process running
flow.serve
will pause the schedule
for the deployment (if it has one).When running this in environments where restarts are expected use thepause_on_shutdown=False
flag to prevent this behavior:Serve multiple flows at once
Serve multiple flows with the same process using theserve
utility along
with the to_deployment
method of flows:
Retrieve a flow from remote storage
You can retrieve flows from remote storage with theflow.from_source
method.
flow.from_source
accepts a git repository URL and an entrypoint pointing to the
flow to load from the repository:
load_from_url.py
GitRepository
instead of URL:
load_from_storage.py
You can serve loaded flowsYou can serve flows loaded from remote storage with the same
serve
method as local flows:serve_loaded_flow.py