Skip to main content
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 Containers

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.
  1. Persisting Files: write to a volume.
  2. 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:
It can take up to 60 seconds for any files written to a distributed volume to become available to other containers.
To run this code, run python [filename].py. You’ll see it print the text we just wrote to the file.

Creating a Volume

Volumes can be attached anything you run on Beam.
By default, Volumes are shared across all apps in your Beam account.
If you add a volume to your app, it will be created automatically. You can also create volumes manually in the CLI, by using:

Uploading Data

You can upload files with the CLI using the beam cp command.

Files

Directories

Downloading Data

Files

Directories

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