fork_and_test.py
Prepare a repo once, then test one candidate fix per fork.
import osfrom upstream import Upstream REPO = "https://github.com/you/app"SETUP = f"git clone {REPO} app && cd app && uv sync"TEST = "cd app && git apply fix.patch && uv run pytest -q" client = Upstream(api_key=os.environ["UPSTREAM_API_KEY"]) def try_fixes(patches): with client.sandbox(template="python") as base: base.exec(["sh", "-c", SETUP]) # one prepared machine, one fork per candidate fix forks = [base.fork() for _ in patches] for sb, patch in zip(forks, patches): sb.write_file("/workspace/app/fix.patch", patch) r = sb.exec(["sh", "-c", TEST]) print(sb.sandbox_id, "pass" if r.exit_code == 0 else "fail") sb.destroy()