Skip to content

Functions

def add_parser(groups: argparse._SubParsersAction) -> None
static
Parameter Type Default
groups argparse._SubParsersAction
Source: sdk/python/svm/cli_config.py:43
def add_parser(box: argparse._SubParsersAction) -> None
static
Parameter Type Default
box argparse._SubParsersAction
Source: sdk/python/svm/cli_files.py:21
def add_parser(groups: argparse._SubParsersAction) -> None
static
Parameter Type Default
groups argparse._SubParsersAction
Source: sdk/python/svm/cli_network.py:21
def add_parser(groups: argparse._SubParsersAction) -> None
static
Parameter Type Default
groups argparse._SubParsersAction
Source: sdk/python/svm/cli_storage.py:19
def add_parser(groups: argparse._SubParsersAction) -> None
static
Parameter Type Default
groups argparse._SubParsersAction
Source: sdk/python/svm/cli_team.py:14
def add_parser(groups: argparse._SubParsersAction) -> None
static
Parameter Type Default
groups argparse._SubParsersAction
Source: sdk/python/svm/cli_templates.py:27
def api_error(*, code: str, message: str, status_code: int, path: str | None=None, **fields) -> ApiError
static

The most specific ApiError for code. GUEST_UNRESPONSIVE, SANDBOX_UNREACHABLE and FILE_UPLOAD_FAILED name GuestUnresponsiveError, SandboxUnreachableError and FileUploadApiError from the code alone (never from the path). For NOT_FOUND the request’s path says what is missing (a sandbox, volume or secret); HTTP 507 is NotEnoughSpaceError; an unknown code stays a plain ApiError.

Parameter Type Default
code str
message str
status_code int
path str | None None
fields optional

Returns ApiError

Raises ApiError, FileUploadApiError, GuestUnresponsiveError, NotEnoughSpaceError, SandboxUnreachableError

Source: sdk/python/svm/errors.py:280
def apply(args: argparse.Namespace, path: Path | None, data: dict[str, Any]) -> None
static

Fill the arguments a command left unset from the project file, then the built-in defaults.

Parameter Type Default
args argparse.Namespace
path Path | None
data dict[str, Any]
Source: sdk/python/svm/cli_config.py:103
def config_path(env: dict[str, str]) -> str
static

The file the SDKs read the credentials from: $SVM_CONFIG when set, else the default location (see _config).

Parameter Type Default
env dict[str, str]

Returns str

Source: sdk/python/svm/cli_auth.py:187
def configure(path: str, domain: str, api_key: str, team: str | None=None, *, force: bool=False) -> dict[str, Any]
static

Write domain and api_key (and default_team_id when given) to the credentials file at path, mode 0600, keeping every other key in it. A file that already holds a domain or an API key is left alone unless force. The file is replaced atomically; a file that cannot be read as a JSON object is never overwritten. Nothing returned or raised holds the key.

Parameter Type Default
path str
domain str
api_key str
team str | None None
force bool False

Returns dict[str, Any]

Source: sdk/python/svm/cli_auth.py:211
def create_script(name: str, cwd: str | None, envs: dict[str, str] | None) -> str
static
Parameter Type Default
name str
cwd str | None
envs dict[str, str] | None

Returns str

Source: sdk/python/svm/sessions.py:26
def default_build_logger(file: IO[str] | None=None) -> Callable[[BuildLogLine], None]
static

An on_log for build/follow_logs that writes each line as <timestamp> [<stream>] <text> to file (standard error by default).

Parameter Type Default
file IO[str] | None None

Returns Callable[[BuildLogLine], None]

Source: sdk/python/svm/templates.py:58
def deserialize_chart(data: Dict[str, Any]) -> Chart
static

The typed chart for the kernel’s chart JSON.

Parameter Type Default
data Dict[str, Any]

Returns Chart

Source: sdk/python/svm/charts.py:147
def digest_of(path: str, size: int) -> 'hashlib._Hash'
static
Parameter Type Default
path str
size int

