baseten.sandboxΒΆ

Create and work with Baseten sandboxes.

Create one SandboxClient up front and reuse it, then create a sandbox and run a command in it:

from baseten.sandbox import SandboxClient

with SandboxClient(api_key="my-api-key") as client:
    sandbox = client.create()
    process = sandbox.process.exec(
        command="echo hello", wait_for_completion=True
    )
    print(process.stdout)

AsyncSandboxClient is the same for async code. HTTP/2 is used when the h2 package is installed, which is recommended: pip install "httpx[http2]".

Classes

AsyncImageClient

Async form of ImageClient.

AsyncSandbox

Async form of Sandbox.

AsyncSandboxClient

Async form of SandboxClient.

AsyncSandboxCreateResult

Async form of SandboxCreateResult.

AsyncSandboxFileSystem

Async form of SandboxFileSystem.

AsyncSandboxPreviews

A sandbox's previews, which expose its ports on HTTPS URLs.

AsyncSandboxProcess

Async form of SandboxProcess.

AsyncSandboxStream

Async form of SandboxStream.

ImageBuilder

An image described as a Dockerfile and the files it copies in.

ImageCleanupResult

Result of ImageClient.cleanup().

ImageClient

Images that sandboxes are created from.

ImageIgnoreFileOptions

A candidate path in a directory being pushed, for an ignore function.

ImageIgnoreFileProcessorOptions

A .dockerignore found at the root of a directory being pushed.

ImageInfo

An image repository as last reported by the control plane.

ImageLibraryInfo

A built-in image available to every team.

ImageLibraryVolume

A volume attachment a built-in image suggests, in ImageLibraryInfo.

ImageLogLine

One line of an image's build log, from ImageClient.logs().

ImageTagInfo

One version of an image.

Sandbox

One sandbox, to run processes and work with files in.

SandboxClient

Client for Baseten sandboxes.

SandboxClientOptions

Options for SandboxClient and AsyncSandboxClient.

SandboxCreateResult

A newly created sandbox, with its record as of creation.

SandboxEnvValue

Value of an environment variable in a sandbox.

SandboxExpirationPolicyDate

Expires a sandbox at a fixed time.

SandboxExpirationPolicyIdle

Expires a sandbox after a period without activity.

SandboxExpirationPolicyMaxAge

Expires a sandbox a period after its creation, regardless of activity.

SandboxExpirationPolicyUnknown

An expiration policy of a kind this SDK does not know.

SandboxFileSystem

Files and directories in a sandbox.

SandboxFileSystemDirectory

A directory's contents, one level deep, from SandboxFileSystem.list().

SandboxFileSystemFileInfo

A file in a SandboxFileSystemDirectory.

SandboxFileSystemFindMatch

An entry found by SandboxFileSystem.find().

SandboxFileSystemFindResult

Result of SandboxFileSystem.find().

SandboxFileSystemGrepMatch

A matching line found by SandboxFileSystem.grep().

SandboxFileSystemGrepResult

Result of SandboxFileSystem.grep().

SandboxFileSystemOptions

Filesystem configuration of a sandbox, fixed at creation.

SandboxFileSystemSubdirectoryInfo

A subdirectory in a SandboxFileSystemDirectory.

SandboxFileSystemWatchEvent

A change seen by SandboxFileSystem.watch().

SandboxInfo

A sandbox as last reported by the control plane.

SandboxLifecycle

When a sandbox is deleted automatically, and how long its record stays after.

SandboxNetwork

Network configuration of a sandbox, fixed at creation.

SandboxNetworkProxy

Proxy configuration of a sandbox's network.

SandboxNetworkProxyRoute

A proxy rule injecting headers and body fields into requests to its destinations.

SandboxPort

A port the sandbox exposes.

SandboxPreviewInfo

A preview as last reported by the control plane.

SandboxPreviewTokenInfo

An access token for a private preview.

SandboxPreviews

A sandbox's previews, which expose its ports on HTTPS URLs.

SandboxProcess

Processes in a sandbox.

SandboxProcessExecEventExit

The exit of the process run by SandboxProcess.exec_stream().

SandboxProcessExecEventOutput

Output from SandboxProcess.exec_stream().

SandboxProcessInfo

A process in a sandbox.

SandboxProcessLogLine

One line of a process's output.

SandboxProcessLogs

Output of a process, as returned by SandboxProcess.logs().

SandboxRetryOptions

Retry budgets for transient failures.

SandboxStream

Items a sandbox sends as they happen, read by iterating.

SandboxTokenProviderContext

What a token provider is told about the token it is asked for.

Functions

default_image_ignore_file(options)

Report whether a path is left out of a pushed build context by default.