Snapshot and fork
Prepare an environment one time, then copy it. A snapshot saves the files of a sandbox. A fork makes new sandboxes from those files.
Snapshot
Section titled “Snapshot”A snapshot is the saved files of a sandbox. The engine keeps a snapshot as an image. You can start any number of new sandboxes from one snapshot, now or later.
boxfork snapshot <sandbox> # prints a snapshot IDboxfork create --snapshot <snapshot> # a new sandbox with those filesA snapshot stays until you delete it with boxfork rmsnapshot.
A fork does the snapshot and the new sandboxes in one step:
copies = sbx.fork(3) # three sandboxes with the same filesboxfork fork --count 3 <sandbox>A change in one copy does not go to the other copies or to the original. If the daemon cannot create all the copies, it creates none. The daemon removes the snapshot of a fork when it kills the last copy.
- An agent tries many solutions. Fork the sandbox, try one idea in each copy, and keep the copy that works.
- Many runs from one setup. Install the packages one time, then fork for each test or each evaluation.
- Episodes for reinforcement learning. Start each episode from the same state. See RL with boxfork.
What a snapshot does not keep
Section titled “What a snapshot does not keep”- Processes that run. A copy starts its processes again.
- The data in memory, also the memory of a GPU, and
/dev/shm. - The data of a volume. A copy mounts the same volumes as the original.
- A directory that the image keeps in a volume of its own. The snapshot lists these paths as
excluded_paths.
Snapshots that keep memory and processes need a microVM backend. That is on the roadmap, and it is not built.