Returns 'hashlib._Hash'

Source: sdk/python/svm/transfer.py:108
def emit(value: Any, as_json: bool) -> None
static
Parameter Type Default
value Any
as_json bool
Source: sdk/python/svm/cli_common.py:28
def emit_page(response: dict[str, Any], as_json: bool, columns: tuple[str, ...]) -> None
static

A list response: JSON as the API sent it, else one tab-separated row per item and the next page token.

Parameter Type Default
response dict[str, Any]
as_json bool
columns tuple[str, ...]
Source: sdk/python/svm/cli_common.py:42
def envs(values: list[str]) -> dict[str, str]
static

--env KEY=VALUE entries of a terminal session.

Parameter Type Default
values list[str]

Returns dict[str, str]

Source: sdk/python/svm/cli_common.py:63
def error_kind(error: BaseException) -> str
static

The language-neutral name the conformance suite uses for an error.

Parameter Type Default
error BaseException

Returns str

Source: sdk/python/svm/errors.py:295
def find(start: Path) -> Path | None
static
Parameter Type Default
start Path

Returns Path \| None

Source: sdk/python/svm/cli_config.py:50
def fork(client: SandboxClient, args: argparse.Namespace) -> int
static

svm sandbox fork and svm snapshot fork: the children, never their access tokens.

Parameter Type Default
client SandboxClient
args argparse.Namespace

Returns int

Source: sdk/python/svm/cli_storage.py:83
def fork_options(parser: argparse.ArgumentParser) -> argparse.ArgumentParser
static
Parameter Type Default
parser argparse.ArgumentParser

Returns argparse.ArgumentParser

Source: sdk/python/svm/cli_storage.py:76
def group(subparsers: argparse._SubParsersAction, name: str, dest: str='command', **kwargs: Any) -> argparse._SubParsersAction
static
Parameter Type Default
subparsers argparse._SubParsersAction
name str
dest str 'command'
kwargs Any optional

Returns argparse._SubParsersAction

Source: sdk/python/svm/cli_common.py:19
def info(domain: str, settings: Any, open_store: Callable[[], Any], *, request: Callable[..., dict[str, Any]]=request_json) -> dict[str, Any]
static

Who the CLI acts as: the domain, which credential it uses (api_key, access_token, session or none) and, for a signed-in user, who that is. No credential is ever part of the answer. settings is the credential the SDKs would use (the environment, else the credentials file: _config.resolve), or None; the keyring is opened only then. signed_in is true only when GET /v2/me answered: it answers only a signed-in user, so an API key or a service account’s access token that it refuses (401 or 403) is reported with signed_in false, not as an error.

Parameter Type Default
domain str
settings Any
open_store Callable[[], Any]
request Callable[..., dict[str, Any]] request_json

Returns dict[str, Any]

Source: sdk/python/svm/cli_auth.py:157
def is_transient(error: grpc.RpcError) -> bool
static

Whether the same call may succeed on a new connection: the connection broke or the sandbox is not ready. A guest that took the call and stopped answering (reason GUEST_UNRESPONSIVE) is not: the host has already waited its health timeout, so a new connection meets the same stuck guest; the caller gets GuestUnresponsiveError at once.

Parameter Type Default
error grpc.RpcError

Returns bool

Raises GuestUnresponsiveError

Source: sdk/python/svm/resume.py:23
def leaf(subparsers: argparse._SubParsersAction, name: str, **kwargs: Any) -> argparse.ArgumentParser
static

A command parser that accepts --json.

Parameter Type Default
subparsers argparse._SubParsersAction
name str
kwargs Any optional

Returns argparse.ArgumentParser

Source: sdk/python/svm/cli_common.py:14
def load(explicit: str | None, env: dict[str, str]) -> tuple[Path | None, dict[str, Any]]
static

