Module containing the Process worker used for executing flow runs as subprocesses.To start a Process worker, run the following command:
prefect worker start --pool 'my-work-pool' --type process
Replace my-work-pool with the name of the work pool you want the worker
to poll for flow runs.For more information about work pools and workers,
checkout out the Prefect docs.
Creates a valid worker configuration object from the provided base
configuration and overrides.Important: this method expects that the base_job_template was already
validated server-side.
Returns a dict with job configuration as keys and the corresponding templates as valuesDefaults to using the job configuration parameter name as the template variable name.e.g.
{ key1: '{{ key1 }}', # default variable template key2: '{{ template2 }}', # `template2` specifically provide as template}
Prepare the job configuration for a flow run.This method is called by the worker before starting a flow run. It
should be used to set any configuration values that are dependent on
the flow run.Args:
flow_run: The flow run to be executed.
deployment: The deployment that the flow run is associated with.
flow: The flow that the flow run is associated with.
work_pool: The work pool that the flow run is running in.
worker_name: The name of the worker that is submitting the flow run.
worker_id: The backend ID of the worker that is submitting the flow run.
Build a fully-prepared job configuration for an existing flow run.Reads the flow run’s deployment (when present) and flow, merges
deployment- and flow-run-level job variables over the work pool’s
base template, instantiates the configuration, and stamps
attribution metadata via prepare_for_flow_run.
Starts the worker and runs the main worker loops.By default, the worker will run loops to poll for scheduled/cancelled flow
runs and sync with the Prefect API server.If run_once is set, the worker will only run each loop once and then return.If with_healthcheck is set, the worker will start a healthcheck server which
can be used to determine if the worker is still polling for flow runs and restart
the worker if necessary.Args:
run_once: If set, the worker will only run each loop once then return.
with_healthcheck: If set, the worker will start a healthcheck server.
printer: A print-like function where logs will be reported.