Skip to content

Commit 8b3464e

Browse files
committed
pre-commit
1 parent f14cc45 commit 8b3464e

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

commit0/harness/build.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import json
21
import logging
3-
import traceback
42

53
import docker
64
from datasets import load_dataset
7-
from tqdm import tqdm
85
from typing import Iterator
96

10-
from commit0.harness.constants import EVAL_BACKENDS, RepoInstance, SPLIT
7+
from commit0.harness.constants import RepoInstance, SPLIT
118
from commit0.harness.docker_build import build_repo_images
129
from commit0.harness.spec import make_spec
1310

@@ -37,4 +34,5 @@ def main(
3734
client = docker.from_env()
3835
build_repo_images(client, specs, num_workers)
3936

37+
4038
__all__ = []

commit0/harness/run_pytest_ids.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def main(
6666
else:
6767
local_branch = local_repo.branches[branch]
6868
commit_id = local_branch.commit.hexsha
69-
patch = generate_patch_between_commits(local_repo, example["base_commit"], commit_id)
69+
patch = generate_patch_between_commits(
70+
local_repo, example["base_commit"], commit_id
71+
)
7072
patch_file = Path(log_dir / "patch.diff")
7173
patch_file.write_text(patch)
7274

@@ -84,7 +86,10 @@ def main(
8486
f"Evaluation must be from {', '.join(EVAL_BACKENDS)}, but {backend} is provided."
8587
)
8688

87-
files_to_copy = Files(eval_script={"src": eval_file, "dest": Path("/eval.sh")}, patch={"src": patch_file, "dest": Path("/patch.diff")})
89+
files_to_copy = Files(
90+
eval_script={"src": eval_file, "dest": Path("/eval.sh")},
91+
patch={"src": patch_file, "dest": Path("/patch.diff")},
92+
)
8893

8994
try:
9095
with execution_context(spec, logger, timeout, files_to_copy) as context:

commit0/harness/utils.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22
import git.exc
33
import hashlib
44
import logging
5-
import socket
65
import os
76
import time
8-
import requests
9-
import subprocess
10-
import pwd
11-
from typing import Optional, Tuple
7+
from typing import Optional
128

139
from fastcore.net import HTTP404NotFoundError, HTTP403ForbiddenError # type: ignore
1410
from ghapi.core import GhApi
15-
from commit0.harness.constants import EVAL_BACKENDS
1611

1712

1813
class EvaluationError(Exception):
@@ -168,25 +163,31 @@ def create_repo_on_github(
168163
break
169164

170165

171-
def generate_patch_between_commits(repo: git.Repo, old_commit: str, new_commit: str) -> str:
172-
"""
173-
Generate a patch string by comparing two specified commits.
166+
def generate_patch_between_commits(
167+
repo: git.Repo, old_commit: str, new_commit: str
168+
) -> str:
169+
"""Generate a patch string by comparing two specified commits.
174170
175171
Args:
172+
----
176173
repo (git.Repo): An instance of the git.Repo object representing the repository.
177174
old_commit (str): The hash or reference to the old commit.
178175
new_commit (str): The hash or reference to the new commit.
179176
180177
Returns:
178+
-------
181179
patch (str): A string containing the patch in the diff format between the two commits
182180
183181
Raises:
182+
------
184183
git.GitCommandError: If there is an error while running git commands.
184+
185185
"""
186186
try:
187-
patch = repo.git.diff(old_commit, new_commit, '--', '.', ':(exclude)spec.pdf')
188-
return patch+'\n\n'
187+
patch = repo.git.diff(old_commit, new_commit, "--", ".", ":(exclude)spec.pdf")
188+
return patch + "\n\n"
189189
except git.GitCommandError as e:
190190
raise Exception(f"Error generating patch: {e}")
191191

192+
192193
__all__ = []

0 commit comments

Comments
 (0)