sail.Image provides the base images you start a Sailbox from and a chainable
builder for customizing them. @sail.function lets you ship a local Python
function into a Sailbox and run it as if it were local. See the
Images guide for a task-oriented walkthrough.
sail.Image
sail.Image is a namespace of base-image properties. Each returns an
ImageDefinition you can either pass directly to
Sailbox.create or extend with builder methods.
| Property | Architecture | Python pinning |
|---|---|---|
sail.Image.debian_arm64 | arm64 | Pins the image to your local Python version. |
sail.Image.debian_arm | arm64 | Alias of debian_arm64. |
sail.Image.builtin_debian_arm64 | arm64 | Stable builtin rootfs, no Python-versioned base. |
sail.Image.debian_amd64 | amd64 | No Python-versioned variant. |
sail.Image.debian_amd | amd64 | Alias of debian_amd64. |
Prefer
debian_arm64 / debian_arm for most workloads: they pin the base
image to your local interpreter, so functions shipped with
@sail.function (serialized with cloudpickle) run against a
matching Python inside the Sailbox. Reach for builtin_debian_arm64 only when
you specifically need a base image that does not vary with your local Python
version.ImageDefinition
AnImageDefinition is an immutable image spec. Builder methods return a new
ImageDefinition, so you chain them and finish with .build() (or pass the
unbuilt definition straight to Sailbox.create, which builds it for you).
apt_install
apt. Requires at least one
non-empty package name.
pip_install
pip. Requires at least one
non-empty package name.
run_commands
add_local_file
remote_path. The file
is hashed (sha256) and uploaded to the content-addressed asset store; only the
hash, target path, and mode flow into the spec, so a one-byte change forces a
rebuild.
| Parameter | Default | Description |
|---|---|---|
local_path | required | Path to the local file. |
remote_path | required | Absolute POSIX destination. A trailing slash appends the local basename. |
mode | None | POSIX permission bits (low 9 bits, max 0o777). Defaults to 0o644. |
ValueError if the source is missing, the path is invalid, or the
file exceeds the 5 GiB single-file limit.
add_local_dir
remote_path. Each regular file is
hashed and uploaded; per-file modes come from the local stat. Symlinks are
skipped. ignore accepts gitignore-style patterns (a list) or a path to a
file of patterns (e.g. .dockerignore). remote_path must be absolute.
env
build
ImageDefinition (one carrying a resolved image id). timeout must be > 0.
Raises sail.ImageBuildError if the build fails, TimeoutError if it does
not finish within timeout.
You rarely need to call
build() yourself: passing an unbuilt definition to
Sailbox.create builds it first (bounded by
image_build_timeout).@sail.function
Sailbox.exec. The decorator returns a
SailFunction; calling it locally still invokes the original
function unchanged.
SailFunction to exec, the call blocks and returns the
function’s return value directly (not a SailboxExecRequest). The SDK
serializes the function and its arguments with cloudpickle, runs them with the
image’s python3, and returns the deserialized result.
Constraints:
- Function execution is synchronous;
background=Trueis not supported. - Currently supported only for sailboxes running custom images.
- The sailbox’s
python3must match your local Python major.minor (cloudpickle bytecode is version-sensitive), which is whydebian_arm64pins the local version. - Imported third-party packages are referenced by name, so they must exist in the sailbox environment.
- Keep arguments and return values small; write large artifacts from inside the sailbox and return a small reference instead.
sail.SailboxFunctionError (with the remote error_type,
traceback, stdout, stderr attached) when the function raises remotely,
and sail.SailboxFunctionSerializationError if the payload or result cannot be
serialized or the runtime cannot be prepared. See Errors.
SailFunction
The wrapper returned by@sail.function. You normally don’t construct it
directly. Calling a SailFunction locally is identical to calling the wrapped
function. Async functions, async generators, and generator functions are
rejected at decoration time with TypeError.
| Member | Description |
|---|---|
func | The wrapped callable. |
__call__(*args, **kwargs) | Invokes the wrapped function locally. |