diff --git a/swebench/harness/docker_build.py b/swebench/harness/docker_build.py index d7bcf8ee..7eb490b2 100644 --- a/swebench/harness/docker_build.py +++ b/swebench/harness/docker_build.py @@ -1,7 +1,10 @@ +from __future__ import annotations + import logging import re import traceback import docker +import docker.errors from tqdm import tqdm from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path @@ -315,8 +318,8 @@ def build_env_images( traceback.print_exc() failed.append(futures[future]) continue - except Exception as e: - print(f"Error building image") + except Exception: + print("Error building image") traceback.print_exc() failed.append(futures[future]) continue @@ -390,8 +393,8 @@ def build_instance_images( traceback.print_exc() failed.append(futures[future]) continue - except Exception as e: - print(f"Error building image") + except Exception: + print("Error building image") traceback.print_exc() failed.append(futures[future]) continue @@ -409,7 +412,7 @@ def build_instance_images( def build_instance_image( test_spec: TestSpec, client: docker.DockerClient, - logger: logging.Logger, + logger: logging.Logger|None, nocache: bool, ): """ diff --git a/swebench/harness/docker_utils.py b/swebench/harness/docker_utils.py index 1ab186b3..2a1dddf2 100644 --- a/swebench/harness/docker_utils.py +++ b/swebench/harness/docker_utils.py @@ -1,6 +1,7 @@ from __future__ import annotations import docker +import docker.errors import os import signal import tarfile @@ -284,7 +285,7 @@ def clean_images( """ images = list_images(client) removed = 0 - print(f"Cleaning cached images...") + print("Cleaning cached images...") for image_name in images: if should_remove(image_name, cache_level, clean, prior_images): try: diff --git a/swebench/harness/test_spec.py b/swebench/harness/test_spec.py index 959b34bd..109e24e5 100644 --- a/swebench/harness/test_spec.py +++ b/swebench/harness/test_spec.py @@ -128,11 +128,11 @@ def make_repo_script_list(specs, repo, repo_directory, base_commit, env_name): f"cd {repo_directory}", f"git reset --hard {base_commit}", # Remove the remote so the agent won't see newer commits. - f"git remote remove origin", + "git remote remove origin", # Make sure conda is available for later use "source /opt/miniconda3/bin/activate", f"conda activate {env_name}", - f'echo "Current environment: $CONDA_DEFAULT_ENV"', + 'echo "Current environment: $CONDA_DEFAULT_ENV"', ] if repo in MAP_REPO_TO_INSTALL: setup_commands.append(MAP_REPO_TO_INSTALL[repo]) @@ -254,7 +254,7 @@ def make_eval_script_list(instance, specs, env_name, repo_directory, base_commit ] ) eval_commands = [ - f"source /opt/miniconda3/bin/activate", + "source /opt/miniconda3/bin/activate", f"conda activate {env_name}", f"cd {repo_directory}", ] @@ -264,8 +264,8 @@ def make_eval_script_list(instance, specs, env_name, repo_directory, base_commit f"git config --global --add safe.directory {repo_directory}", # for nonroot user f"cd {repo_directory}", # This is just informational, so we have a record - f"git status", - f"git show", + "git status", + "git show", f"git diff {base_commit}", "source /opt/miniconda3/bin/activate", f"conda activate {env_name}",