Skip to content

Commit 723b377

Browse files
committed
more error messages
1 parent e5a341b commit 723b377

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

baselines/run_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def run_agent_for_repo(
7272
)
7373

7474
run_id = args2string(agent_config)
75-
print(run_id, file=sys.stderr)
75+
print(f"Agent is coding on branch: {run_id}", file=sys.stderr)
7676
create_branch(local_repo, run_id, example["base_commit"])
7777
latest_commit = local_repo.commit(run_id)
7878
# in cases where the latest commit of branch is not commit 0

commit0/__main__.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,24 @@ def main() -> None:
6565
repo = sys.argv[2]
6666
commit0.harness.get_pytest_ids.main(repo, stdout=True)
6767
elif command == "test" or command == "test-reference":
68-
if command == "test" and len(sys.argv) < 5:
69-
raise ValueError(f"An argument is missing for commit0 test.\nUsage: commit0 test {{repo_dir}} {{branch}} {{test_ids}}")
70-
elif command == "test" and len(sys.argv) > 5:
71-
raise ValueError(f"Too many arguments are passed to commit0 test.\nUsage: commit0 test {{repo_dir}} {{branch}} {{test_ids}}")
7268
# this command assume execution in arbitrary working directory
7369
repo_or_repo_path = sys.argv[2]
74-
branch = sys.argv[3]
75-
test_ids = sys.argv[4]
70+
if command == "test-reference":
71+
if len(sys.argv) < 4:
72+
raise ValueError(f"An argument is missing for commit0 test-reference.\nUsage: commit0 test-reference {{repo_dir}} {{test_ids}}")
73+
elif len(sys.argv) > 4:
74+
raise ValueError(f"Too many arguments are passed to commit0 test-reference.\nUsage: commit0 test-reference {{repo_dir}} {{test_ids}}")
75+
branch = "reference"
76+
test_ids = sys.argv[3]
77+
else:
78+
if len(sys.argv) < 5:
79+
raise ValueError(f"An argument is missing for commit0 test.\nUsage: commit0 test {{repo_dir}} {{branch}} {{test_ids}}")
80+
elif len(sys.argv) > 5:
81+
raise ValueError(f"Too many arguments are passed to commit0 test.\nUsage: commit0 test {{repo_dir}} {{branch}} {{test_ids}}")
82+
branch = sys.argv[3]
83+
test_ids = sys.argv[4]
7684
if branch.startswith("branch="):
7785
branch = branch[len("branch="):]
78-
if command == "test-reference":
79-
config.branch = "reference"
8086
commit0.harness.run_pytest_ids.main(
8187
config.dataset_name,
8288
config.dataset_split,
@@ -90,13 +96,17 @@ def main() -> None:
9096
stdout=True,
9197
)
9298
elif command == "evaluate" or command == "evaluate-reference":
93-
if command == "evaluate" and len(sys.argv) < 4:
94-
raise ValueError(f"An argument is missing for commit0 test.\nUsage: commit0 test {{repo_dir}} {{branch}} {{test_ids}}")
95-
elif command == "evaluate" and len(sys.argv) > 4:
96-
raise ValueError(f"Too many arguments are passed to commit0 test.\nUsage: commit0 test {{repo_dir}} {{branch}} {{test_ids}}")
9799
if command == "evaluate-reference":
100+
if len(sys.argv) < 3:
101+
raise ValueError(f"An argument is missing for commit0 evaluate-reference.\nUsage: commit0 evaluate-reference {{repo_split}}")
102+
elif len(sys.argv) > 3:
103+
raise ValueError(f"Too many arguments are passed to commit0 evaluate-reference.\nUsage: commit0 evaluate-reference {{repo_split}}")
98104
branch = "reference"
99105
else:
106+
if len(sys.argv) < 4:
107+
raise ValueError(f"An argument is missing for commit0 evaluate.\nUsage: commit0 evaluate {{repo_split}} {{branch}}")
108+
elif len(sys.argv) > 4:
109+
raise ValueError(f"Too many arguments are passed to commit0 evaluate.\nUsage: commit0 evaluate {{repo_split}} {{branch}}")
100110
branch = sys.argv[3]
101111
commit0.harness.evaluate.main(
102112
config.dataset_name,

commit0/harness/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from typing import Iterator
77
from commit0.harness.utils import (
88
clone_repo,
9-
create_branch,
109
)
1110
from commit0.harness.constants import RepoInstance, SPLIT
1211

0 commit comments

Comments
 (0)