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.- Persisting Files: write to a volume.
- Temporary Files: temporary files can be written to the
/tmpdirectory 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:Running a database or another service where a single process owns its data?
A durable disk gives one container fast, node-local
storage that persists across restarts.
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 scoped to a workspace and can be shared by its apps.
Uploading Data
You can upload files with the CLI using thebeam cp command.