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: issues of 'harness' in Windows #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion swebench/harness/docker_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions swebench/harness/dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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/
Expand Down
10 changes: 6 additions & 4 deletions swebench/harness/run_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions swebench/harness/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import posixpath
from pathlib import Path
import re
import requests
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down