The project file named by --config or SVM_PROJECT_CONFIG, else the nearest svm.toml, parsed and checked. (SVM_CONFIG is the SDKs’ credentials file, never the project file.)

Parameter Type Default
explicit str | None
env dict[str, str]

Returns tuple[Path \| None, dict[str, Any]]

Source: sdk/python/svm/cli_config.py:58
def login(domain: str, store: Any, *, request: Callable[..., dict[str, Any]]=request_json, sleep: Callable[[float], None]=time.sleep, clock: Callable[[], float]=time.monotonic, open_browser: Callable[[str], bool]=webbrowser.open, write: Callable[[str], None]=print) -> dict[str, Any]
static
Parameter Type Default
domain str
store Any
request Callable[..., dict[str, Any]] request_json
sleep Callable[[float], None] time.sleep
clock Callable[[], float] time.monotonic
open_browser Callable[[str], bool] webbrowser.open
write Callable[[str], None] print

Returns dict[str, Any]

Source: sdk/python/svm/cli_auth.py:101
def logout(domain: str, store: Any, *, request: Callable[..., dict[str, Any]]=request_json) -> None
static
Parameter Type Default
domain str
store Any
request Callable[..., dict[str, Any]] request_json
Source: sdk/python/svm/cli_auth.py:249
def main(argv: list[str] | None=None, env: dict[str, str] | None=None) -> int
static
Parameter Type Default
argv list[str] | None None
env dict[str, str] | None None

Returns int

Source: sdk/python/svm/cli.py:434
def main()
staticSource: sdk/python/svm/lsp_driver.py:43
def message_stream(path: str, mode: int, owner: str, group: str, source: 'bytes | BinaryIO', totals: dict, *, user: str='', metadata: 'dict[str, str] | None'=None, gzip: bool=False) -> Iterator
static

The WriteFile messages for source, counting what was sent (the file’s own bytes, whether or not they travel gzipped).

Parameter Type Default
path str
mode int
owner str
group str
source 'bytes | BinaryIO'
totals dict
user str ''
metadata 'dict[str, str] | None' None
gzip bool False

Returns Iterator

Source: sdk/python/svm/transfer.py:121
def metadata(values: list[str]) -> dict[str, str]
static
Parameter Type Default
values list[str]

Returns dict[str, str]

Source: sdk/python/svm/cli_common.py:53
def normalize(tool: str, args: dict[str, Any]) -> dict[str, Any]
static

Drop unset arguments and spell paths one way, so ./src/a.py and src/a.py share a key.

Parameter Type Default
tool str
args dict[str, Any]

Returns dict[str, Any]

Source: sdk/python/svm/tool_cache.py:49
def open_tunnel(handle: AccessHandle, sandbox_id: str, port: int, *, timeout: float=10.0) -> Tunnel
static
Parameter Type Default
handle AccessHandle
sandbox_id str
port int
timeout float 10.0

Returns Tunnel

Raises ApiError, TransportError

Source: sdk/python/svm/tunnel.py:82
def paging(parser: argparse.ArgumentParser, size: int=50) -> None
static
Parameter Type Default
parser argparse.ArgumentParser
size int 50
Source: sdk/python/svm/cli_common.py:23
def parse_events(lines: Iterator[bytes]) -> Iterator[tuple[str | None, dict[str, Any]]]
static

(id, event) for every data: message of a server-sent event stream; comments and heartbeats are skipped.

Parameter Type Default
lines Iterator[bytes]

Returns Iterator[tuple[str \| None, dict[str, Any]]]

Source: sdk/python/svm/event_stream.py:23
def parse_log(text: str) -> list[GitCommit]
static
Parameter Type Default
text str

Returns list[GitCommit]

Source: sdk/python/svm/git_types.py:99
def parse_result(result: dict[str, Any], max_chars: int, read_file: Any=None) -> BrowserResult
static
Parameter Type Default
result dict[str, Any]
max_chars int
read_file Any None

