Reference

rebase.Function

SDK handle for a deployable Rebase function.

Signature

class rebase.Function(
    fn: Callable | None = None,
    *,
    name: str | None = None,
    project: str,
    description: str | None = None,
    default_parameters: dict[str, Any] | None = None,
    run_type: str = "quick",
    dependencies: list[str] | tuple[str, ...] | None = None,
    image: rebase.Image | dict | None = None,
    min_instances: int | None = None,
    concurrency: int | None = None,
    enabled: bool = True,
    endpoint: rebase.EndpointConfig | dict | None = None,
)

Most code should create functions with @rebase.function(...) or @project.function(...). Use the class constructor when you need an explicit handle.

Helper

rebase.function(
    fn: Callable | None = None,
    *,
    project: str | None = None,
    name: str | None = None,
    description: str | None = None,
    default_parameters: dict[str, Any] | None = None,
    run_type: str = "quick",
    dependencies: list[str] | tuple[str, ...] | None = None,
    image: rebase.Image | dict | None = None,
    min_instances: int | None = None,
    concurrency: int | None = None,
    enabled: bool = True,
    endpoint: rebase.EndpointConfig | dict | None = None,
) -> Callable[[Callable], rebase.Function] | rebase.Function

Parameters

ParameterTypeDescription
fn`CallableNone`
name`strNone`
projectstrProject name that owns the function.
description`strNone`
default_parameters`dictNone`
run_typestrRun type. Defaults to quick (synchronous, isolated Cloud Run, warm after the first call). Use quick_shared for the shared runner or long for cancellable Cloud Run Jobs execution. Passing the removed backend= argument raises an error with a migration hint.
dependencies`list[str]tuple[str, ...]
image`rebase.Imagedict
min_instances`intNone`
concurrency`intNone`
enabledboolWhether the function can be run.
endpoint`rebase.EndpointConfigdict

Constructors

rebase.Function.from_name(project: str, name: str) -> rebase.Function

Methods

function.deploy(replace: bool = False) -> rebase.Function
function.spawn(**parameters) -> rebase.Run
function.remote(**parameters) -> dict[str, Any]
function.run(**parameters) -> rebase.Run
function.ephemeral_run(**parameters) -> rebase.Run
function.map(items, *, parameter=None, kwargs=None, max_concurrency=None,
             ordered=True, return_exceptions=False, timeout=None) -> Iterator
MethodDescription
from_name(project, name)Resolve a deployed function handle.
deploy()Register or update the immutable function version.
spawn(**parameters)Start a run and return immediately.
remote(**parameters)Start a run and wait for the result.
run(**parameters)Alias for spawn(**parameters).
ephemeral_run(**parameters)Run local source without deploying it persistently.
map(items, ...)Fan one call out over many inputs; yields results as they arrive.

map

Function.map runs the function once per item and yields the results as an iterator. Items that are dicts become the call's keyword arguments; anything else is passed as the single parameter named by parameter= (inferred when the function takes exactly one).

forecast = rb.Function.from_name("energy", "forecast-site")

for result in forecast.map(["site-001", "site-002", "site-003"], max_concurrency=10):
    print(result)
ArgumentDescription
itemsIterable of inputs, one call each. Dicts are spread as keyword arguments. Must be non-empty.
parameterName of the parameter to bind non-dict items to. Inferred for single-parameter functions.
kwargsExtra keyword arguments shared by every call.
max_concurrencyCap on simultaneous calls.
orderedYield results in item order (default) rather than completion order.
return_exceptionsYield a RebaseWorkflowError per failed item instead of raising on the first failure.
timeoutOverall time budget in seconds.

A map issued from inside a workflow step is attributed to that step: the runner injects REBASE_RUN_ID and REBASE_STEP_RUN_ID into the container's environment, and the batch is recorded as that step's tasks, so Client.list_run_tasks(run_id) can answer which item failed and in which step. A map from a laptop belongs to no run, which the platform accepts. Use rebase.current_run() to read the ambient run context yourself, and see Tasks and Artifacts for a complete mapped-task example.

On this page