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())
