archil mount uses FUSE, which Modal supports in VM Sandboxes (runtime="vm"). Modal Functions and Sandboxes on the default runtime can’t mount FUSE file systems. From those, read and write the disk with the Python SDK (get_object and put_object, with ARCHIL_API_KEY and ARCHIL_REGION in a Modal Secret), the same way the last step below reads it from your machine.
Prerequisites
Export your Archil API key and region, then install the Archil and Modal SDKs and sign in to Modal:Mount a disk
First, create a disk and store its mount token in a Modal Secret. The token grants access to this disk only. You only do this once:setup.py
eval "$(python setup.py)" to export the disk ID.
Now start a VM Sandbox from an image with the archil client installed. The Sandbox mounts the disk at /mnt/archil, writes a file, and unmounts on exit:
sandbox.py
archil client buffers recent writes, so the trap unmounts before the Sandbox exits, even if a command fails: archil unmount returns once every write has reached the disk. Run modal run sandbox.py twice. Each run starts a new Sandbox, and the second one finds the line the first one wrote:
--shared, and see Sharing disks.
Read it from anywhere
Both Sandboxes are gone, and the file is still on the disk. Read it from your own machine or app with the SDK:read.py
Clean up
Delete the disk and the Modal Secret withpython cleanup.py. Apps started with modal run stop on their own.
cleanup.py
Next steps
- Python SDK: read, write, and search the disk without mounting it.
- Persistent sandboxes: Archil’s own sandboxes, with the disk mounted for you.