What an Ephemeral Disk is#

An EphemeralDisk is bounded filesystem scratch space for one Task Invocation. The filesystem is isolated to that Invocation and is destroyed when it ends. A later Invocation does not see its contents.

Use it for temporary extraction, intermediate files or indexes that do not belong in durable storage. Use a Volume when files must persist, or an Object Storage Mount when they belong in an external bucket.

Declare scratch capacity#

Declare the disk in @app.task(ephemeral_disks=...) and choose an absolute mount path:

python
scratch = yak.EphemeralDisk(size="20GiB")

@app.task(ephemeral_disks={"/scratch": scratch})
def make_temporary_file() -> str:
    from pathlib import Path
    path = Path("/scratch/intermediate.txt")
    path.write_text("temporary\n")
    return path.read_text().strip()

size is an integer GiB string from 1GiB through 100GiB. It is the nominal filesystem size; filesystem metadata leaves slightly less space available to application files. The current Preview supports at most one Ephemeral Disk per Task declaration.

Mount paths must be absolute, non-root, non-overlapping and outside reserved Yak paths. Check them against the Task’s Volume and Object Storage Mount declarations. Persistent yak deploy does not support Ephemeral Disk declarations in the current SDK contract.

Capacity and lifetime#

If the Task writes beyond the usable capacity, the filesystem reports a normal space-exhaustion error such as ENOSPC. Handle or avoid it in the Task if the workload can approach the configured size. Setup or mount failures happen before user code starts; an ENOSPC raised while writing is an application-time filesystem error.

The disk is removed when its Invocation ends whether the Task succeeds, fails, is cancelled or times out. Copy data that must survive into a Volume or an external object store before the Task returns.