Returns BrowserResult

Raises BrowserError

Source: sdk/python/svm/browser.py:108
def parse_status(text: str) -> GitStatus
static

git status --porcelain=v1 --branch -z output.

Parameter Type Default
text str

Returns GitStatus

Source: sdk/python/svm/git_types.py:61
def process_error(code: str, message: str, status: grpc.StatusCode, reason: str | None=None) -> ProcessError
static

The ProcessError for a data-plane failure, also an instance of the REST error class of its gRPC status (and of the specific class its envd code names, e.g. SandboxFileNotFoundError, or its reason: FILE_UPLOAD_FAILED is a FileUploadError, GUEST_UNRESPONSIVE a GuestUnresponsiveError).

Parameter Type Default
code str
message str
status grpc.StatusCode
reason str | None None

Returns ProcessError

Raises FileUploadError, GuestUnresponsiveError, ProcessError, SandboxFileNotFoundError

Source: sdk/python/svm/process.py:83
def qualify_image(reference: str) -> str
static

The full name of an image reference, as the build service reads it: a Docker Hub short name gains its registry (python:3.12-slim -> docker.io/library/python:3.12-slim, acme/app:1 -> docker.io/acme/app:1); a reference whose first part is a host (it has a dot or a port, or is localhost) and a local/ image stay as they are.

Parameter Type Default
reference str

Returns str

Source: sdk/python/svm/dockerfile.py:62
def read_api_key(from_stdin: bool, env: dict[str, str], stdin: Any=None, prompt: Callable[[str], str]=getpass.getpass) -> str
static

The key to save: the first line of standard input with --api-key-stdin, else SVM_API_KEY, else a prompt that does not echo (a terminal is needed). The key is never an argument, so it is not in the process list or the shell history.

Parameter Type Default
from_stdin bool
env dict[str, str]
stdin Any None
prompt Callable[[str], str] getpass.getpass

Returns str

Source: sdk/python/svm/cli_auth.py:192
def read_ranges(open_read: Callable[[int, int], Iterator], offset: int, limit: int, policy: RetryPolicy, still_same: Callable[[], bool] | None=None, on_auth: Callable[[grpc.RpcError], bool] | None=None) -> Iterator[bytes]
static

The bytes of a file from offset (up to limit, 0 meaning to the end), resuming where a break left off.

open_read(offset, limit) opens one ranged read; still_same() is asked before each resume and raises when the file changed, because bytes from two versions must not be joined.

Parameter Type Default
open_read Callable[[int, int], Iterator]
offset int
limit int
policy RetryPolicy
still_same Callable[[], bool] | None None
on_auth Callable[[grpc.RpcError], bool] | None None

Returns Iterator[bytes]

Raises TransferError

Source: sdk/python/svm/transfer.py:56
def reader(stream, out)
static
Parameter Type Default
stream
out
Source: sdk/python/svm/lsp_driver.py:26
def refresh_access_token(domain: str, store: Any, *, request: Callable[..., dict[str, Any]]=request_json) -> str
static
Parameter Type Default
domain str
store Any
request Callable[..., dict[str, Any]] request_json

Returns str

Source: sdk/python/svm/cli_auth.py:141
def registry_of(image: str) -> str
static

The registry host of an image reference (Docker Hub when the first component is not a host).

Parameter Type Default
image str

Returns str

Source: sdk/python/svm/template_helpers.py:92
def release_data_plane(sandbox: object) -> None
static

Close a sandbox handle’s data-plane channels (commands, files, metrics, ports) before the CLI exits. A gRPC channel left to the garbage collector at interpreter shutdown can deadlock in its __del__, so a command that printed its result could hang instead of exiting (F130).

Parameter Type Default
sandbox object
Source: sdk/python/svm/cli_common.py:99
def request_json(domain: str, method: str, path: str, *, body: dict[str, Any] | None=None, bearer_token: str | None=None, api_key: str | None=None, timeout: float=10.0) -> dict[str, Any]
static
Parameter Type Default
domain str
method str
path str
body dict[str, Any] | None None
bearer_token str | None None
api_key str | None None
timeout float 10.0

