kikocis/auto-code-rover public
Changesets · Branches · Tags · Compare
| Changeset | eba410d8d60724ebc33bf3206f7af31d3669cb3422b08f51ebfbe33e065991b1 |
|---|---|
| Author | Martin Mirchev <mmirchev@comp.nus.edu.sg> · 2024-06-08 18:13 +08:00 |
| Committer | Martin Mirchev <mmirchev@comp.nus.edu.sg> · 2024-06-08 18:13 +08:00 |
| Parents | b5e8b533440a |
12 files changed
modified app/analysis/sbfl.py +4 −8
| @@ -372,16 +372,14 @@ | ||
| 372 | 372 | ) |
| 373 | 373 | Path(log_file).write_text(cp.stdout) |
| 374 | 374 | except TimeoutExpired: |
| 375 | - log.log_and_print( | |
| 376 | - "Timeout expired while running the test suite.", | |
| 377 | - ) | |
| 375 | + log.log_and_print("Timeout expired while running the test suite.") | |
| 378 | 376 | return "", log_file |
| 379 | 377 | |
| 380 | 378 | # (3) check whether the coverage file is there |
| 381 | 379 | cov_file = pjoin(execution_dir, ".coverage") |
| 382 | 380 | if not os.path.exists(cov_file): |
| 383 | 381 | log.log_and_print( |
| 384 | - "Coverage file is not produced after running the test suite.", | |
| 382 | + "Coverage file is not produced after running the test suite." | |
| 385 | 383 | ) |
| 386 | 384 | return "", log_file |
| 387 | 385 | return cov_file, log_file |
| @@ -450,9 +448,7 @@ | ||
| 450 | 448 | Path(log_file).write_text(cp.stdout) |
| 451 | 449 | # Path(self.output_dir, "run_developer_tests.log").write_text(cp.stdout) |
| 452 | 450 | except TimeoutExpired: |
| 453 | - log.log_and_print( | |
| 454 | - "Timeout expired while running the test suite.", | |
| 455 | - ) | |
| 451 | + log.log_and_print("Timeout expired while running the test suite.") | |
| 456 | 452 | return "", log_file |
| 457 | 453 | |
| 458 | 454 | # (2) check whether the coverage file is there |
| @@ -469,7 +465,7 @@ | ||
| 469 | 465 | # now check again |
| 470 | 466 | if not os.path.exists(cov_file): |
| 471 | 467 | log.log_and_print( |
| 472 | - "Coverage file is not produced after running the test suite.", | |
| 468 | + "Coverage file is not produced after running the test suite." | |
| 473 | 469 | ) |
| 474 | 470 | return "", log_file |
| 475 | 471 | return cov_file, log_file |
modified app/api/eval_helper.py +4 −16
| @@ -269,14 +269,8 @@ | ||
| 269 | 269 | p2p_failure.append(test_case) |
| 270 | 270 | |
| 271 | 271 | results = { |
| 272 | - FAIL_TO_PASS: { | |
| 273 | - "success": f2p_success, | |
| 274 | - "failure": f2p_failure, | |
| 275 | - }, | |
| 276 | - PASS_TO_PASS: { | |
| 277 | - "success": p2p_success, | |
| 278 | - "failure": p2p_failure, | |
| 279 | - }, | |
| 272 | + FAIL_TO_PASS: {"success": f2p_success, "failure": f2p_failure}, | |
| 273 | + PASS_TO_PASS: {"success": p2p_success, "failure": p2p_failure}, | |
| 280 | 274 | } |
| 281 | 275 | |
| 282 | 276 | f2f_success = [] |
| @@ -300,14 +294,8 @@ | ||
| 300 | 294 | |
| 301 | 295 | results.update( |
| 302 | 296 | { |
| 303 | - FAIL_TO_FAIL: { | |
| 304 | - "success": f2f_success, | |
| 305 | - "failure": f2f_failure, | |
| 306 | - }, | |
| 307 | - PASS_TO_FAIL: { | |
| 308 | - "success": p2f_success, | |
| 309 | - "failure": p2f_failure, | |
| 310 | - }, | |
| 297 | + FAIL_TO_FAIL: {"success": f2f_success, "failure": f2f_failure}, | |
| 298 | + PASS_TO_FAIL: {"success": p2f_success, "failure": p2f_failure}, | |
| 311 | 299 | } |
| 312 | 300 | ) |
| 313 | 301 | return results |
modified app/inference.py +4 −13
| @@ -281,24 +281,15 @@ | ||
| 281 | 281 | found |= call_is_ok |
| 282 | 282 | |
| 283 | 283 | if (not found) and method_name and class_name: |
| 284 | - kwargs = { | |
| 285 | - "method_name": method_name, | |
| 286 | - "class_name": class_name, | |
| 287 | - } | |
| 284 | + kwargs = {"method_name": method_name, "class_name": class_name} | |
| 288 | 285 | call_function("search_method_in_class", kwargs) |
| 289 | 286 | |
| 290 | 287 | if (not found) and method_name and file_name: |
| 291 | - kwargs = { | |
| 292 | - "method_name": method_name, | |
| 293 | - "file_name": file_name, | |
| 294 | - } | |
| 288 | + kwargs = {"method_name": method_name, "file_name": file_name} | |
| 295 | 289 | call_function("search_method_in_file", kwargs) |
| 296 | 290 | |
| 297 | 291 | if (not found) and class_name and file_name: |
| 298 | - kwargs = { | |
| 299 | - "class_name": class_name, | |
| 300 | - "file_name": file_name, | |
| 301 | - } | |
| 292 | + kwargs = {"class_name": class_name, "file_name": file_name} | |
| 302 | 293 | call_function("search_class_in_file", kwargs) |
| 303 | 294 | |
| 304 | 295 | if (not found) and class_name: |
| @@ -367,7 +358,7 @@ | ||
| 367 | 358 | # good case in which we can check function call |
| 368 | 359 | func_call_intent: FunctionCallIntent = func_call_intents[0] |
| 369 | 360 | log_and_print( |
| 370 | - f"{colored('This round model response (function call):', 'blue')} {func_call_intent}", | |
| 361 | + f"{colored('This round model response (function call):', 'blue')} {func_call_intent}" | |
| 371 | 362 | ) |
| 372 | 363 | # dispatch this function call |
| 373 | 364 | this_model_response = res_text |
modified app/log.py +4 −20
| @@ -74,11 +74,7 @@ | ||
| 74 | 74 | title = name |
| 75 | 75 | |
| 76 | 76 | panel = Panel( |
| 77 | - markdown, | |
| 78 | - title=title, | |
| 79 | - title_align="left", | |
| 80 | - border_style="magenta", | |
| 81 | - width=WIDTH, | |
| 77 | + markdown, title=title, title_align="left", border_style="magenta", width=WIDTH | |
| 82 | 78 | ) |
| 83 | 79 | console.print(panel) |
| 84 | 80 | |
| @@ -104,11 +100,7 @@ | ||
| 104 | 100 | title = name |
| 105 | 101 | |
| 106 | 102 | panel = Panel( |
| 107 | - markdown, | |
| 108 | - title=title, | |
| 109 | - title_align="left", | |
| 110 | - border_style="blue", | |
| 111 | - width=WIDTH, | |
| 103 | + markdown, title=title, title_align="left", border_style="blue", width=WIDTH | |
| 112 | 104 | ) |
| 113 | 105 | console.print(panel) |
| 114 | 106 | if print_callback: |
| @@ -137,11 +129,7 @@ | ||
| 137 | 129 | title = name |
| 138 | 130 | |
| 139 | 131 | panel = Panel( |
| 140 | - markdown, | |
| 141 | - title=title, | |
| 142 | - title_align="left", | |
| 143 | - border_style="yellow", | |
| 144 | - width=WIDTH, | |
| 132 | + markdown, title=title, title_align="left", border_style="yellow", width=WIDTH | |
| 145 | 133 | ) |
| 146 | 134 | console.print(panel) |
| 147 | 135 | if print_callback: |
| @@ -160,11 +148,7 @@ | ||
| 160 | 148 | |
| 161 | 149 | title = "Issue description" |
| 162 | 150 | panel = Panel( |
| 163 | - content, | |
| 164 | - title=title, | |
| 165 | - title_align="left", | |
| 166 | - border_style="red", | |
| 167 | - width=WIDTH, | |
| 151 | + content, title=title, title_align="left", border_style="red", width=WIDTH | |
| 168 | 152 | ) |
| 169 | 153 | console.print(panel) |
| 170 | 154 |
modified app/main.py +9 −31
| @@ -40,8 +40,7 @@ | ||
| 40 | 40 | set_swe_parser_args(swe_parser) |
| 41 | 41 | |
| 42 | 42 | github_parser = subparsers.add_parser( |
| 43 | - "github-issue", | |
| 44 | - help="Run an online github issue", | |
| 43 | + "github-issue", help="Run an online github issue" | |
| 45 | 44 | ) |
| 46 | 45 | set_github_parser_args(github_parser) |
| 47 | 46 | |
| @@ -104,11 +103,7 @@ | ||
| 104 | 103 | setup_dir = abspath(setup_dir) |
| 105 | 104 | |
| 106 | 105 | task = RawGithubTask( |
| 107 | - args.task_id, | |
| 108 | - args.clone_link, | |
| 109 | - args.commit_hash, | |
| 110 | - args.issue_link, | |
| 111 | - setup_dir, | |
| 106 | + args.task_id, args.clone_link, args.commit_hash, args.issue_link, setup_dir | |
| 112 | 107 | ) |
| 113 | 108 | groups = {"github": [task]} |
| 114 | 109 | run_task_groups(groups, num_processes) |
| @@ -119,11 +114,7 @@ | ||
| 119 | 114 | issue_file = args.issue_file |
| 120 | 115 | if issue_file is not None: |
| 121 | 116 | issue_file = abspath(issue_file) |
| 122 | - task = RawLocalTask( | |
| 123 | - args.task_id, | |
| 124 | - local_repo, | |
| 125 | - issue_file, | |
| 126 | - ) | |
| 117 | + task = RawLocalTask(args.task_id, local_repo, issue_file) | |
| 127 | 118 | groups = {"local": [task]} |
| 128 | 119 | run_task_groups(groups, num_processes) |
| 129 | 120 | elif subcommand == "extract-patches": |
| @@ -156,14 +147,10 @@ | ||
| 156 | 147 | def set_github_parser_args(parser: ArgumentParser) -> None: |
| 157 | 148 | add_task_related_args(parser) |
| 158 | 149 | parser.add_argument( |
| 159 | - "--task-id", | |
| 160 | - type=str, | |
| 161 | - help="Assign an id to the current fresh issue task.", | |
| 150 | + "--task-id", type=str, help="Assign an id to the current fresh issue task." | |
| 162 | 151 | ) |
| 163 | 152 | parser.add_argument( |
| 164 | - "--clone-link", | |
| 165 | - type=str, | |
| 166 | - help="The link to the repository to clone.", | |
| 153 | + "--clone-link", type=str, help="The link to the repository to clone." | |
| 167 | 154 | ) |
| 168 | 155 | parser.add_argument("--commit-hash", type=str, help="The commit hash to checkout.") |
| 169 | 156 | parser.add_argument("--issue-link", type=str, help="The link to the issue.") |
| @@ -370,17 +357,14 @@ | ||
| 370 | 357 | |
| 371 | 358 | |
| 372 | 359 | def run_task_groups_parallel( |
| 373 | - task_groups: Mapping[str, Sequence[RawTask]], | |
| 374 | - num_processes: int, | |
| 360 | + task_groups: Mapping[str, Sequence[RawTask]], num_processes: int | |
| 375 | 361 | ): |
| 376 | 362 | num_task_groups = len(task_groups) |
| 377 | 363 | globals_mut.init_total_num_task_groups(num_task_groups) |
| 378 | 364 | num_processes = min(num_processes, num_task_groups) |
| 379 | 365 | |
| 380 | 366 | task_group_ids_items = sorted( |
| 381 | - task_groups.items(), | |
| 382 | - key=lambda x: len(x[1]), | |
| 383 | - reverse=True, | |
| 367 | + task_groups.items(), key=lambda x: len(x[1]), reverse=True | |
| 384 | 368 | ) |
| 385 | 369 | log.print_with_time(f"Sorted task groups: {[x[0] for x in task_group_ids_items]}") |
| 386 | 370 | try: |
| @@ -437,9 +421,7 @@ | ||
| 437 | 421 | |
| 438 | 422 | task.dump_meta_data(task_output_dir) |
| 439 | 423 | |
| 440 | - log.log_and_always_print( | |
| 441 | - f"============= Running task {task_id} =============", | |
| 442 | - ) | |
| 424 | + log.log_and_always_print(f"============= Running task {task_id} =============") | |
| 443 | 425 | |
| 444 | 426 | run_ok = False |
| 445 | 427 | |
| @@ -516,11 +498,7 @@ | ||
| 516 | 498 | return run_ok |
| 517 | 499 | |
| 518 | 500 | |
| 519 | -def dump_cost( | |
| 520 | - start_time: datetime, | |
| 521 | - end_time: datetime, | |
| 522 | - task_output_dir: str, | |
| 523 | -): | |
| 501 | +def dump_cost(start_time: datetime, end_time: datetime, task_output_dir: str): | |
| 524 | 502 | model_stats = common.SELECTED_MODEL.get_overall_exec_stats() |
| 525 | 503 | stats = { |
| 526 | 504 | "commit": apputils.get_current_commit_hash(), |
modified app/model/bedrock.py +27 −9
| @@ -4,7 +4,6 @@ | ||
| 4 | 4 | |
| 5 | 5 | import os |
| 6 | 6 | import sys |
| 7 | - | |
| 8 | 7 | from typing import Literal |
| 9 | 8 | |
| 10 | 9 | import litellm |
| @@ -42,7 +41,7 @@ | ||
| 42 | 41 | super().__init__(name, cost_per_input, cost_per_output, parallel_tool_call) |
| 43 | 42 | self._model_provider = self.name.split(".")[0] |
| 44 | 43 | self._initialized = True |
| 45 | - | |
| 44 | + | |
| 46 | 45 | def setup(self) -> None: |
| 47 | 46 | """ |
| 48 | 47 | Check API key. |
| @@ -54,10 +53,14 @@ | ||
| 54 | 53 | required_env_vars = [ |
| 55 | 54 | "AWS_ACCESS_KEY_ID", |
| 56 | 55 | "AWS_SECRET_ACCESS_KEY", |
| 57 | - "AWS_REGION_NAME" | |
| 56 | + "AWS_REGION_NAME", | |
| 58 | 57 | ] |
| 59 | - if len(set(os.environ).intersection(required_env_vars)) != len(required_env_vars): | |
| 60 | - print(f"Missing env vars. Please refer to https://litellm.vercel.app/docs/providers/bedrock") | |
| 58 | + if len(set(os.environ).intersection(required_env_vars)) != len( | |
| 59 | + required_env_vars | |
| 60 | + ): | |
| 61 | + print( | |
| 62 | + "Missing env vars. Please refer to https://litellm.vercel.app/docs/providers/bedrock" | |
| 63 | + ) | |
| 61 | 64 | sys.exit(1) |
| 62 | 65 | return os.getenv(required_env_vars[-1]) |
| 63 | 66 | |
| @@ -122,16 +125,25 @@ | ||
| 122 | 125 | log_and_print("Context length exceeded") |
| 123 | 126 | raise e |
| 124 | 127 | |
| 128 | + | |
| 125 | 129 | class AnthropicClaude2(BedrockModel): |
| 126 | 130 | def __init__(self): |
| 127 | - super().__init__("bedrock/anthropic.claude-v2:1", 0.00000025, 0.00000125,parallel_tool_call= True) | |
| 131 | + super().__init__( | |
| 132 | + "bedrock/anthropic.claude-v2:1", | |
| 133 | + 0.00000025, | |
| 134 | + 0.00000125, | |
| 135 | + parallel_tool_call=True, | |
| 136 | + ) | |
| 128 | 137 | self.note = "Older Claude model" |
| 129 | 138 | |
| 130 | 139 | |
| 131 | 140 | class AnthropicClaude3Opus(BedrockModel): |
| 132 | 141 | def __init__(self): |
| 133 | 142 | super().__init__( |
| 134 | - "bedrock/anthropic.claude-3-opus-20240229-v1:0", 0.000015, 0.000075, parallel_tool_call=True | |
| 143 | + "bedrock/anthropic.claude-3-opus-20240229-v1:0", | |
| 144 | + 0.000015, | |
| 145 | + 0.000075, | |
| 146 | + parallel_tool_call=True, | |
| 135 | 147 | ) |
| 136 | 148 | self.note = "Most powerful model from Antropic" |
| 137 | 149 | |
| @@ -139,7 +151,10 @@ | ||
| 139 | 151 | class AnthropicClaude3Sonnet(BedrockModel): |
| 140 | 152 | def __init__(self): |
| 141 | 153 | super().__init__( |
| 142 | - "bedrock/anthropic.claude-3-sonnet-20240229-v1:0", 0.000003, 0.000015, parallel_tool_call=True | |
| 154 | + "bedrock/anthropic.claude-3-sonnet-20240229-v1:0", | |
| 155 | + 0.000003, | |
| 156 | + 0.000015, | |
| 157 | + parallel_tool_call=True, | |
| 143 | 158 | ) |
| 144 | 159 | self.note = "Most balanced (intelligence and speed) model from Antropic" |
| 145 | 160 | |
| @@ -147,6 +162,9 @@ | ||
| 147 | 162 | class AnthropicClaude3Haiku(BedrockModel): |
| 148 | 163 | def __init__(self): |
| 149 | 164 | super().__init__( |
| 150 | - "bedrock/anthropic.claude-3-haiku-20240307-v1:0", 0.00000025, 0.00000125, parallel_tool_call=True | |
| 165 | + "bedrock/anthropic.claude-3-haiku-20240307-v1:0", | |
| 166 | + 0.00000025, | |
| 167 | + 0.00000125, | |
| 168 | + parallel_tool_call=True, | |
| 151 | 169 | ) |
| 152 | 170 | self.note = "Fastest model from Antropic" |
modified app/model/gpt.py +1 −2
| @@ -84,8 +84,7 @@ | ||
| 84 | 84 | return content |
| 85 | 85 | |
| 86 | 86 | def extract_resp_func_calls( |
| 87 | - self, | |
| 88 | - chat_completion_message: ChatCompletionMessage, | |
| 87 | + self, chat_completion_message: ChatCompletionMessage | |
| 89 | 88 | ) -> list[FunctionCallIntent]: |
| 90 | 89 | """ |
| 91 | 90 | Given a chat completion message, extract the function calls from it. |
modified app/model/ollama.py +1 −4
| @@ -119,10 +119,7 @@ | ||
| 119 | 119 | assert self.client is not None |
| 120 | 120 | try: |
| 121 | 121 | # build up options for ollama |
| 122 | - options = { | |
| 123 | - "temperature": common.MODEL_TEMP, | |
| 124 | - "top_p": top_p, | |
| 125 | - } | |
| 122 | + options = {"temperature": common.MODEL_TEMP, "top_p": top_p} | |
| 126 | 123 | if response_format == "json_object": |
| 127 | 124 | # additional instructions for json mode |
| 128 | 125 | json_instruction = { |
modified app/model/register.py +1 −1
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | common.register_model(claude.Claude3Opus()) |
| 19 | 19 | common.register_model(claude.Claude3Sonnet()) |
| 20 | 20 | common.register_model(claude.Claude3Haiku()) |
| 21 | - | |
| 21 | + | |
| 22 | 22 | common.register_model(bedrock.AnthropicClaude3Opus()) |
| 23 | 23 | common.register_model(bedrock.AnthropicClaude3Sonnet()) |
| 24 | 24 | common.register_model(bedrock.AnthropicClaude3Haiku()) |
modified app/raw_tasks.py +2 −6
| @@ -126,9 +126,7 @@ | ||
| 126 | 126 | "problem_statement": self.problem_statement, |
| 127 | 127 | "instance_id": self.task_id, |
| 128 | 128 | }, |
| 129 | - "setup_info": { | |
| 130 | - "repo_path": self.clone_path, | |
| 131 | - }, | |
| 129 | + "setup_info": {"repo_path": self.clone_path}, | |
| 132 | 130 | } |
| 133 | 131 | |
| 134 | 132 | meta_file = pjoin(output_dir, "meta.json") |
| @@ -221,9 +219,7 @@ | ||
| 221 | 219 | "problem_statement": self.problem_statement, |
| 222 | 220 | "instance_id": self.task_id, |
| 223 | 221 | }, |
| 224 | - "setup_info": { | |
| 225 | - "repo_path": self.local_repo, | |
| 226 | - }, | |
| 222 | + "setup_info": {"repo_path": self.local_repo}, | |
| 227 | 223 | } |
| 228 | 224 | |
| 229 | 225 | meta_file = pjoin(output_dir, "meta.json") |
modified app/task.py +3 −9
| @@ -128,10 +128,7 @@ | ||
| 128 | 128 | |
| 129 | 129 | # (2) install |
| 130 | 130 | cp = apputils.run_string_cmd_in_conda( |
| 131 | - task.install_cmd, | |
| 132 | - task.env_name, | |
| 133 | - capture_output=True, | |
| 134 | - text=True, | |
| 131 | + task.install_cmd, task.env_name, capture_output=True, text=True | |
| 135 | 132 | ) |
| 136 | 133 | if cp.returncode != 0: |
| 137 | 134 | log_and_print(cp.stderr) |
| @@ -141,10 +138,7 @@ | ||
| 141 | 138 | "python -m pip install xmlrunner coverage pytest pytest-cov" |
| 142 | 139 | ) |
| 143 | 140 | cp = apputils.run_string_cmd_in_conda( |
| 144 | - other_install_cmd, | |
| 145 | - task.env_name, | |
| 146 | - capture_output=True, | |
| 147 | - text=True, | |
| 141 | + other_install_cmd, task.env_name, capture_output=True, text=True | |
| 148 | 142 | ) |
| 149 | 143 | if cp.returncode != 0: |
| 150 | 144 | log_and_print(cp.stderr) |
| @@ -195,7 +189,7 @@ | ||
| 195 | 189 | app_utils.repo_clean_changes() |
| 196 | 190 | |
| 197 | 191 | log_and_print( |
| 198 | - f"[Validation] Finishing. Result is {tests_passed}. Message: {msg}.", | |
| 192 | + f"[Validation] Finishing. Result is {tests_passed}. Message: {msg}." | |
| 199 | 193 | ) |
| 200 | 194 | return tests_passed, msg, log_file |
| 201 | 195 |
modified app/utils.py +3 −5
| @@ -156,9 +156,7 @@ | ||
| 156 | 156 | submodule_unbind_cmd = ["git", "submodule", "deinit", "-f", "."] |
| 157 | 157 | submodule_init_cmd = ["git", "submodule", "update", "--init"] |
| 158 | 158 | run_command( |
| 159 | - submodule_unbind_cmd, | |
| 160 | - stdout=subprocess.DEVNULL, | |
| 161 | - stderr=subprocess.DEVNULL, | |
| 159 | + submodule_unbind_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL | |
| 162 | 160 | ) |
| 163 | 161 | run_command( |
| 164 | 162 | submodule_init_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL |
| @@ -302,11 +300,11 @@ | ||
| 302 | 300 | log_and_print( |
| 303 | 301 | f"Refactored invocation argument parsing gives different result on " |
| 304 | 302 | f"{invocation_str!r}: old result is {arguments!r}, new result " |
| 305 | - f" is {new_arguments!r}", | |
| 303 | + f" is {new_arguments!r}" | |
| 306 | 304 | ) |
| 307 | 305 | except Exception as e: |
| 308 | 306 | log_and_print( |
| 309 | - f"Refactored invocation argument parsing failed on {invocation_str!r}: {e!s}", | |
| 307 | + f"Refactored invocation argument parsing failed on {invocation_str!r}: {e!s}" | |
| 310 | 308 | ) |
| 311 | 309 | except Exception as e: |
| 312 | 310 | raise ValueError(f"Invalid function invocation: {invocation_str}") from e |