| 6 | |
| 7 | class SWEBench(BaseTask): |
| 8 | def __init__(self, logdir, split, _type="patch", **kwargs): |
| 9 | self.max_repetitions = kwargs.get("max_repetitions", 3) |
| 10 | self.task_template = """You need to identify the cause of the following github issue, collect the relevant information, and provide a solution. |
| 11 | Github Issue: ```{issue}```""" |
| 12 | |
| 13 | self.logdir = logdir |
| 14 | self.dataset = load_dataset("princeton-nlp/SWE-bench_Verified")[split] |
| 15 | |
| 16 | client = docker.from_env() |
| 17 | |
| 18 | successful, failed = build_instance_images( |
| 19 | client=client, |
| 20 | dataset=self.dataset, |
| 21 | force_rebuild=False, |
| 22 | max_workers=12, |
| 23 | ) |
| 24 | |
| 25 | self.images = {specs.instance_id: specs.instance_image_key for specs in successful} |
| 26 | self.dataset = self.dataset.filter(lambda x: x["instance_id"] in [specs.instance_id for specs in successful]) |
| 27 | self.setup_scripts = ["\n".join(["#!/bin/bash", "set -euxo pipefail"] + specs.env_script_list) + "\n" for specs in successful] |
| 28 | |
| 29 | |
| 30 | def construct_prompt(self, idx): |