fork.py
Fork a running sandbox and show the two diverge.
import osfrom upstream import Upstream client = Upstream(api_key=os.environ["UPSTREAM_API_KEY"]) with client.sandbox(template="python") as base: base.write_file("/workspace/state.txt", "prepared") child = base.fork() child.write_file("/workspace/state.txt", "changed in the fork") print(base.read_file_text("/workspace/state.txt")) # prepared print(child.read_file_text("/workspace/state.txt")) # changed in the fork child.destroy()