Persistent Storage
Ricochet isolates each deployment from the one before it.
To keep files across deployments, or to let your app’s workers use the same files, save them in the ./persistent directory.
Ricochet puts ./persistent at the root of your bundle in every deployment, and keeps what you save there until you delete the app or task.
Treat ./persistent like any other folder:
# save a model, then read it back after a restart or redeploysaveRDS(model, "persistent/model.rds")model <- readRDS("persistent/model.rds")using Serialization
# save a model, then read it back after a restart or redeployserialize("persistent/model.jls", model)model = deserialize("persistent/model.jls")import pickle
# save a model, then read it back after a restart or redeploywith open("persistent/model.pkl", "wb") as f: pickle.dump(model, f)with open("persistent/model.pkl", "rb") as f: model = pickle.load(f)Run It Locally
Section titled “Run It Locally”On your own machine, persistent/ exists only once you create it.
Create it at the start of your code so the same code runs locally and on ricochet:
dir.create("persistent", showWarnings = FALSE)mkpath("persistent")from pathlib import Path
Path("persistent").mkdir(exist_ok=True)Entrypoint in a Folder
Section titled “Entrypoint in a Folder”Ricochet starts your code in the root of your bundle, where persistent/ lives.
Shiny, Quarto and R Markdown switch to the folder of your entrypoint before they run your code.
If your entrypoint is app/app.R or reports/index.qmd, save to ../persistent/ instead, with one ../ for each folder level.
Ship Files With a Deployment
Section titled “Ship Files With a Deployment”To start with data, put a persistent/ folder in your bundle.
When you deploy, ricochet copies its files into persistent/ and keeps any file already there with the same name.
If you only use a local persistent/ folder for testing, leave it out of the bundle in _ricochet.toml:
[content]exclude = ["persistent/**"]See Your Files
Section titled “See Your Files”Open your app or task and select Files:
- Deployment lists the files in one deployment. It opens on your newest successful deployment, and Bundle switches to another one.
- Persistent lists the files in
./persistent.
You need the Contributor role to see these files and the Editor role to download them.
Deployment leaves out persistent/ and package environments such as renv/ and .venv/.
It lists .env, .env.* and .Renviron files as hidden, and you can’t download them, because they may contain secrets.
Package Cache
Section titled “Package Cache”Ricochet installs each version of an R, Julia or Python package once, then reuses it for every app and task that needs it. So you wait less on later deployments.