What an Object Storage Mount is#

An ObjectStorageMount exposes an existing S3 or S3-compatible bucket, optionally narrowed to a relative prefix, at a filesystem path inside one Task Invocation. The objects stay in the external provider. Yak does not copy the bucket into a Volume or take ownership of its lifecycle.

Use a mount when the data already belongs in object storage and the Task needs filesystem access. Use a Volume for Yak-managed durable files, or an Ephemeral Disk for invocation-local scratch.

Declare a mount#

The example below reads README.txt from a bucket prefix:

python
dataset = yak.ObjectStorageMount(
    bucket="team-datasets",
    prefix="training/current",
    credentials=yak.Secret.from_name("dataset-reader"),
    mode="ro",
)

@app.task(mounts={"/dataset": dataset})
def read_dataset() -> str:
    from pathlib import Path
    return Path("/dataset/README.txt").read_text()

mode="ro" is the default and rejects writes through the mount. Choose mode="rw" only when the Task should write directly to the external bucket. A prefix is relative to the bucket; the mounted prefix appears at the mount root.

Credentials and provider configuration#

credentials must be a named Secret.from_name(...) reference. Create the Secret through the supported CLI workflow, scoped to the same Environment that runs the Task. The Task declaration contains the name; secret values are resolved server-side for the Invocation. Inline Secret descriptors are not accepted for this mount.

The default provider region is us-east-1. A custom S3-compatible endpoint requires an explicit region. Use an HTTPS endpoint in normal deployments; HTTP is limited to localhost development. Supply the endpoint URL only, without user information, a path, query or fragment.

Mount paths and setup failures#

The mount target must be an absolute, non-root path. Mount targets cannot overlap one another or cover reserved Yak paths. Validate the target alongside the Task’s Volume and Ephemeral Disk mounts.

Invalid mount configuration, unavailable credentials or a failed mount setup prevents the Task’s user code from starting. These are Invocation setup failures rather than exceptions raised by your Python callable. Once the mount is ready, normal file errors and application errors come from the Task’s code.

Prerequisites and Preview boundary#

The example below requires all of the following before yak run object_storage_mount.py can succeed:

  • an existing S3-compatible bucket and the training/current/README.txt object;
  • a named Secret, dataset-reader, containing credentials with read access to that bucket prefix;
  • Preview access to the Environment where the Secret and Task are used.

The example uses a read-only mount and prints only the dataset README text. Do not place access keys in the source file. Object Storage Mounts and Ephemeral Disks are Task Invocation resources and are not supported by persistent yak deploy in the current SDK contract.