Before you run#
Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Volumes for the full setup and current behavior.
Python example
Stage a checkpoint, publish it, and read it from a remote Task.
Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Volumes for the full setup and current behavior.
import asyncio
from pathlib import Path
import yak
app = yak.App(name="volume-checkpoint", image="python:3.11")
volume = yak.Volume.from_name("quickstart-checkpoints")
@app.task(volumes={"/checkpoint": volume.mount(read_only=True, subpath="reports")})
def read_checkpoint() -> str:
contents = Path("/checkpoint/summary.txt").read_text().strip()
return f"checkpoint: {contents}"
@app.entrypoint()
async def main() -> None:
with volume.open("reports/summary.txt", "w") as file:
file.write("ready\n")
volume.publish()
print(await read_checkpoint.remote.aio())
if __name__ == "__main__":
asyncio.run(main())
Save the source as volume_checkpoint.py, then run:
$ yak run volume_checkpoint.py