kikocis/auto-code-rover public
Changesets · Branches · Tags · Compare
| Changeset | 645e8ae0bdf2c9a2aa08e07758959c1b6b83cdbc47d0ba7eb78de700120a7d5b |
|---|---|
| Author | Martin Mirchev <mirchevmartin2203@gmail.com> · 2024-07-18 12:59 +08:00 |
| Committer | Martin Mirchev <mirchevmartin2203@gmail.com> · 2024-07-18 13:49 +08:00 |
| Parents | 61cc3168abed |
3 files changed
modified app/globals.py +6 −0
| @@ -29,3 +29,9 @@ | ||
| 29 | 29 | |
| 30 | 30 | # timeout for test cmd execution, currently set to 5 min |
| 31 | 31 | test_exec_timeout: int = 300 |
| 32 | + | |
| 33 | +# A special mode to only collect fix locations and exit | |
| 34 | +disable_patch_generation: bool = False | |
| 35 | + | |
| 36 | +# Used with disable_patch_generation - constrains or extends the amount of context retrieval rounds | |
| 37 | +context_generation_limit: int = -1 |
modified app/inference.py +26 −13
| @@ -93,7 +93,15 @@ | ||
| 93 | 93 | msg_thread.add_user(prompt) |
| 94 | 94 | |
| 95 | 95 | round_no = start_round_no |
| 96 | - for round_no in range(start_round_no, globals.conv_round_limit + 1): | |
| 96 | + | |
| 97 | + round_count = range(start_round_no, globals.conv_round_limit + 1) | |
| 98 | + | |
| 99 | + if globals.disable_patch_generation: | |
| 100 | + round_count = range( | |
| 101 | + start_round_no, start_round_no + globals.context_generation_limit + 1 | |
| 102 | + ) | |
| 103 | + | |
| 104 | + for round_no in round_count: | |
| 97 | 105 | api_manager.start_new_tool_call_layer() |
| 98 | 106 | |
| 99 | 107 | conversation_file = pjoin(output_dir, f"conversation_round_{round_no}.json") |
| @@ -167,13 +175,17 @@ | ||
| 167 | 175 | ): |
| 168 | 176 | msg_thread.add_user(collated_tool_response) |
| 169 | 177 | |
| 170 | - print_banner("PATCH GENERATION") | |
| 171 | - logger.debug("Gathered enough information. Invoking write_patch.") | |
| 172 | - print_acr( | |
| 173 | - collated_tool_response, | |
| 174 | - "patch generation round 1", | |
| 175 | - print_callback=print_callback, | |
| 176 | - ) | |
| 178 | + if globals.disable_patch_generation: | |
| 179 | + logger.debug("Gathered enough information. Skipping patch generation due to feature flag.") | |
| 180 | + Path(output_dir, "fix_locations.json").write_text(json.dumps(buggy_locations, indent=4)) | |
| 181 | + else: | |
| 182 | + print_banner("PATCH GENERATION") | |
| 183 | + logger.debug("Gathered enough information. Invoking write_patch.") | |
| 184 | + print_acr( | |
| 185 | + collated_tool_response, | |
| 186 | + "patch generation round 1", | |
| 187 | + print_callback=print_callback, | |
| 188 | + ) | |
| 177 | 189 | break |
| 178 | 190 | |
| 179 | 191 | msg = "The buggy locations is not precise. You may need to check whether the arguments are correct and search more information." |
| @@ -242,12 +254,13 @@ | ||
| 242 | 254 | |
| 243 | 255 | round_no += 1 |
| 244 | 256 | |
| 245 | - api_manager.start_new_tool_call_layer() | |
| 257 | + if not globals.disable_patch_generation: | |
| 258 | + api_manager.start_new_tool_call_layer() | |
| 246 | 259 | |
| 247 | - write_patch_intent = FunctionCallIntent("write_patch", {}, None) | |
| 248 | - api_manager.dispatch_intent( | |
| 249 | - write_patch_intent, msg_thread, print_callback=print_callback | |
| 250 | - ) | |
| 260 | + write_patch_intent = FunctionCallIntent("write_patch", {}, None) | |
| 261 | + api_manager.dispatch_intent( | |
| 262 | + write_patch_intent, msg_thread, print_callback=print_callback | |
| 263 | + ) | |
| 251 | 264 | |
| 252 | 265 | conversation_file = pjoin(output_dir, f"conversation_round_{round_no}.json") |
| 253 | 266 | msg_thread.save_to_file(conversation_file) |
modified app/main.py +31 −8
| @@ -88,6 +88,8 @@ | ||
| 88 | 88 | globals.enable_angelic = args.enable_angelic |
| 89 | 89 | globals.enable_perfect_angelic = args.enable_perfect_angelic |
| 90 | 90 | globals.only_save_sbfl_result = args.save_sbfl_result |
| 91 | + globals.disable_patch_generation = args.output_fix_locs | |
| 92 | + globals.context_generation_limit = args.output_fix_limit | |
| 91 | 93 | |
| 92 | 94 | subcommand = getattr(args, subparser_dest_attr_name) |
| 93 | 95 | if subcommand == "swe-bench": |
| @@ -242,6 +244,20 @@ | ||
| 242 | 244 | default=1, |
| 243 | 245 | help="Number of processes to run the tasks in parallel.", |
| 244 | 246 | ) |
| 247 | + parser.add_argument( | |
| 248 | + "--output-fix-locs", | |
| 249 | + action="store_true", | |
| 250 | + required=False, | |
| 251 | + default=False, | |
| 252 | + help="Output fix locations to file and do not repair.", | |
| 253 | + ) | |
| 254 | + parser.add_argument( | |
| 255 | + "--output-fix-limit", | |
| 256 | + type=int, | |
| 257 | + required=False, | |
| 258 | + default=10, | |
| 259 | + help="Limit output of content retrieval rounds", | |
| 260 | + ) | |
| 245 | 261 | |
| 246 | 262 | |
| 247 | 263 | def make_swe_tasks( |
| @@ -438,18 +454,25 @@ | ||
| 438 | 454 | |
| 439 | 455 | log.log_and_always_print(run_status_message) |
| 440 | 456 | |
| 441 | - final_patch_path = get_final_patch_path(task_output_dir) | |
| 442 | - if final_patch_path is not None: | |
| 457 | + if globals.disable_patch_generation: | |
| 443 | 458 | log.log_and_always_print( |
| 444 | - f"Please find the generated patch at: {final_patch_path}" | |
| 459 | + f"Patch generation is disabled. Please find fix locations at: {task_output_dir}/fix_locations.json" | |
| 445 | 460 | ) |
| 446 | - if isinstance(task, RawSweTask): | |
| 461 | + else: | |
| 462 | + final_patch_path = get_final_patch_path(task_output_dir) | |
| 463 | + if final_patch_path is not None: | |
| 447 | 464 | log.log_and_always_print( |
| 448 | - "[SWE-bench mode] Note that the patch may be move to other paths in SWE-bench mode. " | |
| 449 | - "Please check the SWE-bench input file containing generated patches for all tasks." | |
| 465 | + f"Please find the generated patch at: {final_patch_path}" | |
| 466 | + ) | |
| 467 | + if isinstance(task, RawSweTask): | |
| 468 | + log.log_and_always_print( | |
| 469 | + "[SWE-bench mode] Note that the patch may be move to other paths in SWE-bench mode. " | |
| 470 | + "Please check the SWE-bench input file containing generated patches for all tasks." | |
| 471 | + ) | |
| 472 | + else: | |
| 473 | + log.log_and_always_print( | |
| 474 | + "No patch generated. You can try running ACR again." | |
| 450 | 475 | ) |
| 451 | - else: | |
| 452 | - log.log_and_always_print("No patch generated. You can try running ACR again.") | |
| 453 | 476 | |
| 454 | 477 | return run_ok |
| 455 | 478 |