mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
add Visual SWE-bench benchmark (#7131)
Co-authored-by: tsukimi <yuailun@pku.edu.cn> Co-authored-by: Ryan H. Tran <descience.thh10@gmail.com>
This commit is contained in:
172
evaluation/benchmarks/visual_swe_bench/README.md
Normal file
172
evaluation/benchmarks/visual_swe_bench/README.md
Normal file
@@ -0,0 +1,172 @@
|
||||
# Visual SWE-Bench Evaluation with Docker Image
|
||||
|
||||
This folder contains the evaluation harness that we built on top of the original [Visual SWE-Bench benchmark](https://multi-swe-bench.github.io/#/) ([paper](https://arxiv.org/abs/2412.17315)).
|
||||
|
||||
The evaluation consists of three steps:
|
||||
|
||||
1. Environment setup: [install python environment](../../README.md#development-environment), [configure LLM config](../../README.md#configure-openhands-and-your-llm), and [pull docker](#openhands-visual-swe-bench-instance-level-docker-support).
|
||||
2. [Run inference](#run-inference-on-visual-swe-bench-instances): Generate a edit patch for each Github issue.
|
||||
3. [Evaluate patches using Visual SWE-Bench docker](#evaluate-generated-patches).
|
||||
|
||||
## Setup Environment and LLM Configuration
|
||||
|
||||
Please follow instruction [here](../../README.md#setup) to setup your local development environment and LLM.
|
||||
|
||||
## OpenHands Visual SWE-Bench Instance-level Docker Support
|
||||
|
||||
OpenHands now support using the official evaluation docker for both **[inference](#run-inference-on-visual-swe-bench-instances) and [evaluation](#evaluate-generated-patches)**.
|
||||
This is now the default behavior.
|
||||
|
||||
## Run Inference on Visual SWE-Bench Instances
|
||||
|
||||
Make sure your Docker daemon is running, and you have ample disk space for the [instance-level docker image](#openhands-visual-swe-bench-instance-level-docker-support).
|
||||
|
||||
When the `run_infer.sh` script is started, it will automatically pull the relevant Visual SWE-Bench images. For example, for instance ID `networkx__networkx-6503`, it will try to pull our pre-build docker image `sweb.eval.x86_64.networkx_s_networkx-6503` from DockerHub. This image will be used create an OpenHands runtime image where the agent will operate on.
|
||||
|
||||
```bash
|
||||
./evaluation/benchmarks/visual_swe_bench/scripts/run_infer.sh [model_config] [git-version] [agent] [eval_limit] [max_iter] [num_workers]
|
||||
|
||||
# Example
|
||||
./evaluation/benchmarks/visual_swe_bench/scripts/run_infer.sh llm.eval_gpt4_1106_preview HEAD CodeActAgent 133 30 1
|
||||
```
|
||||
|
||||
where `model_config` is mandatory, and the rest are optional.
|
||||
|
||||
- `model_config`, e.g. `eval_gpt4_1106_preview`, is the config group name for your
|
||||
LLM settings, as defined in your `config.toml`.
|
||||
- `git-version`, e.g. `HEAD`, is the git commit hash of the OpenHands version you would
|
||||
like to evaluate. It could also be a release tag like `0.6.2`.
|
||||
- `agent`, e.g. `CodeActAgent`, is the name of the agent for benchmarks, defaulting
|
||||
to `CodeActAgent`.
|
||||
- `eval_limit`, e.g. `10`, limits the evaluation to the first `eval_limit` instances. By
|
||||
default, the script evaluates the entire Visual SWE-bench set (133 issues). Note:
|
||||
in order to use `eval_limit`, you must also set `agent`.
|
||||
- `max_iter`, e.g. `20`, is the maximum number of iterations for the agent to run. By
|
||||
default, it is set to 30.
|
||||
- `num_workers`, e.g. `3`, is the number of parallel workers to run the evaluation. By
|
||||
default, it is set to 1.
|
||||
|
||||
There are also two optional environment variables you can set.
|
||||
|
||||
```bash
|
||||
export USE_HINT_TEXT=true # if you want to use hint text in the evaluation. Default to false. Ignore this if you are not sure.
|
||||
export USE_INSTANCE_IMAGE=true # if you want to use instance-level docker images. Default to true
|
||||
```
|
||||
|
||||
Let's say you'd like to run 10 instances using `llm.eval_gpt4_1106_preview` and CodeActAgent,
|
||||
|
||||
then your command would be:
|
||||
|
||||
```bash
|
||||
./evaluation/benchmarks/visual_swe_bench/scripts/run_infer.sh llm.eval_gpt4_1106_preview HEAD CodeActAgent 10
|
||||
```
|
||||
|
||||
### Specify a subset of tasks to run infer
|
||||
|
||||
If you would like to specify a list of tasks you'd like to benchmark on, you could
|
||||
create a `config.toml` under `./evaluation/benchmarks/visual_swe_bench/` folder, and put a list
|
||||
attribute named `selected_ids`, e.g.
|
||||
|
||||
```toml
|
||||
selected_ids = ['astropy__astropy-13838', 'matplotlib__matplotlib-21617', 'plotly__plotly.py-1966']
|
||||
```
|
||||
|
||||
Then only these tasks (rows whose `instance_id` is in the above list) will be evaluated.
|
||||
In this case, `eval_limit` option applies to tasks that are in the `selected_ids` list.
|
||||
|
||||
After running the inference, you will obtain a `output.jsonl` (by default it will be saved to `evaluation/evaluation_outputs`).
|
||||
|
||||
## Evaluate Generated Patches
|
||||
|
||||
### Download Docker Images
|
||||
|
||||
**(Recommended for reproducibility)** If you have extra local space (e.g., 200GB), you can try pull the instance-level docker images we've prepared by running:
|
||||
|
||||
```bash
|
||||
evaluation/benchmarks/visual_swe_bench/scripts/docker/pull_all_eval_docker.sh instance
|
||||
```
|
||||
|
||||
If you want to save disk space a bit, while speeding up the image pre-build process, you can pull the environment-level docker images:
|
||||
|
||||
```bash
|
||||
evaluation/benchmarks/visual_swe_bench/scripts/docker/pull_all_eval_docker.sh env
|
||||
```
|
||||
|
||||
If you want to evaluate on the full SWE-Bench test set:
|
||||
|
||||
```bash
|
||||
evaluation/benchmarks/visual_swe_bench/scripts/docker/pull_all_eval_docker.sh instance full
|
||||
```
|
||||
|
||||
### Run evaluation
|
||||
|
||||
With `output.jsonl` file, you can run `eval_infer.sh` to evaluate generated patches, and produce a fine-grained report.
|
||||
|
||||
**This evaluation is performed using the official dockerized evaluation announced.**
|
||||
|
||||
> If you want to evaluate existing results, you should first run this to clone existing outputs
|
||||
>
|
||||
>```bash
|
||||
>git clone https://huggingface.co/spaces/OpenHands/evaluation evaluation/evaluation_outputs
|
||||
>```
|
||||
|
||||
NOTE, you should have already pulled the instance-level OR env-level docker images following [this section](#openhands-visual-swe-bench-instance-level-docker-support).
|
||||
|
||||
Then you can run the following:
|
||||
|
||||
```bash
|
||||
./evaluation/benchmarks/visual_swe_bench/scripts/eval_infer.sh $YOUR_OUTPUT_JSONL [instance_id]
|
||||
|
||||
# Example
|
||||
./evaluation/benchmarks/visual_swe_bench/scripts/eval_infer.sh evaluation/evaluation_outputs/outputs/luolin101__Visual-SWE-bench-test/CodeActAgent/gpt-4-1106-preview_maxiter_50_N_v1.0/output.jsonl
|
||||
```
|
||||
|
||||
The script now accepts optional arguments:
|
||||
|
||||
- `instance_id`: Specify a single instance to evaluate (optional)
|
||||
|
||||
For example, to evaluate a specific instance with a custom dataset and split:
|
||||
|
||||
```bash
|
||||
./evaluation/benchmarks/visual_swe_bench/scripts/eval_infer.sh $YOUR_OUTPUT_JSONL instance_123
|
||||
```
|
||||
|
||||
> You can also pass in a JSONL with SWE-Bench format to `./evaluation/benchmarks/visual_swe_bench/scripts/eval_infer.sh`, where each line is a JSON of `{"model_patch": "XXX", "model_name_or_path": "YYY", "instance_id": "ZZZ"}`.
|
||||
|
||||
The final results will be saved to `evaluation/evaluation_outputs/outputs/visual_swe_bench/CodeActAgent/gpt-4-1106-preview_maxiter_50_N_v1.0/` with the following files/directory:
|
||||
|
||||
- `README.md`: a report showing what are the instances that passed, failed, etc.
|
||||
- `report.json`: a JSON file that contains keys like `"resolved_ids"` pointing to instance IDs that are resolved by the agent.
|
||||
- `logs/`: a directory of test logs
|
||||
|
||||
## Visualize Results
|
||||
|
||||
First you need to clone `https://huggingface.co/spaces/OpenHands/evaluation` and add your own running results from openhands into the `outputs` of the cloned repo.
|
||||
|
||||
```bash
|
||||
git clone https://huggingface.co/spaces/OpenHands/evaluation
|
||||
```
|
||||
|
||||
**(optional) setup streamlit environment with conda**:
|
||||
|
||||
```bash
|
||||
cd evaluation
|
||||
conda create -n streamlit python=3.10
|
||||
conda activate streamlit
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
**run the visualizer**:
|
||||
Then, in a separate Python environment with `streamlit` library, you can run the following:
|
||||
|
||||
```bash
|
||||
# Make sure you are inside the cloned `evaluation` repo
|
||||
conda activate streamlit # if you follow the optional conda env setup above
|
||||
streamlit app.py --server.port 8501 --server.address 0.0.0.0
|
||||
```
|
||||
|
||||
Then you can access the SWE-Bench trajectory visualizer at `localhost:8501`.
|
||||
|
||||
## Submit your evaluation results
|
||||
|
||||
You can start your own fork of [our huggingface evaluation outputs](https://huggingface.co/spaces/OpenHands/evaluation) and submit a PR of your evaluation results following the guide [here](https://huggingface.co/docs/hub/en/repositories-pull-requests-discussions#pull-requests-and-discussions).
|
||||
0
evaluation/benchmarks/visual_swe_bench/__init__.py
Normal file
0
evaluation/benchmarks/visual_swe_bench/__init__.py
Normal file
641
evaluation/benchmarks/visual_swe_bench/run_infer.py
Normal file
641
evaluation/benchmarks/visual_swe_bench/run_infer.py
Normal file
@@ -0,0 +1,641 @@
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from typing import Any
|
||||
|
||||
import pandas as pd
|
||||
import toml
|
||||
from datasets import load_dataset
|
||||
|
||||
import openhands.agenthub
|
||||
from evaluation.benchmarks.swe_bench.resource.mapping import (
|
||||
get_instance_resource_factor,
|
||||
)
|
||||
from evaluation.utils.shared import (
|
||||
EvalException,
|
||||
EvalMetadata,
|
||||
EvalOutput,
|
||||
assert_and_raise,
|
||||
codeact_user_response,
|
||||
get_default_sandbox_config_for_eval,
|
||||
get_metrics,
|
||||
is_fatal_evaluation_error,
|
||||
make_metadata,
|
||||
prepare_dataset,
|
||||
reset_logger_for_multiprocessing,
|
||||
run_evaluation,
|
||||
update_llm_config_for_completions_logging,
|
||||
)
|
||||
from openhands.controller.state.state import State
|
||||
from openhands.core.config import (
|
||||
AgentConfig,
|
||||
AppConfig,
|
||||
get_llm_config_arg,
|
||||
get_parser,
|
||||
)
|
||||
from openhands.core.logger import openhands_logger as logger
|
||||
from openhands.core.main import create_runtime, run_controller
|
||||
from openhands.events.action import CmdRunAction, MessageAction
|
||||
from openhands.events.observation import CmdOutputObservation, ErrorObservation
|
||||
from openhands.events.serialization.event import event_to_dict
|
||||
from openhands.runtime.base import Runtime
|
||||
from openhands.utils.async_utils import call_async_from_sync
|
||||
from openhands.utils.shutdown_listener import sleep_if_should_continue
|
||||
|
||||
USE_HINT_TEXT = os.environ.get('USE_HINT_TEXT', 'false').lower() == 'true'
|
||||
RUN_WITH_BROWSING = os.environ.get('RUN_WITH_BROWSING', 'false').lower() == 'true'
|
||||
|
||||
|
||||
AGENT_CLS_TO_FAKE_USER_RESPONSE_FN = {
|
||||
'CodeActAgent': codeact_user_response,
|
||||
}
|
||||
|
||||
|
||||
def _get_swebench_workspace_dir_name(instance: pd.Series) -> str:
|
||||
return f'{instance.repo}__{instance.version}'.replace('/', '__')
|
||||
|
||||
|
||||
def get_instruction(instance: pd.Series, metadata: EvalMetadata):
|
||||
workspace_dir_name = _get_swebench_workspace_dir_name(instance)
|
||||
# Instruction based on Anthropic's official trajectory
|
||||
# https://github.com/eschluntz/swe-bench-experiments/tree/main/evaluation/verified/20241022_tools_claude-3-5-sonnet-updated/trajs
|
||||
instruction = (
|
||||
'<uploaded_files>\n'
|
||||
f'/workspace/{workspace_dir_name}\n'
|
||||
'</uploaded_files>\n'
|
||||
f"I've uploaded a python code repository in the directory {workspace_dir_name}. Consider the following issue description:\n\n"
|
||||
f'<issue_description>\n'
|
||||
f'{instance.problem_statement}\n'
|
||||
'</issue_description>\n\n'
|
||||
'Can you help me implement the necessary changes to the repository so that the requirements specified in the <issue_description> are met?\n'
|
||||
"I've already taken care of all changes to any of the test files described in the <issue_description>. This means you DON'T have to modify the testing logic or any of the tests in any way!\n"
|
||||
"Also the development Python environment is already set up for you (i.e., all dependencies already installed), so you don't need to install other packages.\n"
|
||||
'Your task is to make the minimal changes to non-test files in the /workspace directory to ensure the <issue_description> is satisfied.\n'
|
||||
'Follow these steps to resolve the issue:\n'
|
||||
'1. As a first step, it might be a good idea to explore the repo to familiarize yourself with its structure.\n'
|
||||
'2. Create a script to reproduce the error and execute it with `python <filename.py>` using the BashTool, to confirm the error\n'
|
||||
'3. Edit the sourcecode of the repo to resolve the issue\n'
|
||||
'4. Rerun your reproduce script and confirm that the error is fixed!\n'
|
||||
'5. Think about edgecases, add comprehensive tests for them in your reproduce script, and run them to make sure your fix handles them as well\n'
|
||||
f'6. Once you are done with the initial implementation, please carefully re-read the problem description and check the difference between the current code and the base commit {instance["base_commit"]}. Do you think that the issue has been completely and comprehensively solved? Write tests to check the correctness of the solution, specifically focusing on tests that may point out any remaining problems that are not yet solved. Run all of the tests in the repo and check if any of them fail, and if they do fix the code. Repeat this process of carefully reading the problem description and current implementation, testing, and fixing any problems until you are confident that the current implementation is correct. Find and run any tests in the repo that are related to:\n'
|
||||
' - The issue you are fixing\n'
|
||||
' - The files you modified\n'
|
||||
' - The functions you changed\n'
|
||||
' Make sure all these tests pass with your changes.\n'
|
||||
"Your thinking should be thorough and so it's fine if it's very long.\n"
|
||||
)
|
||||
|
||||
if RUN_WITH_BROWSING:
|
||||
instruction += (
|
||||
'<IMPORTANT!>\nYou SHOULD NEVER attempt to browse the web. </IMPORTANT!>\n'
|
||||
)
|
||||
return instruction
|
||||
|
||||
|
||||
# TODO: migrate all swe-bench docker to ghcr.io/openhands
|
||||
DOCKER_IMAGE_PREFIX = os.environ.get('EVAL_DOCKER_IMAGE_PREFIX', 'docker.io/xingyaoww/')
|
||||
logger.info(f'Using docker image prefix: {DOCKER_IMAGE_PREFIX}')
|
||||
|
||||
|
||||
def get_instance_docker_image(instance_id: str, official_image: bool = False) -> str:
|
||||
image_name = 'sweb.eval.x86_64.' + instance_id
|
||||
image_name = image_name.replace(
|
||||
'__', '_s_'
|
||||
) # to comply with docker image naming convention
|
||||
other_list = [
|
||||
'plotly__plotly.py-4083',
|
||||
'plotly__plotly.py-2600',
|
||||
'plotly__plotly.py-2591',
|
||||
'plotly__plotly.py-1966',
|
||||
'networkx__networkx-6503',
|
||||
'networkx__networkx-6098',
|
||||
'networkx__networkx-5616',
|
||||
'networkx__networkx-5354',
|
||||
'networkx__networkx-5058',
|
||||
'networkx__networkx-4378',
|
||||
'networkx__networkx-3764',
|
||||
'vega__altair-2785',
|
||||
'vega__altair-1092',
|
||||
'vega__altair-974',
|
||||
'vega__altair-830',
|
||||
'matplotlib__matplotlib-27754',
|
||||
'matplotlib__matplotlib-26926',
|
||||
'matplotlib__matplotlib-26788',
|
||||
'matplotlib__matplotlib-26586',
|
||||
'sympy__sympy-26941',
|
||||
'mwaskom__seaborn-3458',
|
||||
'mwaskom__seaborn-3454',
|
||||
]
|
||||
if instance_id in other_list:
|
||||
return ('docker.io/luolin101/'.rstrip('/') + '/' + image_name).lower()
|
||||
return (DOCKER_IMAGE_PREFIX.rstrip('/') + '/' + image_name).lower()
|
||||
|
||||
|
||||
def get_config(
|
||||
instance: pd.Series,
|
||||
metadata: EvalMetadata,
|
||||
) -> AppConfig:
|
||||
# We use a different instance image for the each instance of swe-bench eval
|
||||
use_official_image = bool(
|
||||
'verified' in metadata.dataset.lower() or 'lite' in metadata.dataset.lower()
|
||||
)
|
||||
base_container_image = get_instance_docker_image(
|
||||
instance['instance_id'], use_official_image
|
||||
)
|
||||
logger.info(
|
||||
f'Using instance container image: {base_container_image}. '
|
||||
f'Please make sure this image exists. '
|
||||
f'Submit an issue on https://github.com/All-Hands-AI/OpenHands if you run into any issues.'
|
||||
)
|
||||
|
||||
sandbox_config = get_default_sandbox_config_for_eval()
|
||||
sandbox_config.base_container_image = base_container_image
|
||||
sandbox_config.enable_auto_lint = True
|
||||
sandbox_config.use_host_network = False
|
||||
# Add platform to the sandbox config to solve issue 4401
|
||||
sandbox_config.platform = 'linux/amd64'
|
||||
sandbox_config.remote_runtime_resource_factor = get_instance_resource_factor(
|
||||
dataset_name=metadata.dataset,
|
||||
instance_id=instance['instance_id'],
|
||||
)
|
||||
|
||||
config = AppConfig(
|
||||
default_agent=metadata.agent_class,
|
||||
run_as_openhands=False,
|
||||
max_iterations=metadata.max_iterations,
|
||||
runtime=os.environ.get('RUNTIME', 'docker'),
|
||||
sandbox=sandbox_config,
|
||||
# do not mount workspace
|
||||
workspace_base=None,
|
||||
workspace_mount_path=None,
|
||||
)
|
||||
config.set_llm_config(
|
||||
update_llm_config_for_completions_logging(
|
||||
metadata.llm_config, metadata.eval_output_dir, instance['instance_id']
|
||||
)
|
||||
)
|
||||
agent_config = AgentConfig(
|
||||
enable_jupyter=False,
|
||||
enable_browsing=RUN_WITH_BROWSING,
|
||||
enable_llm_editor=False,
|
||||
condenser=metadata.condenser_config,
|
||||
enable_prompt_extensions=False,
|
||||
)
|
||||
config.set_agent_config(agent_config)
|
||||
return config
|
||||
|
||||
|
||||
def initialize_runtime(
|
||||
runtime: Runtime,
|
||||
instance: pd.Series, # this argument is not required
|
||||
):
|
||||
"""Initialize the runtime for the agent.
|
||||
|
||||
This function is called before the runtime is used to run the agent.
|
||||
"""
|
||||
logger.info('-' * 30)
|
||||
logger.info('BEGIN Runtime Initialization Fn')
|
||||
logger.info('-' * 30)
|
||||
workspace_dir_name = _get_swebench_workspace_dir_name(instance)
|
||||
obs: CmdOutputObservation
|
||||
|
||||
# Set instance id
|
||||
action = CmdRunAction(
|
||||
command=f"""echo 'export SWE_INSTANCE_ID={instance['instance_id']}' >> ~/.bashrc && echo 'export PIP_CACHE_DIR=~/.cache/pip' >> ~/.bashrc && echo "alias git='git --no-pager'" >> ~/.bashrc"""
|
||||
)
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
obs.exit_code == 0, f'Failed to export SWE_INSTANCE_ID: {str(obs)}'
|
||||
)
|
||||
|
||||
action = CmdRunAction(command="""export USER=$(whoami); echo USER=${USER} """)
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(obs.exit_code == 0, f'Failed to export USER: {str(obs)}')
|
||||
|
||||
# inject the init script
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
# inject the instance info
|
||||
action = CmdRunAction(command='mkdir -p /swe_util/eval_data/instances')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
obs.exit_code == 0,
|
||||
f'Failed to create /swe_util/eval_data/instances: {str(obs)}',
|
||||
)
|
||||
|
||||
swe_instance_json_name = 'swe-bench-instance.json'
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
# Construct the full path for the desired file name within the temporary directory
|
||||
temp_file_path = os.path.join(temp_dir, swe_instance_json_name)
|
||||
# Write to the file with the desired name within the temporary directory
|
||||
with open(temp_file_path, 'w') as f:
|
||||
if not isinstance(instance, dict):
|
||||
json.dump([instance.to_dict()], f)
|
||||
else:
|
||||
json.dump([instance], f)
|
||||
|
||||
# Copy the file to the desired location
|
||||
runtime.copy_to(temp_file_path, '/swe_util/eval_data/instances/')
|
||||
|
||||
# inject the instance swe entry
|
||||
runtime.copy_to(
|
||||
str(os.path.join(script_dir, 'scripts/setup/instance_swe_entry.sh')),
|
||||
'/swe_util/',
|
||||
)
|
||||
|
||||
action = CmdRunAction(command='cat ~/.bashrc')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(obs.exit_code == 0, f'Failed to cat ~/.bashrc: {str(obs)}')
|
||||
|
||||
action = CmdRunAction(command='source ~/.bashrc')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
if isinstance(obs, ErrorObservation):
|
||||
logger.error(f'Failed to source ~/.bashrc: {str(obs)}')
|
||||
assert_and_raise(obs.exit_code == 0, f'Failed to source ~/.bashrc: {str(obs)}')
|
||||
|
||||
action = CmdRunAction(command='source /swe_util/instance_swe_entry.sh')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
obs.exit_code == 0,
|
||||
f'Failed to source /swe_util/instance_swe_entry.sh: {str(obs)}',
|
||||
)
|
||||
|
||||
action = CmdRunAction(command=f'cd /workspace/{workspace_dir_name}')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
obs.exit_code == 0,
|
||||
f'Failed to cd to /workspace/{workspace_dir_name}: {str(obs)}',
|
||||
)
|
||||
|
||||
action = CmdRunAction(command='git reset --hard')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(obs.exit_code == 0, f'Failed to git reset --hard: {str(obs)}')
|
||||
|
||||
action = CmdRunAction(
|
||||
command='for remote_name in $(git remote); do git remote remove "${remote_name}"; done'
|
||||
)
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(obs.exit_code == 0, f'Failed to remove git remotes: {str(obs)}')
|
||||
|
||||
action = CmdRunAction(command='which python')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
obs.exit_code == 0 and 'testbed' in obs.content,
|
||||
f'Expected to find python interpreter from testbed, but got: {str(obs)}',
|
||||
)
|
||||
|
||||
logger.info('-' * 30)
|
||||
logger.info('END Runtime Initialization Fn')
|
||||
logger.info('-' * 30)
|
||||
|
||||
|
||||
def complete_runtime(
|
||||
runtime: Runtime,
|
||||
instance: pd.Series, # this argument is not required, but it is used to get the workspace_dir_name
|
||||
) -> dict[str, Any]:
|
||||
"""Complete the runtime for the agent.
|
||||
|
||||
This function is called before the runtime is used to run the agent.
|
||||
If you need to do something in the sandbox to get the correctness metric after
|
||||
the agent has run, modify this function.
|
||||
"""
|
||||
logger.info('-' * 30)
|
||||
logger.info('BEGIN Runtime Completion Fn')
|
||||
logger.info('-' * 30)
|
||||
obs: CmdOutputObservation
|
||||
workspace_dir_name = _get_swebench_workspace_dir_name(instance)
|
||||
|
||||
action = CmdRunAction(command=f'cd /workspace/{workspace_dir_name}')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
|
||||
if obs.exit_code == -1:
|
||||
# The previous command is still running
|
||||
# We need to kill previous command
|
||||
logger.info('The previous command is still running, trying to kill it...')
|
||||
action = CmdRunAction(command='C-c')
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
|
||||
# Then run the command again
|
||||
action = CmdRunAction(command=f'cd /workspace/{workspace_dir_name}')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
|
||||
assert_and_raise(
|
||||
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||
f'Failed to cd to /workspace/{workspace_dir_name}: {str(obs)}',
|
||||
)
|
||||
|
||||
action = CmdRunAction(command='git config --global core.pager ""')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||
f'Failed to git config --global core.pager "": {str(obs)}',
|
||||
)
|
||||
|
||||
# First check for any git repositories in subdirectories
|
||||
action = CmdRunAction(command='find . -type d -name .git -not -path "./.git"')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||
f'Failed to find git repositories: {str(obs)}',
|
||||
)
|
||||
|
||||
git_dirs = [p for p in obs.content.strip().split('\n') if p]
|
||||
if git_dirs:
|
||||
# Remove all .git directories in subdirectories
|
||||
for git_dir in git_dirs:
|
||||
action = CmdRunAction(command=f'rm -rf "{git_dir}"')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||
f'Failed to remove git directory {git_dir}: {str(obs)}',
|
||||
)
|
||||
|
||||
# add all files
|
||||
action = CmdRunAction(command='git add -A')
|
||||
action.set_hard_timeout(600)
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
assert_and_raise(
|
||||
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||
f'Failed to git add -A: {str(obs)}',
|
||||
)
|
||||
|
||||
n_retries = 0
|
||||
git_patch = None
|
||||
while n_retries < 5:
|
||||
action = CmdRunAction(
|
||||
command=f'git diff --no-color --cached {instance["base_commit"]}'
|
||||
)
|
||||
action.set_hard_timeout(max(300 + 100 * n_retries, 600))
|
||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||
obs = runtime.run_action(action)
|
||||
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||
n_retries += 1
|
||||
if isinstance(obs, CmdOutputObservation):
|
||||
if obs.exit_code == 0:
|
||||
git_patch = obs.content.strip()
|
||||
break
|
||||
else:
|
||||
logger.info('Failed to get git diff, retrying...')
|
||||
sleep_if_should_continue(10)
|
||||
elif isinstance(obs, ErrorObservation):
|
||||
logger.error(f'Error occurred: {obs.content}. Retrying...')
|
||||
sleep_if_should_continue(10)
|
||||
else:
|
||||
assert_and_raise(False, f'Unexpected observation type: {str(obs)}')
|
||||
|
||||
assert_and_raise(git_patch is not None, 'Failed to get git diff (None)')
|
||||
|
||||
logger.info('-' * 30)
|
||||
logger.info('END Runtime Completion Fn')
|
||||
logger.info('-' * 30)
|
||||
return {'git_patch': git_patch}
|
||||
|
||||
|
||||
def process_instance(
|
||||
instance: pd.Series,
|
||||
metadata: EvalMetadata,
|
||||
reset_logger: bool = True,
|
||||
runtime_failure_count: int = 0,
|
||||
) -> EvalOutput:
|
||||
config = get_config(instance, metadata)
|
||||
|
||||
# Setup the logger properly, so you can run multi-processing to parallelize the evaluation
|
||||
if reset_logger:
|
||||
log_dir = os.path.join(metadata.eval_output_dir, 'infer_logs')
|
||||
reset_logger_for_multiprocessing(logger, instance.instance_id, log_dir)
|
||||
else:
|
||||
logger.info(f'Starting evaluation for instance {instance.instance_id}.')
|
||||
|
||||
# Increase resource_factor with increasing attempt_id
|
||||
if runtime_failure_count > 0:
|
||||
config.sandbox.remote_runtime_resource_factor = min(
|
||||
config.sandbox.remote_runtime_resource_factor * (2**runtime_failure_count),
|
||||
8,
|
||||
)
|
||||
logger.warning(
|
||||
f'This is the {runtime_failure_count + 1}th attempt for instance {instance.instance_id}, setting resource factor to {config.sandbox.remote_runtime_resource_factor}'
|
||||
)
|
||||
runtime = create_runtime(config)
|
||||
call_async_from_sync(runtime.connect)
|
||||
|
||||
try:
|
||||
initialize_runtime(runtime, instance)
|
||||
|
||||
instruction = get_instruction(instance, metadata)
|
||||
|
||||
# Here's how you can run the agent (similar to the `main` function) and get the final task state
|
||||
state: State | None = asyncio.run(
|
||||
run_controller(
|
||||
config=config,
|
||||
initial_user_action=MessageAction(content=instruction),
|
||||
runtime=runtime,
|
||||
fake_user_response_fn=AGENT_CLS_TO_FAKE_USER_RESPONSE_FN[
|
||||
metadata.agent_class
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
# if fatal error, throw EvalError to trigger re-run
|
||||
if is_fatal_evaluation_error(state.last_error):
|
||||
raise EvalException('Fatal error detected: ' + state.last_error)
|
||||
|
||||
# ======= THIS IS SWE-Bench specific =======
|
||||
# Get git patch
|
||||
return_val = complete_runtime(runtime, instance)
|
||||
git_patch = return_val['git_patch']
|
||||
logger.info(
|
||||
f'Got git diff for instance {instance.instance_id}:\n--------\n{git_patch}\n--------'
|
||||
)
|
||||
finally:
|
||||
runtime.close()
|
||||
# ==========================================
|
||||
|
||||
# ======= Attempt to evaluate the agent's edits =======
|
||||
# we use eval_infer.sh to evaluate the agent's edits, not here
|
||||
# because the agent may alter the environment / testcases
|
||||
test_result = {
|
||||
'git_patch': git_patch,
|
||||
}
|
||||
|
||||
# If you are working on some simpler benchmark that only evaluates the final model output (e.g., in a MessageAction)
|
||||
# You can simply get the LAST `MessageAction` from the returned `state.history` and parse it for evaluation.
|
||||
if state is None:
|
||||
raise ValueError('State should not be None.')
|
||||
|
||||
# NOTE: this is NO LONGER the event stream, but an agent history that includes delegate agent's events
|
||||
histories = [event_to_dict(event) for event in state.history]
|
||||
metrics = get_metrics(state)
|
||||
|
||||
# Save the output
|
||||
output = EvalOutput(
|
||||
instance_id=instance.instance_id,
|
||||
instruction=instruction,
|
||||
instance=instance.to_dict(), # SWE Bench specific
|
||||
test_result=test_result,
|
||||
metadata=metadata,
|
||||
history=histories,
|
||||
metrics=metrics,
|
||||
error=state.last_error if state and state.last_error else None,
|
||||
)
|
||||
return output
|
||||
|
||||
|
||||
def filter_dataset(dataset: pd.DataFrame, filter_column: str) -> pd.DataFrame:
|
||||
file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config.toml')
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, 'r') as file:
|
||||
data = toml.load(file)
|
||||
if 'selected_ids' in data:
|
||||
selected_ids = data['selected_ids']
|
||||
logger.info(
|
||||
f'Filtering {len(selected_ids)} tasks from "selected_ids"...'
|
||||
)
|
||||
subset = dataset[dataset[filter_column].isin(selected_ids)]
|
||||
logger.info(f'Retained {subset.shape[0]} tasks after filtering')
|
||||
return subset
|
||||
skip_ids = os.environ.get('SKIP_IDS', '').split(',')
|
||||
if len(skip_ids) > 0:
|
||||
logger.info(f'Filtering {len(skip_ids)} tasks from "SKIP_IDS"...')
|
||||
return dataset[~dataset[filter_column].isin(skip_ids)]
|
||||
return dataset
|
||||
|
||||
|
||||
# A list of instances that are known to be tricky to infer
|
||||
# (will cause runtime failure even with resource factor = 8)
|
||||
SWEGYM_EXCLUDE_IDS = [
|
||||
'dask__dask-10422',
|
||||
'pandas-dev__pandas-50548',
|
||||
'pandas-dev__pandas-53672',
|
||||
'pandas-dev__pandas-54174',
|
||||
'pandas-dev__pandas-55518',
|
||||
'pandas-dev__pandas-58383',
|
||||
'pydata__xarray-6721',
|
||||
'pytest-dev__pytest-10081',
|
||||
'pytest-dev__pytest-7236',
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = get_parser()
|
||||
parser.add_argument(
|
||||
'--dataset',
|
||||
type=str,
|
||||
default='princeton-nlp/SWE-bench',
|
||||
help='data set to evaluate on, either full-test or lite-test',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--split',
|
||||
type=str,
|
||||
default='test',
|
||||
help='split to evaluate on',
|
||||
)
|
||||
args, _ = parser.parse_known_args()
|
||||
|
||||
# NOTE: It is preferable to load datasets from huggingface datasets and perform post-processing
|
||||
# so we don't need to manage file uploading to OpenHands's repo
|
||||
dataset = load_dataset(args.dataset, split=args.split)
|
||||
swe_bench_tests = filter_dataset(dataset.to_pandas(), 'instance_id')
|
||||
logger.info(
|
||||
f'Loaded dataset {args.dataset} with split {args.split}: {len(swe_bench_tests)} tasks'
|
||||
)
|
||||
if 'SWE-Gym' in args.dataset:
|
||||
swe_bench_tests = swe_bench_tests[
|
||||
~swe_bench_tests['instance_id'].isin(SWEGYM_EXCLUDE_IDS)
|
||||
]
|
||||
logger.info(
|
||||
f'{len(swe_bench_tests)} tasks left after excluding SWE-Gym excluded tasks'
|
||||
)
|
||||
|
||||
llm_config = None
|
||||
if args.llm_config:
|
||||
llm_config = get_llm_config_arg(args.llm_config)
|
||||
llm_config.log_completions = True
|
||||
# modify_params must be False for evaluation purpose, for reproducibility and accurancy of results
|
||||
llm_config.modify_params = False
|
||||
|
||||
if llm_config is None:
|
||||
raise ValueError(f'Could not find LLM config: --llm_config {args.llm_config}')
|
||||
|
||||
details = {}
|
||||
_agent_cls = openhands.agenthub.Agent.get_cls(args.agent_cls)
|
||||
|
||||
dataset_descrption = (
|
||||
args.dataset.replace('/', '__') + '-' + args.split.replace('/', '__')
|
||||
)
|
||||
metadata = make_metadata(
|
||||
llm_config,
|
||||
dataset_descrption,
|
||||
args.agent_cls,
|
||||
args.max_iterations,
|
||||
args.eval_note,
|
||||
args.eval_output_dir,
|
||||
details=details,
|
||||
)
|
||||
|
||||
output_file = os.path.join(metadata.eval_output_dir, 'output.jsonl')
|
||||
print(f'### OUTPUT FILE: {output_file} ###')
|
||||
instances = prepare_dataset(swe_bench_tests, output_file, args.eval_n_limit)
|
||||
|
||||
if len(instances) > 0 and not isinstance(
|
||||
instances['PASS_TO_PASS'][instances['PASS_TO_PASS'].index[0]], str
|
||||
):
|
||||
for col in ['PASS_TO_PASS', 'FAIL_TO_PASS']:
|
||||
instances[col] = instances[col].apply(lambda x: str(x))
|
||||
|
||||
run_evaluation(
|
||||
instances,
|
||||
metadata,
|
||||
output_file,
|
||||
args.eval_num_workers,
|
||||
process_instance,
|
||||
timeout_seconds=8 * 60 * 60, # 8 hour PER instance should be more than enough
|
||||
max_retries=5,
|
||||
)
|
||||
@@ -0,0 +1,157 @@
|
||||
xingyaoww/sweb.eval.x86_64.astropy_s_astropy-11693:latest
|
||||
xingyaoww/sweb.eval.x86_64.astropy_s_astropy-13838:latest
|
||||
xingyaoww/sweb.eval.x86_64.astropy_s_astropy-14295:latest
|
||||
xingyaoww/sweb.eval.x86_64.astropy_s_astropy-8292:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-13908:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-13980:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-13983:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-13984:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-14043:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-14623:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-19763:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-20470:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-20518:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-20584:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-20761:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-20826:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-21443:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-21490:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-21550:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-21568:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-21617:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-22865:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-22871:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-22931:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-23047:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-23111:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-23412:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24088:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24177:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24189:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24570:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24691:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24749:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24768:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24849:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24870:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-24971:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25287:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25334:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25340:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25346:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25405:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25499:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25565:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25640:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25667:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25779:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-26078:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-26466:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-2576:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-2846:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-2979:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3180:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3187:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3202:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3216:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3217:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3276:latest
|
||||
xingyaoww/sweb.eval.x86_64.mwaskom_s_seaborn-3394:latest
|
||||
xingyaoww/sweb.eval.x86_64.pydata_s_xarray-4182:latest
|
||||
xingyaoww/sweb.eval.x86_64.pydata_s_xarray-5682:latest
|
||||
xingyaoww/sweb.eval.x86_64.pylint-dev_s_pylint-4551:latest
|
||||
xingyaoww/sweb.eval.x86_64.scikit-learn_s_scikit-learn-13087:latest
|
||||
xingyaoww/sweb.eval.x86_64.scikit-learn_s_scikit-learn-13618:latest
|
||||
xingyaoww/sweb.eval.x86_64.scikit-learn_s_scikit-learn-14067:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-10048:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-10097:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-10191:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-10435:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-11266:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-11502:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-7615:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-7757:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8028:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8056:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8075:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8120:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8265:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8278:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8620:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8621:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8638:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-8658:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9229:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9230:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9289:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9320:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9350:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9464:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9673:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9698:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9797:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9982:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9987:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9997:latest
|
||||
xingyaoww/sweb.eval.x86_64.sphinx-doc_s_sphinx-9999:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-11787:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-11788:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-13264:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-13840:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-15151:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-15304:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-15625:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-15976:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-16003:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-17067:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-17115:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-18922:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-21769:latest
|
||||
xingyaoww/sweb.eval.x86_64.sympy_s_sympy-24723:latest
|
||||
luolin101/sweb.eval.x86_64.plotly_s_plotly.py-4083:latest
|
||||
luolin101/sweb.eval.x86_64.plotly_s_plotly.py-2600:latest
|
||||
luolin101/sweb.eval.x86_64.plotly_s_plotly.py-2591:latest
|
||||
luolin101/sweb.eval.x86_64.plotly_s_plotly.py-1966:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-6503:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-6098:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-5616:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-5354:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-5058:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-4378:latest
|
||||
luolin101/sweb.eval.x86_64.networkx_s_networkx-3764:latest
|
||||
luolin101/sweb.eval.x86_64.vega_s_altair-2785:latest
|
||||
luolin101/sweb.eval.x86_64.vega_s_altair-1092:latest
|
||||
luolin101/sweb.eval.x86_64.vega_s_altair-974:latest
|
||||
luolin101/sweb.eval.x86_64.vega_s_altair-830:latest
|
||||
luolin101/sweb.eval.x86_64.matplotlib_s_matplotlib-27754:latest
|
||||
luolin101/sweb.eval.x86_64.matplotlib_s_matplotlib-26926:latest
|
||||
luolin101/sweb.eval.x86_64.matplotlib_s_matplotlib-26788:latest
|
||||
luolin101/sweb.eval.x86_64.matplotlib_s_matplotlib-26586:latest
|
||||
luolin101/sweb.eval.x86_64.sympy_s_sympy-26941:latest
|
||||
luolin101/sweb.eval.x86_64.mwaskom_s_seaborn-3458:latest
|
||||
luolin101/sweb.eval.x86_64.mwaskom_s_seaborn-3454:latest
|
||||
xingyaoww/sweb.eval.x86_64.matplotlib_s_matplotlib-25631:latest
|
||||
xingyaoww/sweb.env.x86_64.428468730904ff6b4232aa:latest
|
||||
xingyaoww/sweb.env.x86_64.89a9e6df7ab7bcb9e010c8:latest
|
||||
xingyaoww/sweb.env.x86_64.15374367de368534f261e3:latest
|
||||
xingyaoww/sweb.env.x86_64.6b007979cf533f0f3016e8:latest
|
||||
xingyaoww/sweb.env.x86_64.b382c45e0a94d34ef0fc86:latest
|
||||
xingyaoww/sweb.env.x86_64.7037e8c448a4b8ebfe9b13:latest
|
||||
xingyaoww/sweb.env.x86_64.31244378a92e3bcce809ac:latest
|
||||
xingyaoww/sweb.env.x86_64.efa6065ed5bf204410fd53:latest
|
||||
xingyaoww/sweb.env.x86_64.a0efca7a0fe6719dbf65c2:latest
|
||||
xingyaoww/sweb.env.x86_64.502d8fc6ebccd881244091:latest
|
||||
luolin101/sweb.env.x86_64.eb002359cfcbe2edb56088:latest
|
||||
xingyaoww/sweb.env.x86_64.d905bb51fb68acc5d4221b:latest
|
||||
xingyaoww/sweb.env.x86_64.aa92880033da20ca313928:latest
|
||||
luolin101/sweb.env.x86_64.c6d251a05e0af7688b64fd:latest
|
||||
xingyaoww/sweb.env.x86_64.c795f4b88616b8462021ed:latest
|
||||
luolin101/sweb.env.x86_64.1e5a06e76ee016d067d77e:latest
|
||||
luolin101/sweb.env.x86_64.2e03d8e4d4bd373937a9ef:latest
|
||||
luolin101/sweb.env.x86_64.4c16026920d27ea78f3b7a:latest
|
||||
luolin101/sweb.env.x86_64.d15120dfdbda9831e9646b:latest
|
||||
luolin101/sweb.env.x86_64.c581ba273c3275679773dd:latest
|
||||
luolin101/sweb.env.x86_64.dc800a1bbe275c5de0c4aa:latest
|
||||
luolin101/sweb.env.x86_64.59bd7d84a0939c7caba7e6:latest
|
||||
xingyaoww/sweb.env.x86_64.0d80c7dec81ee2f2f513e2:latest
|
||||
xingyaoww/sweb.base.x86_64:latest
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
LEVEL=$1
|
||||
# three levels:
|
||||
# - base, keyword "sweb.base"
|
||||
# - env, keyword "sweb.env"
|
||||
# - instance, keyword "sweb.eval"
|
||||
SET=$2
|
||||
|
||||
if [ -z "$LEVEL" ]; then
|
||||
echo "Usage: $0 <cache_level> <set>"
|
||||
echo "cache_level: base, env, or instance"
|
||||
echo "set: lite, full"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SET" ]; then
|
||||
echo "Usage: $0 <cache_level> <set>"
|
||||
echo "cache_level: base, env, or instance"
|
||||
echo "set: lite, full, default is lite"
|
||||
SET="lite"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$SET" == "full" ]; then
|
||||
IMAGE_FILE="$(dirname "$0")/all-visualswebench-full-instance-images.txt"
|
||||
else
|
||||
IMAGE_FILE="$(dirname "$0")/all-visualswebench-full-instance-images.txt"
|
||||
fi
|
||||
|
||||
# Define a pattern based on the level
|
||||
case $LEVEL in
|
||||
base)
|
||||
PATTERN="sweb.base"
|
||||
;;
|
||||
env)
|
||||
PATTERN="sweb.base\|sweb.env"
|
||||
;;
|
||||
instance)
|
||||
PATTERN="sweb.base\|sweb.env\|sweb.eval"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid cache level: $LEVEL"
|
||||
echo "Valid levels are: base, env, instance"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Pulling docker images for [$LEVEL] level"
|
||||
|
||||
echo "Pattern: $PATTERN"
|
||||
echo "Image file: $IMAGE_FILE"
|
||||
|
||||
# Read each line from the file, filter by pattern, and pull the docker image
|
||||
grep "$PATTERN" "$IMAGE_FILE" | while IFS= read -r image; do
|
||||
echo "Pulling $image into $image"
|
||||
docker pull $image
|
||||
# replace _s_ to __ in the image name
|
||||
renamed_image=$(echo "$image" | sed 's|.*/||; s/_s_/__/g')
|
||||
docker tag $image $renamed_image
|
||||
done
|
||||
141
evaluation/benchmarks/visual_swe_bench/scripts/eval_infer.sh
Executable file
141
evaluation/benchmarks/visual_swe_bench/scripts/eval_infer.sh
Executable file
@@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROCESS_FILEPATH=$1
|
||||
if [ -z "$PROCESS_FILEPATH" ]; then
|
||||
echo "Error: PROCESS_FILEPATH is empty. Usage: ./eval_infer.sh <output_file> [instance_id] [dataset_name] [split]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $PROCESS_FILEPATH ]; then
|
||||
echo "Error: $PROCESS_FILEPATH is not a file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If instance_id is empty, it means we want to eval on the whole $PROCESS_FILEPATH
|
||||
# otherwise, we want to eval on the instance_id
|
||||
INSTANCE_ID=$2
|
||||
DATASET_NAME=${3:-"luolin101/Visual-SWE-bench"}
|
||||
SPLIT=${4:-"test"}
|
||||
|
||||
echo "INSTANCE_ID: $INSTANCE_ID"
|
||||
echo "DATASET_NAME: $DATASET_NAME"
|
||||
echo "SPLIT: $SPLIT"
|
||||
|
||||
PROCESS_FILEPATH=$(realpath $PROCESS_FILEPATH)
|
||||
FILE_DIR=$(dirname $PROCESS_FILEPATH)
|
||||
FILE_NAME=$(basename $PROCESS_FILEPATH)
|
||||
|
||||
echo "Evaluating $FILE_NAME @ $FILE_DIR"
|
||||
|
||||
# ================================================
|
||||
# detect whether PROCESS_FILEPATH is in OH format or in SWE-bench format
|
||||
echo "=============================================================="
|
||||
echo "Detecting whether PROCESS_FILEPATH is in OH format or in SWE-bench format"
|
||||
echo "=============================================================="
|
||||
# SWE-bench format is a JSONL where every line has three fields: model_name_or_path, instance_id, and model_patch
|
||||
function is_swebench_format() {
|
||||
# Read the first line of the file
|
||||
read -r first_line < "$PROCESS_FILEPATH"
|
||||
|
||||
# Use jq to check if the first line has the required fields
|
||||
echo "$first_line" | jq -e '. | has("model_name_or_path") and has("instance_id") and has("model_patch")' > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1 # Return 1 if the first line does not have the required fields
|
||||
fi
|
||||
|
||||
return 0 # Return 0 if the first line has the required fields
|
||||
}
|
||||
# Call the function with the file path
|
||||
is_swebench_format "$PROCESS_FILEPATH"
|
||||
IS_SWEBENCH_FORMAT=$?
|
||||
# Use the result in an if-else statement
|
||||
if [ $IS_SWEBENCH_FORMAT -eq 0 ]; then
|
||||
echo "The file IS in SWE-bench format."
|
||||
SWEBENCH_FORMAT_JSONL=$PROCESS_FILEPATH
|
||||
else
|
||||
echo "The file IS NOT in SWE-bench format."
|
||||
|
||||
# ==== Convert OH format to SWE-bench format ====
|
||||
echo "Merged output file with fine-grained report will be saved to $FILE_DIR"
|
||||
poetry run python3 evaluation/benchmarks/swe_bench/scripts/eval/convert_oh_output_to_swe_json.py $PROCESS_FILEPATH
|
||||
# replace .jsonl with .swebench.jsonl in filename
|
||||
SWEBENCH_FORMAT_JSONL=${PROCESS_FILEPATH/.jsonl/.swebench.jsonl}
|
||||
echo "SWEBENCH_FORMAT_JSONL: $SWEBENCH_FORMAT_JSONL"
|
||||
# assert that the file exists
|
||||
if [ ! -f $SWEBENCH_FORMAT_JSONL ]; then
|
||||
echo "Error: $SWEBENCH_FORMAT_JSONL does not exist. There is probably an error in the conversion process."
|
||||
exit 1
|
||||
fi
|
||||
SWEBENCH_FORMAT_JSONL=$(realpath $SWEBENCH_FORMAT_JSONL)
|
||||
fi
|
||||
# ================================================
|
||||
|
||||
echo "=============================================================="
|
||||
echo "Running SWE-bench evaluation"
|
||||
echo "=============================================================="
|
||||
|
||||
RUN_ID=$(date +"%Y%m%d_%H%M%S")
|
||||
N_PROCESS=16
|
||||
|
||||
if [ -z "$INSTANCE_ID" ]; then
|
||||
echo "Running SWE-bench evaluation on the whole input file..."
|
||||
# Default to SWE-Bench-lite
|
||||
# change `--dataset_name` and `--split` to alter dataset
|
||||
|
||||
poetry run python -m visualswebench.harness.run_evaluation \
|
||||
--dataset_name "$DATASET_NAME" \
|
||||
--split "$SPLIT" \
|
||||
--predictions_path $SWEBENCH_FORMAT_JSONL \
|
||||
--timeout 1800 \
|
||||
--cache_level instance \
|
||||
--max_workers $N_PROCESS \
|
||||
--run_id $RUN_ID
|
||||
|
||||
# get the "model_name_or_path" from the first line of the SWEBENCH_FORMAT_JSONL
|
||||
MODEL_NAME_OR_PATH=$(jq -r '.model_name_or_path' $SWEBENCH_FORMAT_JSONL | head -n 1)
|
||||
echo "MODEL_NAME_OR_PATH: $MODEL_NAME_OR_PATH"
|
||||
|
||||
RESULT_OUTPUT_DIR=$(dirname $SWEBENCH_FORMAT_JSONL)
|
||||
echo "RESULT_OUTPUT_DIR: $RESULT_OUTPUT_DIR"
|
||||
|
||||
# move the eval results to the target directory
|
||||
mkdir -p $RESULT_OUTPUT_DIR
|
||||
# rm eval_outputs directory if it exists
|
||||
if [ -d $RESULT_OUTPUT_DIR/eval_outputs ]; then
|
||||
rm -rf $RESULT_OUTPUT_DIR/eval_outputs
|
||||
fi
|
||||
|
||||
mv logs/run_evaluation/$RUN_ID/$MODEL_NAME_OR_PATH $RESULT_OUTPUT_DIR
|
||||
mv $RESULT_OUTPUT_DIR/$MODEL_NAME_OR_PATH $RESULT_OUTPUT_DIR/eval_outputs
|
||||
echo "RUN_ID: $RUN_ID" > $RESULT_OUTPUT_DIR/run_id.txt
|
||||
|
||||
# move report file
|
||||
REPORT_PATH=$MODEL_NAME_OR_PATH.$RUN_ID.json
|
||||
if [ -f $REPORT_PATH ]; then
|
||||
# check if $RESULT_OUTPUT_DIR/report.json exists
|
||||
if [ -f $RESULT_OUTPUT_DIR/report.json ]; then
|
||||
echo "Report file $RESULT_OUTPUT_DIR/report.json already exists. Overwriting..."
|
||||
if [ -f $RESULT_OUTPUT_DIR/report.json.bak ]; then
|
||||
rm $RESULT_OUTPUT_DIR/report.json.bak
|
||||
fi
|
||||
mv $RESULT_OUTPUT_DIR/report.json $RESULT_OUTPUT_DIR/report.json.bak
|
||||
fi
|
||||
|
||||
mv $REPORT_PATH $RESULT_OUTPUT_DIR/report.json
|
||||
fi
|
||||
|
||||
poetry run python evaluation/benchmarks/swe_bench/scripts/eval/update_output_with_eval.py $PROCESS_FILEPATH
|
||||
|
||||
else
|
||||
echo "Running SWE-bench evaluation on the instance_id: $INSTANCE_ID"
|
||||
poetry run python -m visualswebench.harness.run_evaluation \
|
||||
--dataset_name "$DATASET_NAME" \
|
||||
--split "$SPLIT" \
|
||||
--predictions_path $SWEBENCH_FORMAT_JSONL \
|
||||
--timeout 1800 \
|
||||
--instance_ids $INSTANCE_ID \
|
||||
--cache_level instance \
|
||||
--max_workers $N_PROCESS \
|
||||
--run_id $RUN_ID
|
||||
fi
|
||||
117
evaluation/benchmarks/visual_swe_bench/scripts/run_infer.sh
Executable file
117
evaluation/benchmarks/visual_swe_bench/scripts/run_infer.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
source "evaluation/utils/version_control.sh"
|
||||
|
||||
MODEL_CONFIG=$1
|
||||
COMMIT_HASH=$2
|
||||
AGENT=$3
|
||||
EVAL_LIMIT=$4
|
||||
MAX_ITER=$5
|
||||
NUM_WORKERS=$6
|
||||
DATASET=$7
|
||||
SPLIT=$8
|
||||
N_RUNS=$9
|
||||
|
||||
if [ -z "$NUM_WORKERS" ]; then
|
||||
NUM_WORKERS=1
|
||||
echo "Number of workers not specified, use default $NUM_WORKERS"
|
||||
fi
|
||||
checkout_eval_branch
|
||||
|
||||
if [ -z "$AGENT" ]; then
|
||||
echo "Agent not specified, use default CodeActAgent"
|
||||
AGENT="CodeActAgent"
|
||||
fi
|
||||
|
||||
if [ -z "$MAX_ITER" ]; then
|
||||
echo "MAX_ITER not specified, use default 100"
|
||||
MAX_ITER=100
|
||||
fi
|
||||
|
||||
if [ -z "$USE_INSTANCE_IMAGE" ]; then
|
||||
echo "USE_INSTANCE_IMAGE not specified, use default true"
|
||||
USE_INSTANCE_IMAGE=true
|
||||
fi
|
||||
|
||||
if [ -z "$RUN_WITH_BROWSING" ]; then
|
||||
echo "RUN_WITH_BROWSING not specified, use default false"
|
||||
RUN_WITH_BROWSING=false
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$DATASET" ]; then
|
||||
echo "DATASET not specified, use default luolin101/Visual-SWE-bench"
|
||||
DATASET="luolin101/Visual-SWE-bench"
|
||||
fi
|
||||
|
||||
if [ -z "$SPLIT" ]; then
|
||||
echo "SPLIT not specified, use default test"
|
||||
SPLIT="test"
|
||||
fi
|
||||
|
||||
export USE_INSTANCE_IMAGE=$USE_INSTANCE_IMAGE
|
||||
echo "USE_INSTANCE_IMAGE: $USE_INSTANCE_IMAGE"
|
||||
export RUN_WITH_BROWSING=$RUN_WITH_BROWSING
|
||||
echo "RUN_WITH_BROWSING: $RUN_WITH_BROWSING"
|
||||
|
||||
get_openhands_version
|
||||
|
||||
echo "AGENT: $AGENT"
|
||||
echo "OPENHANDS_VERSION: $OPENHANDS_VERSION"
|
||||
echo "MODEL_CONFIG: $MODEL_CONFIG"
|
||||
echo "DATASET: $DATASET"
|
||||
echo "SPLIT: $SPLIT"
|
||||
|
||||
# Default to NOT use Hint
|
||||
if [ -z "$USE_HINT_TEXT" ]; then
|
||||
export USE_HINT_TEXT=false
|
||||
fi
|
||||
echo "USE_HINT_TEXT: $USE_HINT_TEXT"
|
||||
EVAL_NOTE="$OPENHANDS_VERSION"
|
||||
# if not using Hint, add -no-hint to the eval note
|
||||
if [ "$USE_HINT_TEXT" = false ]; then
|
||||
EVAL_NOTE="$EVAL_NOTE-no-hint"
|
||||
fi
|
||||
|
||||
if [ "$RUN_WITH_BROWSING" = true ]; then
|
||||
EVAL_NOTE="$EVAL_NOTE-with-browsing"
|
||||
fi
|
||||
|
||||
if [ -n "$EXP_NAME" ]; then
|
||||
EVAL_NOTE="$EVAL_NOTE-$EXP_NAME"
|
||||
fi
|
||||
|
||||
function run_eval() {
|
||||
local eval_note=$1
|
||||
COMMAND="poetry run python evaluation/benchmarks/visual_swe_bench/run_infer.py \
|
||||
--agent-cls $AGENT \
|
||||
--llm-config $MODEL_CONFIG \
|
||||
--max-iterations $MAX_ITER \
|
||||
--eval-num-workers $NUM_WORKERS \
|
||||
--eval-note $eval_note \
|
||||
--dataset $DATASET \
|
||||
--split $SPLIT"
|
||||
|
||||
if [ -n "$EVAL_LIMIT" ]; then
|
||||
echo "EVAL_LIMIT: $EVAL_LIMIT"
|
||||
COMMAND="$COMMAND --eval-n-limit $EVAL_LIMIT"
|
||||
fi
|
||||
|
||||
# Run the command
|
||||
eval $COMMAND
|
||||
}
|
||||
|
||||
unset SANDBOX_ENV_GITHUB_TOKEN # prevent the agent from using the github token to push
|
||||
if [ -z "$N_RUNS" ]; then
|
||||
N_RUNS=1
|
||||
echo "N_RUNS not specified, use default $N_RUNS"
|
||||
fi
|
||||
|
||||
for i in $(seq 1 $N_RUNS); do
|
||||
current_eval_note="$EVAL_NOTE-run_$i"
|
||||
echo "EVAL_NOTE: $current_eval_note"
|
||||
run_eval $current_eval_note
|
||||
done
|
||||
|
||||
checkout_original_branch
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ~/.bashrc
|
||||
SWEUTIL_DIR=/swe_util
|
||||
|
||||
# FIXME: Cannot read SWE_INSTANCE_ID from the environment variable
|
||||
# SWE_INSTANCE_ID=django__django-11099
|
||||
if [ -z "$SWE_INSTANCE_ID" ]; then
|
||||
echo "Error: SWE_INSTANCE_ID is not set." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read the swe-bench-test-lite.json file and extract the required item based on instance_id
|
||||
item=$(jq --arg INSTANCE_ID "$SWE_INSTANCE_ID" '.[] | select(.instance_id == $INSTANCE_ID)' $SWEUTIL_DIR/eval_data/instances/swe-bench-instance.json)
|
||||
|
||||
if [[ -z "$item" ]]; then
|
||||
echo "No item found for the provided instance ID."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WORKSPACE_NAME=$(echo "$item" | jq -r '(.repo | tostring) + "__" + (.version | tostring) | gsub("/"; "__")')
|
||||
|
||||
echo "WORKSPACE_NAME: $WORKSPACE_NAME"
|
||||
|
||||
# Clear the workspace
|
||||
if [ -d /workspace ]; then
|
||||
rm -rf /workspace/*
|
||||
else
|
||||
mkdir /workspace
|
||||
fi
|
||||
# Copy repo to workspace
|
||||
if [ -d /workspace/$WORKSPACE_NAME ]; then
|
||||
rm -rf /workspace/$WORKSPACE_NAME
|
||||
fi
|
||||
mkdir -p /workspace
|
||||
cp -r /testbed /workspace/$WORKSPACE_NAME
|
||||
|
||||
# Activate instance-specific environment
|
||||
. /opt/miniconda3/etc/profile.d/conda.sh
|
||||
conda activate testbed
|
||||
Reference in New Issue
Block a user