Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/commit0/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def evaluate_instance(

def main() -> None:
prompt_dir = (Path(__file__).parent / "prompts").resolve()
choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")]
choices = [str(p) for p in prompt_dir.glob("*.j2")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Nit - Code Duplication: This exact pattern (prompt directory setup + choices list + argparse) appears identically in all 6 benchmark files. Consider extracting to benchmarks/utils/prompts.py:

def get_prompt_arg_parser(script_file: Path) -> tuple[list[str], Path]:
    """Get prompt choices and default path for argparse."""
    prompt_dir = (script_file.parent / "prompts").resolve()
    choices = [p.name for p in prompt_dir.glob("*.j2")]
    default = prompt_dir / "default.j2"
    assert default.exists(), f"Default prompt {default} not found"
    return choices, default

Not critical for this PR, but would make the next fix easier (you'd update one place instead of six).

default_prompt_path = prompt_dir / "default.j2"
assert default_prompt_path.exists(), (
f"Default prompt {default_prompt_path} not found"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/multiswebench/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def evaluate_instance(

def main() -> None:
prompt_dir = (Path(__file__).parent / "prompts").resolve()
choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")]
choices = [str(p) for p in prompt_dir.glob("*.j2")]
default_prompt_path = prompt_dir / "default.j2"
assert default_prompt_path.exists(), (
f"Default prompt {default_prompt_path} not found"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/swebench/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def evaluate_instance(

def main() -> None:
prompt_dir = (Path(__file__).parent / "prompts").resolve()
choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")]
choices = [str(p) for p in prompt_dir.glob("*.j2")]
Comment thread
simonrosenberg marked this conversation as resolved.
Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Code Smell: This identical change in 6 files suggests you could extract get_prompt_choices(prompt_dir) to a shared utility in benchmarks/utils/. Not critical, but reduces duplication and makes future fixes easier.

default_prompt_path = prompt_dir / "default.j2"
assert default_prompt_path.exists(), (
f"Default prompt {default_prompt_path} not found"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/swebenchmultimodal/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def evaluate_instance(

def main() -> None:
prompt_dir = (Path(__file__).parent / "prompts").resolve()
choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")]
choices = [str(p) for p in prompt_dir.glob("*.j2")]
default_prompt_path = prompt_dir / "default.j2"
assert default_prompt_path.exists(), (
f"Default prompt {default_prompt_path} not found"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/swefficiency/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def evaluate_instance(

def main() -> None:
prompt_dir = (Path(__file__).parent / "prompts").resolve()
choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")]
choices = [str(p) for p in prompt_dir.glob("*.j2")]
default_prompt_path = prompt_dir / "default.j2"
assert default_prompt_path.exists(), (
f"Default prompt {default_prompt_path} not found"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/swtbench/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def evaluate_instance(
def main() -> None:
"""Main entry point for SWT-bench evaluation."""
prompt_dir = (Path(__file__).parent / "prompts").resolve()
choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")]
choices = [str(p) for p in prompt_dir.glob("*.j2")]
default_prompt_path = prompt_dir / "default.j2"
assert default_prompt_path.exists(), (
f"Default prompt {default_prompt_path} not found"
Expand Down
Loading