Function Execution
Choose the mode and isolation for SDK-callable Rebase Functions.
Rebase Functions are private Python callables invoked through the SDK. They default to mode="interactive", isolation="shared", the lowest-latency shared Cloud Run runner path.
For the full overview across functions, models, and workflows, see Execution Modes.
import rebase as rb
project = rb.project("energy-tools")
@project.function(name="add")
def add(a: int = 0, b: int = 0) -> dict:
return {"sum": a + b}
project.deploy()
result = add.remote(a=40, b=2)
print(result)Execution options
| Mode and isolation | Use it when |
|---|---|
interactive/shared | Default. You want the fastest development loop and lowest first-call latency for mutually trusted code. |
interactive/dedicated | You want synchronous calls on a private per-function Cloud Run service. The service stays warm after the first call. |
job | The run may take a long time or must be cancellable. Each run gets a Cloud Run Job execution. |
Set the mode and isolation on the decorator:
@project.function(name="add-shared") # defaults to interactive/shared
def add_shared(a: int = 0, b: int = 0) -> dict:
return {"sum": a + b}
@project.function(name="add-dedicated", isolation="dedicated")
def add_dedicated(a: int = 0, b: int = 0) -> dict:
return {"sum": a + b}
@project.function(name="add-job", mode="job")
def add_job(a: int = 0, b: int = 0) -> dict:
return {"sum": a + b}
@project.function(name="add-dedicated-warm", isolation="dedicated", min_instances=1, concurrency=1)
def add_dedicated_warm(a: int = 0, b: int = 0) -> dict:
return {"sum": a + b}The deprecated run_type values remain accepted: quick_shared maps to interactive/shared, quick maps to interactive/dedicated, and long maps to job. See Execution Modes.
Infrastructure mapping
Rebase resolves the public settings to concrete Cloud Run infrastructure. Run records report the resolved value in the internal execution_backend field.
| Mode and isolation | Internal execution path |
|---|---|
interactive/shared | Shared Cloud Run runner (cloud_run_shared). |
interactive/dedicated | Private Cloud Run service (cloud_run) with one tagged revision per immutable version. |
job | Cloud Run Jobs (cloud_run_jobs), one execution per run. |
Dedicated interactive execution
mode="interactive", isolation="dedicated" creates a private Cloud Run service for the function. Each immutable version becomes a tagged Cloud Run revision under that service. Rebase stores the version tag URL and invokes it for exact-version execution.
On first deploy, Rebase creates the Cloud Run service. On later deploys of the same function, Rebase updates the service template to create a new tagged revision and preserves tags for older versions. Deploy waits for the revision to become ready, then verifies private invocation by calling the tagged revision health endpoint with a Google-signed identity token before treating deploy as complete.
Use concurrency=1 when you do not want two user calls executing inside the same Cloud Run instance:
@project.function(
name="single-tenant-transform",
isolation="dedicated",
min_instances=1,
concurrency=1,
)
def transform(value: float = 0) -> dict:
return {"value": value * 2}min_instances=1 keeps the function warm, which reduces cold-start risk but creates steady Cloud Run cost. Warm instances are a per-workspace grant set by Rebase, and the default grant is 0: a deploy with min_instances above the workspace's grant fails with 409. Workspaces also cap concurrency, timeout, CPU, memory, and maximum Cloud Run instances to keep usage inside the monthly credit grant. Contact Rebase to raise the warm-instance grant.
Interactive runs execute synchronously, so they cannot be cancelled once started. Use mode="job" when you need cancellable runs.
Private isolated Cloud Run invocation uses two layers:
| Layer | Mechanism |
|---|---|
| Cloud Run service auth | The Rebase API service account receives roles/run.invoker and sends a Google identity token when invoking the service. |
| Runner request auth | The function runner also checks the Rebase runner token in X-Rebase-Runner-Token. |
Shared interactive execution
The default mode="interactive", isolation="shared" runs the function on an already-running Cloud Run runner. There is no per-function service deploy, so registration and the first call are very fast. Multiple functions share the runner process, environment machinery, import path, caches, API identity, and failure domain; use this path only for mutually trusted code. Runs execute synchronously and cannot be cancelled, and rebase run logs does not support this path yet.
Job execution
mode="job" creates or updates a Cloud Run Job for the exact function version and starts one execution per run. This is the right choice for batch work, backfills, and long model executions where isolation matters more than startup latency. Job runs are cancellable.
Dependencies
Add public PyPI dependencies with dependencies=[...]. Rebase records them in the function version fingerprint and installs them with uv pip install in the runner cache:
@project.function(name="flatten-and-add", dependencies=["boltons==24.0.0"])
def flatten_and_add(a: int = 0, b: int = 0) -> dict:
from boltons.iterutils import flatten
values = list(flatten([[a], [b]]))
return {"sum": sum(values)}Use rb.Image when you want the dependency spec to be explicit:
image = rb.Image.python("3.13").uv_pip_install("boltons==24.0.0")
@project.function(name="image-backed-add", image=image)
def image_backed_add(a: int = 0, b: int = 0) -> dict:
from boltons.iterutils import flatten
return {"sum": sum(flatten([[a], [b]]))}Pin exact versions for reproducible function versions.
Images also support uv_sync(...), add_local_file(...), add_local_dir(...), and add_local_python_source(...). An image that uses any of these is built into a container image at deploy time, so it requires isolation="dedicated" or mode="job"; the shared runner refuses it.
GPUs are not supported in the toolkit. Unknown image spec fields such as gpu, cuda, or accelerator are rejected.
Pausing
Stop a whole project or a single function without deleting it:
rebase project pause energy-forecasting
rebase function pause forecast --project energy-forecasting
rebase function resume forecast --project energy-forecastingWhile paused, runs, map calls, and endpoint calls are refused with 409, and a paused project skips its scheduled fires. A later deploy does not lift the pause; resume does.
Latency Shape
As a rough guide for a trivial a + b function:
| Execution | Deploy cost | First call | Warm calls |
|---|---|---|---|
interactive/shared | None beyond registration. | ~0.1 s without extra dependencies; dependency installs add roughly a second on first use. | ~0.08 s. |
interactive/dedicated | Several seconds to provision the private service/revision at deploy time. | ~0.1–0.8 s depending on dependencies. | Low hundreds of milliseconds. |
job | Job created or updated at deploy time. | Cloud Run Job startup dominates — expect seconds per run. | Same as first call; each run is fresh. |
Read these numbers as a shape, not a product guarantee. Dedicated interactive execution pays provisioning once at deploy, shared interactive skips it entirely, and jobs pay startup on every run.

