Before you run#
Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Ephemeral Disks for the full setup and current behavior.
Python example
Write a temporary file to a bounded Ephemeral Disk.
Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Ephemeral Disks for the full setup and current behavior.
import asyncio
from pathlib import Path
import yak
app = yak.App(name="ephemeral-scratch", image="python:3.11")
@app.task(ephemeral_disks={"/scratch": yak.EphemeralDisk(size="1GiB")})
def write_temporary_file() -> str:
path = Path("/scratch/intermediate.txt")
path.write_text("temporary\n")
return path.read_text().strip()
@app.entrypoint()
async def main() -> None:
print(await write_temporary_file.remote.aio())
if __name__ == "__main__":
asyncio.run(main())
Save the source as ephemeral_disk.py, then run:
$ yak run ephemeral_disk.py