Distributed Storage Volumes
Attach distributed storage volumes to your apps
Beam allows you to create highly-available storage volumes that can be used across tasks. You might use volumes for things like storing model weights or large datasets.
Beam Volumes are mounted directly to the containers that run your code, so they are more performant than using cloud object storage.
We strongly recommend storing your data in Beam Volumes for any data you plan to access from your Beam functions.
How to Write Files in Beam
Your apps run in containers that are read only.
There are two use-cases for saving files: persistent files, that you want to access between tasks, and temporary files that will be deleted when your container spins down.
- Persisting Files: write to a volume.
- Temporary Files: temporary files can be written to the
/tmp
directory in your Beam container, for example you could save an image to/tmp/myimage.png
.
Reading and Writing to Volumes
You can read and write to your Volume like any ordinary Python file:
To run this code, run python [filename].py
. You’ll see it print the text we just wrote to the file.
Mounting a Volume
Volumes can be attached anything you run on Beam.
By default, Volumes are shared across all apps in your Beam account.
Uploading Data
You can upload files with the CLI using the beam cp
command.
CLI Management Commands
Create a Volume
Delete a Volume
List Volumes
List Volume Contents
Copy Files to Volumes
Move Files in Volumes
Remove Files from Volumes
Was this page helpful?