Skip to content

Commit

Permalink
Fix issue #9: 'Make the codebase robust'
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Dec 11, 2024
1 parent b81e22a commit 3400a77
Showing 1 changed file with 67 additions and 7 deletions.
74 changes: 67 additions & 7 deletions openhands_resolver/resolve_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,14 +628,71 @@ async def resolve_issues(
logger.info(f"Using {num_workers} workers.")

resolverOutput = None
try:
async def resolve_issues_with_random_models(
...
):
try:
# Replace the ProcessPoolExecutor with asyncio.gather
sem = asyncio.Semaphore(num_workers)
tasks = []
for issue in issues:
# checkout to pr branch
if issue_type == "pr":
logger.info(f"Checking out to PR branch {issue.head_branch} for issue {issue.number}")

subprocess.check_output(
["git", "checkout", f"{issue.head_branch}"],
cwd=repo_dir,
)

base_commit = (
subprocess.check_output(
["git", "rev-parse", "HEAD"], cwd=repo_dir
)
.decode("utf-8")
.strip()
)

async def process_issue_with_semaphore(issue, base_commit, max_iterations, llm_config, output_dir, runtime_container_image, prompt_template, issue_handler, repo_instruction, bool_num_workers):
async with sem:
resolverOutput = await process_issue(
issue,
base_commit,
max_iterations,
llm_config,
output_dir,
runtime_container_image,
prompt_template,
issue_handler,
repo_instruction,
bool_num_workers,
)
await update_progress(
resolverOutput,
output_fp,
pbar,
)

task = asyncio.create_task(process_issue_with_semaphore(
issue,
base_commit,
max_iterations,
llm_config,
output_dir,
runtime_container_image,
prompt_template,
issue_handler,
repo_instruction,
bool(num_workers > 1),
))
tasks.append(task)
await asyncio.gather(*tasks)
except Exception as e:
# handle exception
pass


try:
# Replace the ProcessPoolExecutor with asyncio.gather
tasks = []
for issue in issues:

# checkout to pr branch
if issue_type == "pr":
logger.info(f"Checking out to PR branch {issue.head_branch} for issue {issue.number}")

subprocess.check_output(
Expand Down Expand Up @@ -888,3 +945,6 @@ def main():

if __name__ == "__main__":
main()



0 comments on commit 3400a77

Please sign in to comment.