> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# process

# `prefect.workers.process`

Module containing the Process worker used for executing flow runs as subprocesses.

To start a Process worker, run the following command:

```bash theme={null}
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](https://www.prefect.io/docs/v3/concepts/work-pools/).

## Classes

### `ProcessJobConfiguration` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L60](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L60)</sup>

**Methods:**

#### `from_template_and_values` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L209](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L209)</sup>

```python theme={null}
from_template_and_values(cls, base_job_template: dict[str, Any], values: dict[str, Any], client: 'PrefectClient | None' = None)
```

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.

#### `is_using_a_runner` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L179](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L179)</sup>

```python theme={null}
is_using_a_runner(self) -> bool
```

#### `json_template` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L337](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L337)</sup>

```python theme={null}
json_template(cls) -> dict[str, Any]
```

Returns a dict with job configuration as keys and the corresponding templates as values

Defaults to using the job configuration parameter name as the template variable name.

e.g.

```python theme={null}
{
    key1: '{{ key1 }}',     # default variable template
    key2: '{{ template2 }}', # `template2` specifically provide as template
}
```

#### `prepare_for_flow_run` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L73](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L73)</sup>

```python theme={null}
prepare_for_flow_run(self, flow_run: 'FlowRun', deployment: 'DeploymentResponse | None' = None, flow: 'APIFlow | None' = None, work_pool: 'WorkPool | None' = None, worker_name: str | None = None, worker_id: 'UUID | None' = None) -> None
```

#### `prepare_for_flow_run` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L361](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L361)</sup>

```python theme={null}
prepare_for_flow_run(self, flow_run: 'FlowRun', deployment: 'DeploymentResponse | None' = None, flow: 'APIFlow | None' = None, work_pool: 'WorkPool | None' = None, worker_name: str | None = None, worker_id: 'UUID | None' = None) -> None
```

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.

#### `resolve_for_flow_run` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L278](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L278)</sup>

```python theme={null}
resolve_for_flow_run(cls, flow_run: 'FlowRun') -> Self
```

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`.

#### `validate_working_dir` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L68](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L68)</sup>

```python theme={null}
validate_working_dir(cls, v: Path | str | None) -> Path | None
```

### `ProcessVariables` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L111](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L111)</sup>

**Methods:**

#### `model_json_schema` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L586](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/base.py#L586)</sup>

```python theme={null}
model_json_schema(cls, by_alias: bool = True, ref_template: str = '#/definitions/{model}', schema_generator: Type[GenerateJsonSchema] = GenerateJsonSchema, mode: Literal['validation', 'serialization'] = 'validation') -> dict[str, Any]
```

TODO: stop overriding this method - use GenerateSchema in ConfigDict instead?

### `ProcessWorkerResult` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L130](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L130)</sup>

Contains information about the final state of a completed process

### `ProcessWorker` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L134](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L134)</sup>

**Methods:**

#### `run` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L149](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/workers/process.py#L149)</sup>

```python theme={null}
run(self, flow_run: 'FlowRun', configuration: ProcessJobConfiguration, task_status: Optional[anyio.abc.TaskStatus[int]] = None) -> ProcessWorkerResult
```
