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
- Mounts are set when a computer is created. A running computer can't add or change one. Create the volume first, then the computers that use it.
- One file per writer. Many computers writing different files works well. Many computers appending to the same file at once loses lines; give each its own file or folder, such as
/shared/child-7/. - Files appear when the writer closes them, not mid-write.
- Files outlive the computers. Delete every computer and the volume and its files remain. Stopping, starting and forking a computer keep its mounts.
- Delete a volume with
workpaper volume rm job-1once no computer mounts it. This removes its files for good. - Up to 10 volumes per account and 8 mounts per computer. Mount paths are absolute, such as
/sharedor/home/user/data, outside system folders. Volumes need an account and a full computer; they don't work with the free trial, Instant or the credential vault.
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.