Answer principles round 2: 0 🔴, 2 🟡 (0 misread); workflow-bench hands its effects in as arguments, and no Python file of the repo patches a global
CI / tests (pull_request) Successful in 3m46s
CI / tests (pull_request) Successful in 3m46s
This commit is contained in:
+12
-10
@@ -14,6 +14,7 @@ other. The bench's inputs are untracked:
|
||||
Each run leaves its clone in <run>/, its report in <run>.md and its claude stream in logs/.
|
||||
"""
|
||||
import concurrent.futures
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
@@ -24,7 +25,6 @@ import time
|
||||
|
||||
BENCH = pathlib.Path(__file__).resolve().parent
|
||||
REVIEW_GIT = BENCH / "review_git.py"
|
||||
SOURCES = pathlib.Path(os.environ["BENCH_SOURCES"])
|
||||
CASES = {
|
||||
"cjk": ("151bf38^", "6c49912"),
|
||||
"35b": ("692433b", "1d369ec"),
|
||||
@@ -61,10 +61,10 @@ def git(repo, *args):
|
||||
return subprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, text=True).stdout.strip()
|
||||
|
||||
|
||||
def fresh_clone(case, dest):
|
||||
def fresh_clone(case, dest, sources):
|
||||
if dest.exists():
|
||||
shutil.rmtree(dest)
|
||||
source = SOURCES / f"{case}-main"
|
||||
source = sources / f"{case}-main"
|
||||
base_ref, head_ref = CASES[case]
|
||||
base = git(source, "rev-parse", base_ref)
|
||||
head = git(source, "rev-parse", head_ref)
|
||||
@@ -89,14 +89,15 @@ def rate_limit_reset(log):
|
||||
return max(resets)
|
||||
|
||||
|
||||
def run(name):
|
||||
def run(name, sources):
|
||||
"""One review run of <case>-<version>-<n>, whose case's clone is in the folder sources."""
|
||||
case, version, _ = name.split("-")
|
||||
clone = BENCH / name
|
||||
report = BENCH / f"{name}.md"
|
||||
for attempt in range(1, ATTEMPTS + 1):
|
||||
if report.exists():
|
||||
return f"{name}: done"
|
||||
base, head = fresh_clone(case, clone)
|
||||
base, head = fresh_clone(case, clone, sources)
|
||||
version_dir = BENCH / "versions" / version
|
||||
prompt = (BENCH / "run-prompt.md").read_text().format(
|
||||
version_dir=version_dir, base=base, head=head, case=case, report=report, review_git=REVIEW_GIT)
|
||||
@@ -113,19 +114,20 @@ def run(name):
|
||||
return f"{name}: FAILED after {ATTEMPTS} attempts"
|
||||
|
||||
|
||||
def attempted(name):
|
||||
"""run's result line, or a line naming the failure, so one failed run doesn't stop the other runs' results printing."""
|
||||
def attempted(name, run):
|
||||
"""run's result line for name, or a line naming the failure, so one failed run doesn't stop the other runs' results printing."""
|
||||
try:
|
||||
return run(name)
|
||||
except (KeyError, ValueError, subprocess.CalledProcessError, OSError) as failure:
|
||||
return f"{name}: FAILED: {type(failure).__name__}: {failure}"
|
||||
|
||||
|
||||
def main():
|
||||
def main(names, run):
|
||||
"""Prints the result line of each run named, which run makes."""
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool:
|
||||
for result in pool.map(attempted, sys.argv[1:]):
|
||||
for result in pool.map(lambda name: attempted(name, run), names):
|
||||
print(result, flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main(sys.argv[1:], functools.partial(run, sources=pathlib.Path(os.environ["BENCH_SOURCES"])))
|
||||
|
||||
Reference in New Issue
Block a user