Before you run#
Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Object Storage Mounts for the full setup and current behavior.
Python example
Mount an existing bucket prefix with a named credential Secret.
Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Object Storage Mounts for the full setup and current behavior.
import asyncio
from pathlib import Path
import yak
app = yak.App(name="object-storage-reader", image="python:3.11")
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_summary() -> str:
return Path("/dataset/README.txt").read_text().strip()
@app.entrypoint()
async def main() -> None:
print(await read_dataset_summary.remote.aio())
if __name__ == "__main__":
asyncio.run(main())
Save the source as object_storage_mount.py, then run:
$ yak run object_storage_mount.py