Mounting a Persistent Volume
To setup a persistent volume, first mount in your app definition file. The path is relative to the files in your workspace.app.py
Reading and Writing Files
You can read and write to the persistent volume like an ordinary Python file:run.py
Example: Caching Model Weights
A good use case for Persistent Volumes is caching your ML model in order to avoid downloading it each time you make a prediction. If you’re using a Huggingface model, you can set the Huggingface cache location inapp.py
.
app.py
Example: Saving Pickle Files
You can manually save files to the Persistent Volume. First, mount the volume inapp.py
.
app.py
run.py