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.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.
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:
/mnt/notes
is in the list.
With the CLI set up, you can also write a file and
read it back:
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/. If the folder doesn’t exist,
mounting creates it.
To mount the drive’s /projects/alpha folder at /mnt/alpha:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code:
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:
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.
List drive mounts
Each mount shows the drive’s name, the folder of the drive that’s mounted (/
for the whole drive), the mount path in the sandbox, and whether it’s
read-only.
To list the drives mounted in hello-world:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code:
Unmount a drive
Identify the mount by its mount path. To find it, list the sandbox’s drive mounts. To unmount the drive at/mnt/notes:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code:
Troubleshoot mounting
Next steps
Delete a drive
Permanently remove a drive and its files.
Manage drives
Create a drive, check it, or replace its labels.