Returns dict[str, Any]

Raises ApiError

Source: sdk/python/svm/cli_auth.py:63
def rewrite_data_plane_url(url: str, template: str | None=None) -> str
static

The data-plane URL to dial: url as the API gave it, or rewritten by SVM_DATA_PLANE_URL_TEMPLATE.

The template is an HTTP(S) URL in which {host} stands for the host the API gave (the edge routes on it, so keep it); the API’s path, if any, is kept. https://{host}:8443 reaches a data plane that is only on another machine’s loopback through ssh -L 8443:127.0.0.1:443 <that machine>. The data-plane token goes wherever the template points, so set it only to an address you control, as with SVM_DOMAIN.

Parameter Type Default
url str
template str | None None

Returns str

Source: sdk/python/svm/sandbox_types.py:15
def run(args: argparse.Namespace, path: Path | None, data: dict[str, Any]) -> int
static
Parameter Type Default
args argparse.Namespace
path Path | None
data dict[str, Any]

Returns int

Source: sdk/python/svm/cli_config.py:125
def run(client: SandboxClient, args: argparse.Namespace) -> int
static
Parameter Type Default
client SandboxClient
args argparse.Namespace

Returns int

Source: sdk/python/svm/cli_files.py:82
def run(client: SandboxClient, args: argparse.Namespace) -> int
static
Parameter Type Default
client SandboxClient
args argparse.Namespace

Returns int

Source: sdk/python/svm/cli_network.py:67
def run(client: SandboxClient, args: argparse.Namespace, env: dict[str, str]) -> int
static
Parameter Type Default
client SandboxClient
args argparse.Namespace
env dict[str, str]

Returns int

Source: sdk/python/svm/cli_storage.py:100
def run(client: SandboxClient, args: argparse.Namespace) -> int
static
Parameter Type Default
client SandboxClient
args argparse.Namespace

Returns int

Source: sdk/python/svm/cli_team.py:23
def run(client: SandboxClient | None, args: argparse.Namespace) -> int
static
Parameter Type Default
client SandboxClient | None
args argparse.Namespace

Returns int

Source: sdk/python/svm/cli_templates.py:51
def run_script(name: str, command: str) -> str
static

Restore the session, run command in this shell, and save cwd and exports on the way out, even after exit.

Parameter Type Default
name str
command str

Returns str

Source: sdk/python/svm/sessions.py:37
def script(repo: str | None, *args: str) -> str
static

The shell line for git args in repo: quoted, non-interactive.

Parameter Type Default
repo str | None
args str optional

Returns str

Source: sdk/python/svm/git.py:74
def send_whole(send: Callable[[Iterator], object], make_messages: Callable[[dict], Iterator], rewind: Callable[[], bool], policy: RetryPolicy, on_auth: Callable[[grpc.RpcError], bool] | None=None) -> tuple[object, dict]
static

Send an upload, again from the start after a broken connection while the source can be rewound.

Parameter Type Default
send Callable[[Iterator], object]
make_messages Callable[[dict], Iterator]
rewind Callable[[], bool]
policy RetryPolicy
on_auth Callable[[grpc.RpcError], bool] | None None

Returns tuple[object, dict]

Raises FileUploadError

Source: sdk/python/svm/transfer.py:179
def sink_for(dest: 'str | os.PathLike[str] | BinaryIO', resume: bool)
static

A writable file object for dest, the bytes it already holds, and how to finish it.

Parameter Type Default
dest 'str | os.PathLike[str] | BinaryIO'
resume bool
Source: sdk/python/svm/transfer.py:87
def terminal_options(parser: argparse.ArgumentParser) -> argparse.ArgumentParser
static

The options of the interactive guest shell: who it runs as, where, and with which environment.

