From 972d61e100dadc6cb841c21ee41591eda01e8086 Mon Sep 17 00:00:00 2001 From: yuxqiu Date: Sun, 21 Jul 2024 18:51:55 +0800 Subject: [PATCH 1/2] fix: correct some typings --- swebench/harness/test_spec.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/swebench/harness/test_spec.py b/swebench/harness/test_spec.py index b59db676..2f3401be 100644 --- a/swebench/harness/test_spec.py +++ b/swebench/harness/test_spec.py @@ -4,7 +4,7 @@ import re from dataclasses import dataclass -from typing import Any, Union +from typing import Any, Union, cast from swebench.harness.constants import ( SWEbenchInstance, @@ -37,9 +37,9 @@ class TestSpec: instance_id: str repo: str version: str - repo_script_list: str - eval_script_list: str - env_script_list: str + repo_script_list: list[str] + eval_script_list: list[str] + env_script_list: list[str] arch: str FAIL_TO_PASS: list[str] PASS_TO_PASS: list[str] @@ -104,15 +104,15 @@ def platform(self): return "linux/arm64/v8" else: raise ValueError(f"Invalid architecture: {self.arch}") - + def get_test_specs_from_dataset(dataset: Union[list[SWEbenchInstance], list[TestSpec]]) -> list[TestSpec]: """ Idempotent function that converts a list of SWEbenchInstance objects to a list of TestSpec objects. """ if isinstance(dataset[0], TestSpec): - return dataset - return list(map(make_test_spec, dataset)) + return cast(list[TestSpec], dataset) + return list(map(make_test_spec, cast(list[SWEbenchInstance], dataset))) def make_repo_script_list(specs, repo, repo_directory, base_commit, env_name): From fbf9674da9b02300ba3b0208aa556a761c809207 Mon Sep 17 00:00:00 2001 From: yuxqiu Date: Sun, 21 Jul 2024 18:53:36 +0800 Subject: [PATCH 2/2] fix: incorrect call to `find_dependent_images` --- swebench/harness/docker_build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swebench/harness/docker_build.py b/swebench/harness/docker_build.py index 9d8fb64c..3f71ed84 100644 --- a/swebench/harness/docker_build.py +++ b/swebench/harness/docker_build.py @@ -239,7 +239,7 @@ def get_env_configs_to_build( if env_image.attrs["Created"] < base_image.attrs["Created"]: # Remove the environment image if it was built after the base_image - for dep in find_dependent_images(env_image): + for dep in find_dependent_images(client, test_spec.env_image_key): # Remove instance images that depend on this environment image remove_image(client, dep.image_id, "quiet") remove_image(client, test_spec.env_image_key, "quiet") @@ -339,7 +339,7 @@ def build_instance_images( ): """ Builds the instance images required for the dataset if they do not already exist. - + Args: dataset (list): List of test specs or dataset to build images for client (docker.DockerClient): Docker client to use for building the images