Skip to content

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.

sandbox/work/data.csvpip install donesnapshotfiles only/work/data.csvtry solution A/work/data.csvtry solution B/work/data.csvtry solution C
Prepare an environment one time. A snapshot saves its files. A fork starts new sandboxes from it, so an agent can try three solutions from the same state.

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.

Terminal window
boxfork snapshot <sandbox> # prints a snapshot ID
boxfork create --snapshot <snapshot> # a new sandbox with those files

A 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 files
Terminal window
boxfork 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.
  • 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.