Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct some typings and a incorrect function call #186

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading