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.FunctionParameters
| Parameter | Type | Description |
|---|---|---|
fn | `Callable | None` |
name | `str | None` |
project | str | Project name that owns the function. |
description | `str | None` |
default_parameters | `dict | None` |
run_type | str | Run 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.Image | dict |
min_instances | `int | None` |
concurrency | `int | None` |
enabled | bool | Whether the function can be run. |
endpoint | `rebase.EndpointConfig | dict |
Constructors
rebase.Function.from_name(project: str, name: str) -> rebase.FunctionMethods
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| Method | Description |
|---|---|
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)| Argument | Description |
|---|---|
items | Iterable of inputs, one call each. Dicts are spread as keyword arguments. Must be non-empty. |
parameter | Name of the parameter to bind non-dict items to. Inferred for single-parameter functions. |
kwargs | Extra keyword arguments shared by every call. |
max_concurrency | Cap on simultaneous calls. |
ordered | Yield results in item order (default) rather than completion order. |
return_exceptions | Yield a RebaseWorkflowError per failed item instead of raising on the first failure. |
timeout | Overall 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.

