Skip to content

Commit eaa6e78

Browse files
run_single_file: pass pull request to prepare step
1 parent 61de911 commit eaa6e78

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

scripts/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Codex helper
22

3-
The `run_single_file.py` script runs Codex inside Docker on a single file from this repository. It builds both `private_mathlib4` and `formal_conjectures` before invoking Codex.
3+
The `run_single_file.py` script runs Codex inside Docker on a single file from this repository. It builds both `private_mathlib4` and `formal_conjectures` before invoking Codex. When using the `--prep` option you must also provide `--pr` so `prepare_single_file.py` can fetch review comments for that pull request.
44

55
Example:
66

77
```bash
88
GEMINI_API_KEY="" ./scripts/run_single_file.py \
99
--prep FormalConjectures/Paper/CasasAlvero.lean \
10+
--pr https://github.com/OWNER/REPO/pull/123 \
1011
--export FormalConjectures/Paper/CasasAlvero.lean \
1112
run --auto-continuous --auto-continuous-first-doc \
1213
"lake build FormalConjectures/Paper/CasasAlvero.lean"

scripts/run_single_file.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ def parse_args() -> argparse.Namespace:
1818
parser.add_argument("--image", default="codex_patched", help="Docker image tag")
1919
parser.add_argument("--name", help="Container name (default: script-<pid>)")
2020
parser.add_argument("--prep", help="Prepare a single Lean file")
21+
parser.add_argument(
22+
"--pr",
23+
dest="pull_request",
24+
help="GitHub pull request URL used when preparing a file",
25+
)
26+
parser.add_argument(
27+
"--gh-token",
28+
dest="github_token",
29+
default=None,
30+
help="GitHub token for API access when preparing a file",
31+
)
2132
parser.add_argument(
2233
"--export", action="append", default=[], help="Files to export from container"
2334
)
@@ -27,6 +38,8 @@ def parse_args() -> argparse.Namespace:
2738
args = parser.parse_args()
2839
if not args.cmd:
2940
parser.error("Need Codex command")
41+
if args.prep and not args.pull_request:
42+
parser.error("--prep requires --pr")
3043
return args
3144

3245

@@ -96,13 +109,18 @@ def main() -> int:
96109
)
97110

98111
if args.prep:
112+
prep_cmd = (
113+
f"python3 -m scripts.prepare_single_file --lean {shlex.quote(args.prep)} "
114+
f"--out tmp_prep --lean-explore-local --pr {shlex.quote(args.pull_request)}"
115+
)
116+
if args.github_token:
117+
prep_cmd += f" --gh-token {shlex.quote(args.github_token)}"
99118
docker(
100119
"exec",
101120
cid,
102121
"bash",
103122
"-euc",
104-
f"cd {repo} && "
105-
f"python3 -m scripts.prepare_single_file --lean {args.prep} --out tmp_prep --lean-explore-local && "
123+
f"cd {repo} && {prep_cmd} && "
106124
f"cp tmp_prep/AGENTS_single_task.md AGENTS.md && "
107125
f"cp tmp_prep/$(basename {args.prep}) {args.prep}",
108126
)

0 commit comments

Comments
 (0)