Skip to content

Commit

Permalink
Upgrade to OpenHands 0.9.3 (#51)
Browse files Browse the repository at this point in the history
* Upgrade to OpenHands 0.9.3

* Update

* Update to fix errors
  • Loading branch information
neubig authored Sep 16, 2024
1 parent 6275aa9 commit b95a560
Show file tree
Hide file tree
Showing 6 changed files with 1,209 additions and 985 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__
output/
.vscode
archive/
.mypy_cache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is a node repo for an RSS parser.
- Setup: `npm install`
- Testing: `npm test`
- Setup: `yes | npm install`
- Testing: `SKIP_BROWSER_TESTS=1 npm test`
- Writing Tests: Add to the `test` directory.
35 changes: 18 additions & 17 deletions github_resolver/resolve_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_git_patch(
return git_id, patch_content


async def initialize_runtime(
def initialize_runtime(
runtime: Runtime,
):
"""Initialize the runtime for the agent.
Expand All @@ -101,7 +101,7 @@ async def initialize_runtime(

action = CmdRunAction(command='cd /workspace')
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
if not isinstance(obs, CmdOutputObservation) or obs.exit_code != 0:
raise RuntimeError(
Expand All @@ -110,7 +110,7 @@ async def initialize_runtime(

action = CmdRunAction(command='git config --global core.pager ""')
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
if not isinstance(obs, CmdOutputObservation) or obs.exit_code != 0:
raise RuntimeError(f"Failed to set git config.\n{obs}")
Expand All @@ -129,37 +129,37 @@ async def complete_runtime(
logger.info('-' * 30)
logger.info('BEGIN Runtime Completion Fn')
logger.info('-' * 30)
obs: CmdOutputObservation
obs: Observation

action = CmdRunAction(command='cd /workspace')
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
if not isinstance(obs, CmdOutputObservation) or obs.exit_code != 0:
raise RuntimeError(
f"Failed to change directory to /workspace. Exit code: {obs.exit_code}"
f"Failed to change directory to /workspace. Observation: {obs}"
)

action = CmdRunAction(command='git config --global core.pager ""')
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
if not isinstance(obs, CmdOutputObservation) or obs.exit_code != 0:
raise RuntimeError(f"Failed to set git config. Exit code: {obs.exit_code}")
raise RuntimeError(f"Failed to set git config. Observation: {obs}")

action = CmdRunAction(command='git config --global --add safe.directory /workspace')
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
if not isinstance(obs, CmdOutputObservation) or obs.exit_code != 0:
raise RuntimeError(f"Failed to set git config. Exit code: {obs.exit_code}")
raise RuntimeError(f"Failed to set git config. Observation: {obs}")

action = CmdRunAction(command='git add -A')
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
if not isinstance(obs, CmdOutputObservation) or obs.exit_code != 0:
raise RuntimeError(f"Failed to git add. Exit code: {obs.exit_code}")
raise RuntimeError(f"Failed to git add. Observation: {obs}")

n_retries = 0
git_patch = None
Expand All @@ -170,7 +170,7 @@ async def complete_runtime(
)
action.timeout = 600 + 100 * n_retries
logger.info(action, extra={'msg_type': 'ACTION'})
obs = await runtime.run_action(action)
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
n_retries += 1
if isinstance(obs, CmdOutputObservation):
Expand Down Expand Up @@ -268,7 +268,7 @@ async def process_issue(
max_iterations=max_iterations,
sandbox=SandboxConfig(
runtime_container_image=runtime_container_image,
enable_auto_lint=True,
enable_auto_lint=False,
use_host_network=False,
# large enough timeout, since some testcases take very long to run
timeout=300,
Expand All @@ -279,8 +279,8 @@ async def process_issue(
)
config.set_llm_config(llm_config)

runtime = await create_runtime(config, sid=f"{issue.number}")
await initialize_runtime(runtime)
runtime = create_runtime(config, sid=f"{issue.number}")
initialize_runtime(runtime)

instruction = get_instruction(issue, prompt_template, repo_instruction)

Expand Down Expand Up @@ -341,7 +341,7 @@ def download_issues_from_github(
"Authorization": f"token {token}",
"Accept": "application/vnd.github.v3+json",
}
params = {"state": "open", "per_page": 100, "page": 1}
params: dict[str, int | str] = {"state": "open", "per_page": 100, "page": 1}
all_issues = []

while True:
Expand All @@ -358,6 +358,7 @@ def download_issues_from_github(
raise ValueError("Expected list of dictionaries from Github API.")

all_issues.extend(issues)
assert isinstance(params["page"], int)
params["page"] += 1
converted_issues = []
for issue in all_issues:
Expand Down
Loading

0 comments on commit b95a560

Please sign in to comment.