from gravixlayer import GravixLayer, ForkError
client = GravixLayer() # defaults to cloud="aws", region="us-east-1"
sandbox = client.runtime.create() # defaults to template="base-small"
sandbox.file.write("/workspace/data.txt", "shared\n")
# Fork a running sandbox into 4 children
result = client.runtime.fork(sandbox.runtime_id, count=4)
for child in result.runtimes:
print(child.runtime_id, child.file.read("/workspace/data.txt").content)
child.kill()
for err in result.errors:
print("child failed:", err.code, err.error)
# Fork a saved snapshot instead — no capture, parent need not be alive
result = client.snapshots.fork("my-snapshot", count=3)