Skip to content

Runtime

Controls lifecycle, commands, files, networking, and secrets for one runtime.

Sync · Async counterpart: AsyncRuntime

class Runtime:

This type is created by the SDK; do not construct it directly.

runtime = client.runtimes.create(...)
runtime = client.runtimes.get(...)
Name Type or value Description
cached_info RuntimeInfo Return the most recently fetched runtime metadata.
egress EgressManager Return the egress policy manager for this runtime.
secrets RuntimeSecretManager Return the secret-stub manager for this runtime.
files FileManager Return the file manager for this runtime.
checkpoints RuntimeCheckpointManager Return the checkpoint manager for this runtime.
id str Return the runtime UUID.
name str Return the runtime display name.
heartbeat status Alias for status().

Refresh and return runtime metadata from the API.

def refresh_info() -> RuntimeInfo
  • RuntimeInfo

Boot the runtime and optionally wait until it is ready.

def boot(*, wait: bool = True, timeout: float = 240.0, poll_interval: float = 0.5) -> None
Name Type Default Description
wait bool True Wait for the operation to reach its target state.
timeout float 240.0 Maximum operation time in seconds.
poll_interval float 0.5 Seconds between status checks.

Wait until the runtime reaches the running state.

def wait_until_ready(*, timeout: float = 240.0, poll_interval: float = 0.5) -> RuntimeInfo
Name Type Default Description
timeout float 240.0 Maximum operation time in seconds.
poll_interval float 0.5 Seconds between status checks.
  • RuntimeInfo

Pause the runtime.

def pause() -> None

Resume the runtime and optionally wait until it is ready.

def resume(*, wait: bool = True, timeout: float = 240.0, poll_interval: float = 0.5) -> None
Name Type Default Description
wait bool True Wait for the operation to reach its target state.
timeout float 240.0 Maximum operation time in seconds.
poll_interval float 0.5 Seconds between status checks.

Shut down the runtime.

def shutdown() -> None

Delete the runtime.

def delete() -> None

Update the runtime resource configuration.

def update_resources(resources: PatchRuntimeResources | Mapping[str, object]) -> RuntimeInfo
Name Type Default Description
resources PatchRuntimeResources | Mapping[str, object] Structured resource requests and limits.
  • RuntimeInfo

Change the runtime memory limit in MiB.

def resize_memory(new_memory_mib: int) -> RuntimeInfo
Name Type Default Description
new_memory_mib int New runtime memory limit in MiB.
  • RuntimeInfo

Fetch the current runtime lifecycle status.

def status() -> RuntimeStatus
  • RuntimeStatus

Run a command and return its buffered output.

def exec(command: str | Sequence[str], timeout: float | None = None, env: Mapping[str, str] | None = None, stdin: bytes | str | None = None, cwd: str | None = None, max_output_bytes: int | None = None) -> CommandResult
Name Type Default Description
command str | Sequence[str] Shell command or argument sequence to execute.
timeout float | None None Optional execution timeout in seconds.
env Mapping[str, str] | None None Environment variables added to the command.
stdin bytes | str | None None Bytes or text written to standard input.
cwd str | None None Working directory used for the command.
max_output_bytes int | None None Maximum buffered output size.
  • CommandResult — The command exit code and buffered standard output and error.
  • ApiError — If command execution cannot be started or completed.
>>> result = runtime.exec("python --version")
>>> print(result.stdout_text)
Python 3.12.0

Run a command in a background worker and return a future.

def exec_detached(command: str | Sequence[str], **kwargs: Any) -> Future
Name Type Default Description
command str | Sequence[str] Shell command or argument sequence to execute.
kwargs Any {} Additional keyword options forwarded to the operation.
  • Future

Create a runtime from one of this runtime’s checkpoints.

def restore(checkpoint_id: str, *, name: str | None = None, **options: Any) -> Runtime
Name Type Default Description
checkpoint_id str Checkpoint UUID used by the operation.
name str | None None Optional resource display name.
options Any {} Additional runtime creation options.
  • Runtime