VolumeClient

class baseten.sandbox.VolumeClient

Bases: object

Persistent volumes, which keep their data beyond the sandboxes they are mounted in.

Mount one when creating a sandbox with its volumes option. Obtained from SandboxClient.volumes.

Parameters:

context (VolumeClientContext)

create(*, size, name=None, region=None, labels=None)

Create a volume.

The volume becomes ready asynchronously, so its status may still be deploying.

Parameters:
  • size (str | int) – Capacity, as a size such as "10Gi" or "512Mi", or a number of megabytes. It can grow later but never shrink.

  • name (str | None) – Unique name of the volume. The server assigns one when None.

  • region (str | None) – Region of the volume. Defaults to the default sandbox region. Only sandboxes in the same region can mount it.

  • labels (Mapping[str, str] | None) – Key-value pairs for organizing and filtering.

Return type:

VolumeInfo

delete(*, name)

Delete a volume and its data. Fails while a sandbox mounts it.

Deletion continues after this returns, so the record usually shows the volume as deleting.

Parameters:

name (str) – Name of the volume.

Return type:

VolumeInfo

get_info(*, name)

Get a volume’s current record.

Parameters:

name (str) – Name of the volume.

Return type:

VolumeInfo

list(*, query=None, statuses=None, page_size=None)

List volumes, newest first, fetching further pages as iteration reaches them.

Records omit labels.

Parameters:
  • query (str | None) – Searches volume names.

  • statuses (list[Literal['DEPLOYING', 'DEPLOYED', 'FAILED', 'DELETING'] | str] | None) – Only volumes with one of these statuses.

  • page_size (int | None) – How many volumes to fetch per underlying request.

Return type:

Iterator[VolumeInfo]

update(*, name, size=None, labels=None)

Update a volume, returning its new record.

Parameters:
  • name (str) – Name of the volume.

  • size (str | int | None) – New capacity, as a size such as "20Gi" or a number of megabytes, no less than the current capacity. None leaves it unchanged.

  • labels (Mapping[str, str] | None) – Labels replacing all current ones, including when empty. None leaves them unchanged.

Return type:

VolumeInfo