Skip to content

Commit 29ba219

Browse files
committed
other integration
1 parent a3f8311 commit 29ba219

File tree

7 files changed

+57
-17
lines changed

7 files changed

+57
-17
lines changed

commit0/cli.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33
from typing import Union, List
44
from typing_extensions import Annotated
5+
from datasets import load_dataset
56
import commit0.harness.run_pytest_ids
67
import commit0.harness.get_pytest_ids
78
import commit0.harness.build
@@ -118,7 +119,11 @@ def setup(
118119
) -> None:
119120
"""Commit0 clone a repo split."""
120121
check_commit0_path()
121-
check_valid(repo_split, SPLIT)
122+
if "swe" in dataset_name.lower():
123+
SWE_SPLIT = load_dataset(dataset_name, split=dataset_split)["instance_id"]
124+
check_valid(repo_split, SWE_SPLIT)
125+
else:
126+
check_valid(repo_split, SPLIT)
122127

123128
base_dir = str(Path(base_dir).resolve())
124129

@@ -168,7 +173,11 @@ def build(
168173
check_commit0_path()
169174

170175
commit0_config = read_commit0_dot_file(commit0_dot_file_path)
171-
check_valid(commit0_config["repo_split"], SPLIT)
176+
if "swe" in commit0_config["dataset_name"].lower():
177+
SWE_SPLIT = load_dataset(commit0_config["dataset_name"], split=commit0_config["dataset_split"])["instance_id"]
178+
check_valid(commit0_config["repo_split"], SWE_SPLIT)
179+
else:
180+
check_valid(commit0_config["repo_split"], SPLIT)
172181

173182
typer.echo(
174183
f"Building repository for split: {highlight(commit0_config['repo_split'], Colors.ORANGE)}"
@@ -199,7 +208,8 @@ def get_tests(
199208
) -> None:
200209
"""Get tests for a Commit0 repository."""
201210
check_commit0_path()
202-
check_valid(repo_name, SPLIT_ALL)
211+
SWE_SPLIT = load_dataset("princeton-nlp/SWE-bench_Verified", split="test")["instance_id"]
212+
check_valid(repo_name, SPLIT_ALL+SWE_SPLIT)
203213

204214
commit0.harness.get_pytest_ids.main(repo_name, verbose=1)
205215

@@ -247,11 +257,14 @@ def test(
247257
) -> None:
248258
"""Run tests on a Commit0 repository."""
249259
check_commit0_path()
260+
commit0_config = read_commit0_dot_file(commit0_dot_file_path)
250261
if repo_or_repo_path.endswith("/"):
251262
repo_or_repo_path = repo_or_repo_path[:-1]
252-
check_valid(repo_or_repo_path.split("/")[-1], SPLIT_ALL)
253-
254-
commit0_config = read_commit0_dot_file(commit0_dot_file_path)
263+
if "swe" in commit0_config["dataset_name"].lower():
264+
SWE_SPLIT = load_dataset(commit0_config["dataset_name"], split=commit0_config["dataset_split"])["instance_id"]
265+
check_valid(repo_or_repo_path.split("/")[-1], SWE_SPLIT)
266+
else:
267+
check_valid(repo_or_repo_path.split("/")[-1], SPLIT)
255268

256269
if reference:
257270
branch = "reference"
@@ -316,7 +329,11 @@ def evaluate(
316329
branch = "reference"
317330

318331
commit0_config = read_commit0_dot_file(commit0_dot_file_path)
319-
check_valid(commit0_config["repo_split"], SPLIT)
332+
if "swe" in commit0_config["dataset_name"].lower():
333+
SWE_SPLIT = load_dataset(commit0_config["dataset_name"], split=commit0_config["dataset_split"])["instance_id"]
334+
check_valid(commit0_config["repo_split"], SWE_SPLIT)
335+
else:
336+
check_valid(commit0_config["repo_split"], SPLIT)
320337

321338
typer.echo(f"Evaluating repository split: {commit0_config['repo_split']}")
322339
typer.echo(f"Branch: {branch}")
@@ -391,7 +408,11 @@ def save(
391408
"""Save Commit0 split you choose in Setup Stage to GitHub."""
392409
check_commit0_path()
393410
commit0_config = read_commit0_dot_file(commit0_dot_file_path)
394-
check_valid(commit0_config["repo_split"], SPLIT)
411+
if "swe" in commit0_config["dataset_name"].lower():
412+
SWE_SPLIT = load_dataset(commit0_config["dataset_name"], split=commit0_config["dataset_split"])["instance_id"]
413+
check_valid(commit0_config["repo_split"], SWE_SPLIT)
414+
else:
415+
check_valid(commit0_config["repo_split"], SPLIT)
395416

396417
typer.echo(f"Saving repository split: {commit0_config['repo_split']}")
397418
typer.echo(f"Owner: {owner}")

commit0/harness/build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ def main(
2525
specs = []
2626
for example in dataset:
2727
repo_name = example["repo"].split("/")[-1]
28-
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
29-
continue
28+
if "swe" in dataset_name.lower():
29+
if repo_split != "all" and example["instance_id"] != repo_split:
30+
continue
31+
else:
32+
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
33+
continue
3034
spec = make_spec(example)
3135
specs.append(spec)
3236

commit0/harness/evaluate.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ def main(
3737
log_dirs = []
3838
for example in dataset:
3939
repo_name = example["repo"].split("/")[-1]
40-
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
41-
continue
40+
if "swe" in dataset_name.lower():
41+
if repo_split != "all" and example["instance_id"] != repo_split:
42+
continue
43+
else:
44+
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
45+
continue
4246
hashed_test_ids = get_hash_string(example["test"]["test_dir"])
4347
if branch is None:
4448
git_path = os.path.join(base_dir, repo_name)

commit0/harness/run_pytest_ids.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def main(
5151
example = None
5252
repo_name = None
5353
for example in dataset:
54-
repo_name = example["repo"].split("/")[-1]
54+
if "swe" in dataset_name.lower():
55+
repo_name = example["instance_id"]
56+
else:
57+
repo_name = example["repo"].split("/")[-1]
5558
if repo_or_repo_dir.endswith("/"):
5659
repo_or_repo_dir = repo_or_repo_dir[:-1]
5760
if repo_name in os.path.basename(repo_or_repo_dir):

commit0/harness/save.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ def main(
3030
dataset: Iterator[RepoInstance] = load_dataset(dataset_name, split=dataset_split) # type: ignore
3131
for example in dataset:
3232
repo_name = example["repo"].split("/")[-1]
33-
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
34-
continue
33+
if "swe" in dataset_name.lower():
34+
if repo_split != "all" and example["instance_id"] != repo_split:
35+
continue
36+
else:
37+
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
38+
continue
3539
local_repo_path = f"{base_dir}/{repo_name}"
3640
github_repo_url = f"https://github.com/{owner}/{repo_name}.git"
3741
github_repo_url = github_repo_url.replace(

commit0/harness/setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ def main(
2525
dataset: Iterator[RepoInstance] = load_dataset(dataset_name, split=dataset_split) # type: ignore
2626
for example in dataset:
2727
repo_name = example["repo"].split("/")[-1]
28-
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
29-
continue
3028
clone_url = f"https://github.com/{example['repo']}.git"
3129
if "swe" in dataset_name.lower():
30+
if repo_split != "all" and example["instance_id"] != repo_split:
31+
continue
3232
clone_dir = os.path.abspath(os.path.join(base_dir, example["instance_id"]))
3333
branch = example["base_commit"]
3434
else:
35+
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
36+
continue
3537
clone_dir = os.path.abspath(os.path.join(base_dir, repo_name))
3638
branch = dataset_name.split("/")[-1]
3739
repo = clone_repo(clone_url, clone_dir, branch, logger)

commit0/harness/spec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ def make_repo_script_list(instance: RepoInstance, repo_directory: str) -> list[s
138138
setup_commands.append(cmd)
139139

140140
if "install" in specs and specs["install"] is not None:
141+
if specs["install"].startswith("python -m pip install"):
142+
specs["install"] = specs["install"].replace("python -m ", "")
141143
if specs["install"].startswith("pip"):
142144
install = "uv " + specs["install"]
143145
else:

0 commit comments

Comments
 (0)