shared-notes, created as in
Create a drive, and a running sandbox named
hello-world in the same region, created as in
Create a sandbox.
Drives are in pre-release in the Baseten CLI (
baseten drive and baseten sandbox drive) and in the Python, TypeScript, and Go SDKs (baseten, @basetenlabs/client, @basetenlabs/sandbox, and baseten-go). Commands, methods, and responses can change. The Management API drive operations are experimental.Mount a drive
The mount path must be an absolute path that no other mount uses, such as/mnt/notes. A mount lasts until you unmount it.
To mount shared-notes at /mnt/notes:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code:
hello. The file stays on the drive after you unmount it
or delete the sandbox.
Mount one folder of a drive
Mount a folder of the drive instead of the whole drive. Give the folder’s path from the drive’s root, starting with/.
To mount the drive’s /projects/alpha folder at /mnt/alpha:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code with the same sandbox:
Mount a drive read-only
A read-only mount lets the sandbox read the drive’s files but not change them. Use one for a sandbox that only reads shared inputs. To mountshared-notes read-only at /mnt/notes-ro:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code with the same sandbox:
Share a drive between sandboxes
Mount the same drive in each sandbox that needs its files. Each sandbox mounts it separately, at its own mount path, and can mount it read-write or read-only. To pass a file from one sandbox to another: This procedure uses a second running sandbox namedreader in the drive’s
region.
-
Run the following command to write a file from
hello-world, where the drive is mounted read-write at/mnt/notes: -
Run the following command to mount the drive read-only in
reader: -
Run the following command to read the file from
reader:The command printsstep 1 done.
Troubleshoot mounting
Next steps
List drive mounts
See which drives a sandbox has mounted.
Unmount a drive
Detach a drive from a sandbox and keep its files.