diff --git a/swebench/harness/docker_build.py b/swebench/harness/docker_build.py index 5bd3bca7..df807a58 100644 --- a/swebench/harness/docker_build.py +++ b/swebench/harness/docker_build.py @@ -52,7 +52,7 @@ def setup_logger(instance_id: str, log_file: Path, mode="w"): """ log_file.parent.mkdir(parents=True, exist_ok=True) logger = logging.getLogger(f"{instance_id}.{log_file.name}") - handler = logging.FileHandler(log_file, mode=mode) + handler = logging.FileHandler(log_file, mode=mode, encoding='utf-8') formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) diff --git a/swebench/harness/dockerfiles.py b/swebench/harness/dockerfiles.py index bea24378..b192d0d2 100644 --- a/swebench/harness/dockerfiles.py +++ b/swebench/harness/dockerfiles.py @@ -36,6 +36,7 @@ _DOCKERFILE_ENV = r"""FROM --platform={platform} sweb.base.{arch}:latest COPY ./setup_env.sh /root/ +RUN sed -i -e 's/\r$//' /root/setup_env.sh RUN chmod +x /root/setup_env.sh RUN /bin/bash -c "source ~/.bashrc && /root/setup_env.sh" @@ -48,6 +49,7 @@ _DOCKERFILE_INSTANCE = r"""FROM --platform={platform} {env_image_name} COPY ./setup_repo.sh /root/ +RUN sed -i -e 's/\r$//' /root/setup_repo.sh RUN /bin/bash /root/setup_repo.sh WORKDIR /testbed/ diff --git a/swebench/harness/run_evaluation.py b/swebench/harness/run_evaluation.py index ff986f38..59786b00 100644 --- a/swebench/harness/run_evaluation.py +++ b/swebench/harness/run_evaluation.py @@ -2,12 +2,13 @@ import docker import json -import resource +import platform +if platform.system() == 'Linux': import resource import traceback from argparse import ArgumentParser from concurrent.futures import ThreadPoolExecutor, as_completed -from pathlib import Path +from pathlib import Path,PurePosixPath from tqdm import tqdm from swebench.harness.constants import ( @@ -121,7 +122,7 @@ def run_instance( logger.info( f"Intermediate patch for {instance_id} written to {patch_file}, now applying to container..." ) - copy_to_container(container, patch_file, Path(DOCKER_PATCH)) + copy_to_container(container, patch_file, PurePosixPath(DOCKER_PATCH)) # Attempt to apply patch to container val = container.exec_run( @@ -511,7 +512,8 @@ def main( """ # set open file limit assert len(run_id) > 0, "Run ID must be provided" - resource.setrlimit(resource.RLIMIT_NOFILE, (open_file_limit, open_file_limit)) + if platform.system() == 'Linux': + resource.setrlimit(resource.RLIMIT_NOFILE, (open_file_limit, open_file_limit)) client = docker.from_env() # load predictions as map of instance_id to prediction diff --git a/swebench/harness/utils.py b/swebench/harness/utils.py index a0f76d7c..9a5b7af9 100644 --- a/swebench/harness/utils.py +++ b/swebench/harness/utils.py @@ -1,5 +1,6 @@ import json import os +import posixpath from pathlib import Path import re import requests @@ -176,7 +177,7 @@ def get_lines_with_word(text, target_word): @cache def get_environment_yml_by_commit(repo: str, commit: str, env_name: str) -> str: for req_path in MAP_REPO_TO_ENV_YML_PATHS[repo]: - reqs_url = os.path.join(SWE_BENCH_URL_RAW, repo, commit, req_path) + reqs_url = posixpath.join(SWE_BENCH_URL_RAW, repo, commit, req_path) reqs = requests.get(reqs_url, headers=HEADERS) if reqs.status_code == 200: break @@ -221,7 +222,7 @@ def get_environment_yml(instance: SWEbenchInstance, env_name: str) -> str: @cache def get_requirements_by_commit(repo: str, commit: str) -> str: for req_path in MAP_REPO_TO_REQS_PATHS[repo]: - reqs_url = os.path.join(SWE_BENCH_URL_RAW, repo, commit, req_path) + reqs_url = posixpath.join(SWE_BENCH_URL_RAW, repo, commit, req_path) reqs = requests.get(reqs_url, headers=HEADERS) if reqs.status_code == 200: break