# Chalk Compute Reference: Remote Function
source: https://docs.chalk.ai/compute-docs#section-remote-function

Deploy Python functions as versioned, autoscaling remote functions.

Remote functions turn an ordinary Python callable into a managed service. Chalk packages the function into a container image, deploys it as a ScalingGroup, routes incoming calls over gRPC, and handles replica autoscaling, warm-pool management, batching, and retries. Input and output Arrow schemas are inferred from the function's type hints so callers can invoke it with native Python values and the transport layer stays hidden.

The decorator form, [`function`](https://docs.chalk.ai/compute-docs#function), is the common entrypoint: annotate any callable with `@chalkcompute.function(image=..., cpu=..., memory=...)` and call `.deploy()` to publish a new version. For the imperative API — useful when wrapping functions defined elsewhere or deploying programmatically — construct a [`RemoteFunction`](https://docs.chalk.ai/compute-docs#RemoteFunction) directly.

Use [`RetryPolicy`](https://docs.chalk.ai/compute-docs#RetryPolicy) to configure automatic retries, and catch the [`FunctionError`](https://docs.chalk.ai/compute-docs#FunctionError) / [`FunctionBuildError`](https://docs.chalk.ai/compute-docs#FunctionBuildError) hierarchy for deploy-time and runtime failures.

## `@function(func, image, cpu, compute_class, network_policy, execution_target, memory, gpu, name, env, secrets, volumes, tags, chalk_identity, authenticated, readiness_probe, min_replicas, max_replicas, shutdown_delay_seconds, scaling_interval_seconds, target_cpu_utilization_percentage, target_gpu_utilization_percentage, target_queue_depth, cron_scaling_trigger, scale_from_zero_request_policy, serialization_format, options, max_buffer_duration, max_batching_size, retries, rate_limit, concurrency, queue_policy, schedule, models, tracing, call_timeout)`
source: https://docs.chalk.ai/compute-docs#function

Decorator that deploys a function as a versioned remote function.

Prefer `@cc.function` or `@cc.function(image=...)` without `name=`. The registered name defaults to the Python function's name, including underscores, and can be used with `RemoteFunction.from_name(...)`.

Add optional configuration only for a concrete workload requirement. Ordinary functions, evaluation tasks, and scorers should omit `min_replicas`, `max_replicas`, and `concurrency`: defaults are one replica and no explicit concurrency policy. Multiple evaluation rows do not require overriding them. Document why any tuning override is needed; do not copy unrelated examples' settings or explicitly repeat defaults.

**Locally**, decoration validates the function, starts deployment in a background worker, and returns. The worker:

1. Derives Arrow schemas from the function's type hints
2. Builds a deploy image with a handler shim
3. Registers the function version via `ExternalFunctionCatalogService`
4. If `CHALK_FUNCTION_LOCAL_SDK_COPY=1`, includes local SDK source in the deploy image for unreleased feature iteration.

Deployments of consecutive, distinctly named functions overlap. Remote calls and lifecycle operations wait for their function's deployment before proceeding. A script containing only decorated definitions also waits for all queued deployments before interpreter shutdown.

**Remotely** (inside the container): Lifecycle methods become no-ops. Calling the symbol runs the local Python body in-process; `.remote()` / `.defer()` dispatch to the deployed function (resolved lazily by name), so a function can invoke a sibling without `RemoteFunction.from_name(...)`.

**Parameters**

- `func`: `Callable[..., Any] | None` = `None`
- `image`: `_Image | None` = `None`
  Container image to deploy in. Defaults to `Image.debian_slim()`.
- `cpu`: `str | None` = `None`
  CPU resource request (e.g. `"1"`, `"500m"`).
- `compute_class`: `ComputeClass | None` = `None`
  Where to run replicas. Omit to use the server default; HOST requires fixed, positive replica counts.
- `network_policy`: `NetworkPolicy | None` = `None`
  Optional host egress policy. Omit for the server default; [`NetworkPolicy()`](https://docs.chalk.ai/compute-docs#NetworkPolicy) denies all egress. Kubernetes does not support it.
- `execution_target`: `ExecutionBackend | None` = `None`
  Optional [`ExecutionBackend`](https://docs.chalk.ai/compute-docs#ExecutionBackend); defaults to the environment cluster.
- `memory`: `str | None` = `None`
  Memory resource request (e.g. `"1Gi"`, `"512Mi"`).
- `gpu`: `str | None` = `None`
  GPU resource request (e.g. `"nvidia-l4"`, `"2:nvidia-a100"`). Format is `"<count>:<type>"` or just `"<type>"` for a single GPU.
- `name`: `str | None` = `None`
  Optional registered-name override. Omit this in normal usage to use the function's `__name__`. Set it only when a different registered name is intentional, such as preserving an existing deployment's name after renaming the Python function. For a new task or scorer, choose a descriptive Python name instead of adding a prefix or replacing underscores with hyphens via this option. Changing or removing an override changes the target function; it does not rename an existing deployment.
- `env`: `Mapping[str, str | _Secret] | None` = `None`
  Environment variables as strings or single-value Secret references. The mapping key sets the injected name, overriding aliases and prefixes.
- `secrets`: `list[_Secret] | None` = `None`
  List of `Secret` references to inject.
- `volumes`: `list[tuple[str | Volume, str] | Volume | VolumeMount] | None` = `None`
  List of [`Volume`](https://docs.chalk.ai/compute-docs#Volume) handles, [`VolumeMount`](https://docs.chalk.ai/compute-docs#VolumeMount) specifications, or `(name_or_volume, mount_path)` tuples for persistent storage. Volume handles preserve their selected ref or pinned version.
- `tags`: `dict[str, str] | None` = `None`
- `chalk_identity`: `bool | ChalkIdentity` = `False`
- `authenticated`: `bool` = `False`
- `readiness_probe`: `_ReadinessProbe | None` = `None`
- `min_replicas`: `int` = `1`
  Minimum number of replicas. Defaults to 1; normally omit. Set to 0 only when deliberately choosing scale-to-zero behavior.
- `max_replicas`: `int` = `1`
  Maximum number of replicas. Defaults to 1; normally omit. Increase only when the workload needs additional replica capacity.
- `shutdown_delay_seconds`: `int | None` = `None`
  Graceful termination period in seconds before replicas are forcibly killed during scale-down. Defaults to 30s on the server.
- `scaling_interval_seconds`: `int | None` = `None`
  How often (in seconds) the autoscaler scrapes metrics to make scaling decisions. Defaults to 60s on the server.
- `target_cpu_utilization_percentage`: `int | None` = `None`
  Target CPU utilization percentage (0-100) that drives autoscaling.
- `target_gpu_utilization_percentage`: `int | None` = `None`
  Target GPU utilization percentage (1-100) that drives autoscaling, read from DCGM. Requires `gpu` and `min_replicas >= 1`: the utilization series exists only while replicas do, so this trigger cannot scale a group up from zero.
- `target_queue_depth`: `int | None` = `None`
  Target pending-request queue depth per replica. When set, the autoscaler scales on the function's own queue depth.
- `cron_scaling_trigger`: `_CronScalingTrigger | None` = `None`
  Sets a replica floor during specified cron-defined time windows, independent of the other autoscaling triggers.
- `scale_from_zero_request_policy`: `_ScaleFromZeroRequestPolicy | None` = `None`
- `serialization_format`: `SerializationFormat` = `'pyarrow'`
  Wire format for arguments and results. Currently only `"pyarrow"` is supported.
- `options`: `dict[str, str] | None` = `None`
  Arbitrary key-value options forwarded to the Chalk platform.
- `max_buffer_duration`: `int | None` = `None`
  Maximum time in milliseconds to buffer incoming items before invoking the handler. Defaults to 1000 ms when batching is enabled. When batching is enabled, handler args are lists.
- `max_batching_size`: `int | None` = `None`
  Maximum number of items to accumulate before invoking the handler. Defaults to 10 when batching is enabled.
- `retries`: `int | RetryPolicy | None` = `None`
  Retry policy for handler invocations. An [`int`](https://docs.python.org/3/library/functions.html#int) is the number of retries after the initial execution. Direct calls apply the policy's backoff and jitter client-side; Redis Stream queues apply the count with a fixed reclaim delay. Override per call using `with_options`. Exception filters and shared retry keys are not supported.
- `rate_limit`: `int | RateLimitPolicy | None` = `None`
  Rate limit policy for outbound calls. Pass an [`int`](https://docs.python.org/3/library/functions.html#int) for a simple "N per second" cap with a per-function key, or a `RateLimitPolicy` for full control (`rate`, `per`, `key`). Multiple functions sharing the same `key` share one bucket — used when a downstream service imposes a throughput limit across callers.
- `concurrency`: `int | ConcurrencyPolicy | None` = `None`
  Optional cap on in-flight handler invocations. Defaults to [`None`](https://docs.python.org/3/library/constants.html#None) (no explicit policy); normally omit. It does not enable parallel execution. Set only for a known in-flight limit. Pass an [`int`](https://docs.python.org/3/library/functions.html#int) for a simple `max_concurrent` cap with a per-function key, or a `ConcurrencyPolicy` for full control (`max_concurrent`, `key`). Multiple functions sharing the same `key` share one gate — independent of `rate_limit` (which caps rate, not in-flight count).
- `queue_policy`: `QueuePolicy | None` = `None`
  Queue configuration, including the pending-item cap and asynchronous result retention. Pass a `QueuePolicy` and set `result_ttl_seconds` to retain terminal results for a custom period; the default is one day. Submitting past `max_items` raises a gRPC `RESOURCE_EXHAUSTED` error — clients should back off or call `purge()` on the function to drain the queue if items were erroneously added.
- `schedule`: `str | None` = `None`
  Optional crontab or Chalk duration string for invoking a no-input function on a schedule (e.g. `"0 * * * *"` or `"1h"`).
- `models`: `Mapping[str, Any] | None` = `None`
  Mapping of `model_name -> output_type` for Chalk models that should be auto-bound into the local chalkdf catalog before the function body runs. Each entry becomes a `bind_model` call invoked by the handler shim on import, so `F.catalog_call("model.<name>", ..., output_type=<type>)` resolves without any explicit setup in the function body. For advanced overrides (`version`, `method_name`, `qualified_name`) call `bind_model` directly inside the function.
- `tracing`: `TracingPolicyConfig | None` = `None`
  Server-side remote-function tracing is enabled by default. Use `TracingPolicy` for sampling. Set [`False`](https://docs.python.org/3/library/constants.html#False) to explicitly turn tracing off.
- `call_timeout`: `float | None` = `_DEFAULT_CALL_TIMEOUT`
  Maximum seconds to wait on a single `.remote()`/`.defer()`/ `.poll()` call before raising [`FunctionError`](https://docs.chalk.ai/compute-docs#FunctionError) — including while the scaling group is `Unhealthy` (e.g. replicas stuck in `CrashLoopBackOff`), where the error includes the scaling group's status message. Defaults to 60s. Pass [`None`](https://docs.python.org/3/library/constants.html#None) to disable the deadline and wait indefinitely (previous behavior).

**Examples**

```python
import chalkcompute
@chalkcompute.function
def add(x: int, y: int) -> int:
    return x + y
add.remote(1, 2)   # wire call to the deployed function
add(1, 2)          # runs the Python body in-process
```

## `RemoteFunction`
source: https://docs.chalk.ai/compute-docs#RemoteFunction

Class

A versioned remote function backed by ExternalFunctionCatalogService.

Deploys a Python function as a ScalingGroup and registers it with input/output Arrow schemas derived from the function's type hints.

Most users should prefer the [`function`](https://docs.chalk.ai/compute-docs#function) decorator; use [`RemoteFunction`](https://docs.chalk.ai/compute-docs#RemoteFunction) directly when you need the imperative API (for example, when wrapping a function defined elsewhere, or when constructing deployments programmatically).

**Examples**

Decorator form — the most common entrypoint:

```python
import chalkcompute
from chalkcompute import Image
@chalkcompute.function(
    image=(
        Image.debian_slim()
        .pip_install(["numpy"])
    ),
)
def embed(text: str) -> list[float]:
    import numpy as np
    return np.ones(8).tolist()
embed.remote("hello world")
```

```python
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
```

Imperative form, for constructing a [`RemoteFunction`](https://docs.chalk.ai/compute-docs#RemoteFunction) from an existing callable:

```python
from chalkcompute import RemoteFunction
def square(x: int) -> int:
    return x * x
fn = RemoteFunction(square)
fn.deploy()
fn.remote(7)
```

```python
49
```

```python
fn(7)  # runs the local Python body in-process
```

```python
49
```

**Attributes**

- `version_info`: `FunctionVersionInfo | None`
- `function_id`: `str | None`
- `web_url`: `str | None`

### `RemoteFunction.from_id(version_id, chalk_client, call_timeout)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.from_id

Attach to an existing function version by ID.

This compatibility alias retains the historical version-ID meaning. Prefer `from_version_id` or `from_function_id` in new code.

### `RemoteFunction.from_version_id(version_id, chalk_client, call_timeout)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.from_version_id

Attach through an immutable version ID.

**Parameters**

- `version_id`: `str`
  Identifier of the function version.
- `chalk_client`: `Any | None` = `None`
- `call_timeout`: `float | None` = `_DEFAULT_CALL_TIMEOUT`
  Maximum seconds to wait on a single `.remote()`/`.defer()`/ `.poll()` call before raising. [`None`](https://docs.python.org/3/library/constants.html#None) disables the deadline.

**Returns**

`RemoteFunction`

A handle bound to the existing version.

### `RemoteFunction.from_name(name, chalk_client, call_timeout)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.from_name

Attach to an external function's currently selected version.

**Parameters**

- `name`: `str`
  Name of the function.
- `chalk_client`: `Any | None` = `None`
- `call_timeout`: `float | None` = `_DEFAULT_CALL_TIMEOUT`
  Maximum seconds to wait on a single `.remote()`/`.defer()`/ `.poll()` call before raising. [`None`](https://docs.python.org/3/library/constants.html#None) disables the deadline.

**Returns**

`RemoteFunction`

A handle bound to the existing version.

### `RemoteFunction.from_function_id(function_id, chalk_client, call_timeout)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.from_function_id

Attach to a stable external function by ID.

### `RemoteFunction.deploy(poll_interval, build_timeout, ready_timeout, force_new_version)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.deploy

Ensure the definition is deployed, reusing an unchanged version.

**Parameters**

- `poll_interval`: `float` = `0.5`
  Seconds between status polls.
- `build_timeout`: `float` = `600.0`
  Maximum seconds to wait for the image build.
- `ready_timeout`: `float` = `300.0`
  Maximum seconds to wait for the scaling group to become ready.
- `force_new_version`: `bool` = `False`
  Create a new version even when unchanged, reusing image/source artifacts.

**Returns**

`RemoteFunction`

`self` for chaining.

### `RemoteFunction.wait_ready(timeout, poll_interval)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.wait_ready

Wait until the backing scaling group is ready to serve.

A `min_replicas=0` function counts as ready once it reaches `ScaledToZero`, matching what `deploy` waits for.

**Parameters**

- `timeout`: `float` = `120.0`
  Maximum seconds to wait.
- `poll_interval`: `float` = `2.0`
  Seconds between status polls.

**Returns**

`RemoteFunction`

`self` for chaining.

**Raises**

- `FunctionError`: If the function has not been deployed or never becomes ready.

### `RemoteFunction.with_options(retries)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.with_options

Return an immutable call-scoped handle. None inherits deployed defaults.

Retry counts exclude the initial execution. Direct calls execute retries in the client. Queued execution retries require Redis Stream transport and use the server's retry budget and fixed delay. Handler keyword arguments, including `retries`, remain unchanged.

### `RemoteFunction.with_knowledge_cutoff(knowledge_cutoff)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.with_knowledge_cutoff

Return a call-scoped function handle with an overridden request time.

The returned handle shares this function's deployment and clients but sends `x-chalk-request-timestamp` on subsequent calls and deferred enqueues.

### `RemoteFunction.__call__(args, kwargs)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.__call__

Invoke the underlying Python function locally, in-process.

This runs the original function body in the current process — it does **not** dispatch to the deployed remote function. Use `remote` for a synchronous wire call, or `defer` to enqueue one and get a handle back.

### `RemoteFunction.@remote(args, kwargs)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.remote

Invoke the deployed remote function over the wire.

Bounded by `call_timeout` (set on the constructor / [`@function`](https://docs.chalk.ai/compute-docs#function) decorator / `from_name` — 60s by default): if the scaling group is `Unhealthy` (e.g. replicas stuck in `CrashLoopBackOff`) or otherwise never responds, this raises `TimeoutError` instead of blocking forever, including the scaling group's status message when available.

**Returns**

`Any`

Scalar result for single-row calls, or a list of results otherwise. For generator functions, returns an iterator of result batches.

### `RemoteFunction.defer(args, kwargs)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.defer

Enqueue this function call and return a handle immediately.

Enqueueing itself is bounded by `call_timeout` (see `remote`); the returned handle's own `.get()`/`.stream()` take their own `timeout` for how long to wait on the _result_.

Collecting results only polls this invocation. Failed calls are raised to the caller without enqueueing a replacement invocation.

### `RemoteFunction.poll(call_id, cursor, poll_count, deadline, retry_stale)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.poll

Poll a deferred call once.

`deadline` is the caller's `monotonic` result deadline. It shortens `call_timeout` so a hung poll cannot outlast it, but a poll always gets at least one second. `retry_stale` re-polls once on a fresh client when the connection is stale; callers that retry themselves turn it off.

### `RemoteFunction.purge()`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.purge

Drop pending queued calls for this function.

### `RemoteFunction.versions(limit, include_deleted)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.versions

List immutable versions belonging to this external function.

### `RemoteFunction.rollback(version_id, wait_ready, timeout, poll_interval)`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.rollback

Select an existing immutable version without creating a new one.

### `RemoteFunction.delete()`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.delete

Delete this external function and all of its versions.

### `RemoteFunction.refresh()`
source: https://docs.chalk.ai/compute-docs#RemoteFunction.refresh

Fetch latest function version info from the server.

**Returns**

`FunctionVersionInfo`

Updated version info.

**Raises**

- `FunctionError`: If the function has not been deployed or the RPC fails.

## `DeployedFunction`
source: https://docs.chalk.ai/compute-docs#DeployedFunction

Class (bases: `Protocol`)

Common interface for RemoteFunction and _NoOpFunction.

### `DeployedFunction.__call__(args, kwargs)`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.__call__

### `DeployedFunction.remote(args, kwargs)`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.remote

### `DeployedFunction.defer(args, kwargs)`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.defer

### `DeployedFunction.with_options(retries)`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.with_options

### `DeployedFunction.deploy(poll_interval, build_timeout, ready_timeout, force_new_version)`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.deploy

### `DeployedFunction.wait_ready(timeout, poll_interval)`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.wait_ready

### `DeployedFunction.delete()`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.delete

### `DeployedFunction.refresh()`
source: https://docs.chalk.ai/compute-docs#DeployedFunction.refresh

## `FunctionVersionInfo`
source: https://docs.chalk.ai/compute-docs#FunctionVersionInfo

Class

Metadata about a deployed function version.

**Attributes**

- `id`: `str`
  Unique identifier of the function version.
- `function_name`: `str`
  Registered function name.
- `version`: `int`
  Monotonic version number for this function.
- `scaling_group_name`: `str`
  Name of the scaling group backing this version.
- `function_id`: `str | None`
  Stable identifier of the parent external function.
- `scaling_group_revision_id`: `str | None`
  Immutable scaling-group revision linked to this version.
- `created_at`: `datetime | None`
  Time at which this immutable version was created.
- `is_current`: `bool`
  Whether the parent external function currently serves this version.

## `RetryPolicy`
source: https://docs.chalk.ai/compute-docs#RetryPolicy

Class

Retry configuration for handler invocations.

Construct via the named constructors rather than instantiating directly. With exponential backoff, wait times grow geometrically (`initial`, `initial * multiplier`, `initial * multiplier^2`, ...) capped at `max_wait`. With `linear`, wait times are constant between retries. A plain [`int`](https://docs.python.org/3/library/functions.html#int) passed to `function(retries=3)` is shorthand for `RetryPolicy.exponential(attempts=3)`. By default all [`Exception`](https://docs.python.org/3/library/exceptions.html#Exception) subclasses trigger a retry. Direct `remote()` calls enforce backoff and jitter in the client. Redis Stream queues enforce only `max_retries` with a fixed pending-entry reclaim delay. Legacy Redis List queues ignore the policy. Exception filters and shared retry keys are reserved and rejected when configuring or invoking a function.

**Examples**

```python
RetryPolicy.exponential(attempts=5, initial=1.0, max_wait=30.0)
RetryPolicy.linear(attempts=3, delay=2.0)
```

**Attributes**

- `max_retries`: `int`
  Maximum number of retry attempts (not counting the initial call).
- `initial_wait_seconds`: `float`
  Base wait time in seconds before the first retry.
- `backoff_multiplier`: `float`
  Multiplier applied to wait time on each successive retry. Use `2.0` for exponential backoff (the default) or `1.0` for fixed delay.
- `max_wait_seconds`: `float`
  Upper bound on wait time between retries.
- `jitter`: `bool`
  If true, uniformly sample each wait between zero and its backoff cap.
- `retry_on`: `tuple[type[BaseException], ...]`
  Reserved exception filter. Only the default `(Exception,)` is supported.
- `key`: `str | None`
  Reserved shared-bucket identifier. Only [`None`](https://docs.python.org/3/library/constants.html#None) is supported.

### `RetryPolicy.__post_init__()`
source: https://docs.chalk.ai/compute-docs#RetryPolicy.__post_init__

### `RetryPolicy.validate_execution()`
source: https://docs.chalk.ai/compute-docs#RetryPolicy.validate_execution

Reject policy fields that invocation runtimes cannot enforce.

### `RetryPolicy.from_proto(value)`
source: https://docs.chalk.ai/compute-docs#RetryPolicy.from_proto

Restore deployed defaults, including defaults omitted by older deployments.

### `RetryPolicy.exponential(attempts, initial, multiplier, max_wait, jitter, retry_on, key)`
source: https://docs.chalk.ai/compute-docs#RetryPolicy.exponential

Create a policy with exponential backoff.

**Parameters**

- `attempts`: `int` = `3`
  Maximum number of retry attempts.
- `initial`: `float` = `1.0`
  Base wait time in seconds before the first retry.
- `multiplier`: `float` = `2.0`
  Multiplier applied to wait time on each successive retry.
- `max_wait`: `float` = `60.0`
  Upper bound on wait time between retries.
- `jitter`: `bool` = `True`
  If [`True`](https://docs.python.org/3/library/constants.html#True), add random jitter to wait times.
- `retry_on`: `tuple[type[BaseException], ...]` = `(Exception)`
  Reserved exception filter; only `(Exception,)` is supported.
- `key`: `str | None` = `None`

**Returns**

`RetryPolicy`

A configured [`RetryPolicy`](https://docs.chalk.ai/compute-docs#RetryPolicy).

**Examples**

```python
RetryPolicy.exponential(attempts=5, initial=0.5, max_wait=30.0)
```

### `RetryPolicy.linear(attempts, delay, jitter, retry_on, key)`
source: https://docs.chalk.ai/compute-docs#RetryPolicy.linear

Create a policy with fixed delay between retries.

**Parameters**

- `attempts`: `int` = `3`
  Maximum number of retry attempts.
- `delay`: `float` = `1.0`
  Fixed wait time in seconds between retries.
- `jitter`: `bool` = `False`
  If [`True`](https://docs.python.org/3/library/constants.html#True), add random jitter to wait times.
- `retry_on`: `tuple[type[BaseException], ...]` = `(Exception)`
  Reserved exception filter; only `(Exception,)` is supported.
- `key`: `str | None` = `None`

**Returns**

`RetryPolicy`

A configured [`RetryPolicy`](https://docs.chalk.ai/compute-docs#RetryPolicy).

**Examples**

```python
RetryPolicy.linear(attempts=3, delay=2.0)
```

## `FunctionError`
source: https://docs.chalk.ai/compute-docs#FunctionError

Exception (bases: `Exception`)

Base exception for Function errors.

## `FunctionBuildError`
source: https://docs.chalk.ai/compute-docs#FunctionBuildError

Class (bases: `FunctionError`)

Raised when the function image build fails.
