Skip to content

Commit

Permalink
Merge pull request #186 from yuxqiu/typings
Browse files Browse the repository at this point in the history
fix: correct some typings and a incorrect function call
  • Loading branch information
john-b-yang committed Jul 22, 2024
2 parents 4c21a48 + fbf9674 commit f3dba57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions swebench/harness/docker_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions swebench/harness/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f3dba57

Please sign in to comment.