Parameter Type Default
parser argparse.ArgumentParser

Returns argparse.ArgumentParser

Source: sdk/python/svm/cli_common.py:74
def translate(text: str, *, name: str, ready: list[str] | None=None) -> tuple[dict, list[str]]
static

Return (definition, notes). ready is required unless there is a HEALTHCHECK.

Parameter Type Default
text str
name str
ready list[str] | None None

Returns tuple[dict, list[str]]

Raises DockerfileError, SandboxError

Source: sdk/python/svm/dockerfile.py:109
def verify_webhook_signature(secret: str | Sequence[str], body: bytes, header: str, *, tolerance_seconds: int=300, now: float | None=None) -> None
static

Raise WebhookSignatureError unless header (the X-Webhook-Signature value) is a valid signature of body.

secret is the hex string the platform returned when the webhook was created; its bytes are the HMAC key. During a secret rotation pass a list of secrets (the new one and the old one): a signature by any of them verifies. Pass the body exactly as received, not re-encoded. A timestamp further than tolerance_seconds from now is refused, which is what stops a captured request from being replayed later.

Parameter Type Default
secret str | Sequence[str]
body bytes
header str
tolerance_seconds int 300
now float | None None

Raises WebhookSignatureError

Source: sdk/python/svm/webhook_signature.py:21
def volume_mounts(values)
static

--volume ID:/path[:ro] entries as the create request’s volume_mounts.

Parameter Type Default
values
Source: sdk/python/svm/cli_common.py:87
def wait_for_file(path: str) -> str
static

A ready command that passes once path exists.

Parameter Type Default
path str

Returns str

Source: sdk/python/svm/template_helpers.py:80
def wait_for_port(port: int) -> str
static

A ready command that passes once something listens on TCP port (it reads /proc/net/tcp, so the image needs no tools).

Parameter Type Default
port int

Returns str

Source: sdk/python/svm/template_helpers.py:56
def wait_for_process(name: str) -> str
static

A ready command that passes once a process named name runs (its /proc comm, at most 15 characters).

Parameter Type Default
name str

Returns str

Source: sdk/python/svm/template_helpers.py:73
def wait_for_timeout(ms: int) -> str
static

A ready command that passes after ms milliseconds (rounded up to whole seconds).

Parameter Type Default
ms int

Returns str

Source: sdk/python/svm/template_helpers.py:85
def wait_for_url(url: str, status: int=200) -> str
static

A ready command that passes once url answers with HTTP status (the image needs curl).

Parameter Type Default
url str
status int 200

Returns str

Source: sdk/python/svm/template_helpers.py:63
def watch_events(call: Callable[[str, object], object], path: str, recursive: bool, policy: RetryPolicy, sleep: Callable[[float], None]=time.sleep, stop=None, user: str='') -> Iterator
static

Events of a directory through a polled watcher: the sandbox queues them, so a break loses none. stop (an event) ends the loop, so a consumer that went away does not leave a thread polling.

Parameter Type Default
call Callable[[str, object], object]
path str
recursive bool
policy RetryPolicy
sleep Callable[[float], None] time.sleep
stop None
user str ''

Returns Iterator

Raises WatchLostError

Source: sdk/python/svm/transfer.py:200
def without_access(item: dict[str, Any]) -> dict[str, Any]
static

A sandbox as the API returned it, minus the guest and traffic tokens, which the CLI never prints.

Parameter Type Default
item dict[str, Any]

Returns dict[str, Any]

Source: sdk/python/svm/cli_common.py:82
def wrap_async(name: str)
static
Parameter Type Default
name str
Source: sdk/python/svm/desktop_extras.py:145
def x11_key(key: str) -> str
static

key with common names (enter, esc, cmd+a, F5 …) turned into X11 keysyms, part by part; other parts are kept.

Parameter Type Default
key str

Returns str

Source: sdk/python/svm/desktop.py:46