Home Console
Guides

Shared volumes

One folder that several of your computers mount at once: children write, a parent reads, files outlive the computers.

workpaper volume create job-1                        # a shared folder
workpaper run parent  --volume job-1:/shared         # mounts it at /shared
workpaper run child-1 --volume job-1:/shared -- sh -c 'echo done > /shared/child-1.txt'
workpaper exec parent -- ls /shared                  # child-1.txt is already there

A volume is a named folder that lives on the server, not inside any one computer. Every computer created with --volume NAME:/path sees the same files at that path, so a parent can hand out work to many children and read their results as they finish, without copying anything.

Good to know

From code

// JavaScript
await wp.createVolume("job-1");
const parent = await wp.create("parent", { volumes: { "/shared": "job-1" } });
const kids = await Promise.all([1, 2, 3].map((i) =>
  wp.create(`child-${i}`, { volumes: { "/shared": "job-1" } })));
await Promise.all(kids.map((k, i) => k.exec(`echo result-${i} > /shared/child-${i}.txt`)));
console.log((await parent.exec("cat /shared/*.txt")).stdout);
await Promise.all(kids.map((k) => k.delete()));

# Python
wp.create_volume("job-1")
parent = wp.create("parent", volumes={"/shared": "job-1"})
child = wp.create("child-1", volumes={"/shared": "job-1"})
child.exec("echo done > /shared/child-1.txt")
print(parent.exec("cat /shared/child-1.txt").stdout)

wp.volumes() lists them and wp.deleteVolume(name) / wp.delete_volume(name) removes one. computer.volumes shows what a computer mounts.