|
2 | 2 | from pathlib import Path |
3 | 3 | from typing import Union, List |
4 | 4 | from typing_extensions import Annotated |
| 5 | +from datasets import load_dataset |
5 | 6 | import commit0.harness.run_pytest_ids |
6 | 7 | import commit0.harness.get_pytest_ids |
7 | 8 | import commit0.harness.build |
@@ -118,7 +119,11 @@ def setup( |
118 | 119 | ) -> None: |
119 | 120 | """Commit0 clone a repo split.""" |
120 | 121 | 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) |
122 | 127 |
|
123 | 128 | base_dir = str(Path(base_dir).resolve()) |
124 | 129 |
|
@@ -168,7 +173,11 @@ def build( |
168 | 173 | check_commit0_path() |
169 | 174 |
|
170 | 175 | 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) |
172 | 181 |
|
173 | 182 | typer.echo( |
174 | 183 | f"Building repository for split: {highlight(commit0_config['repo_split'], Colors.ORANGE)}" |
@@ -199,7 +208,8 @@ def get_tests( |
199 | 208 | ) -> None: |
200 | 209 | """Get tests for a Commit0 repository.""" |
201 | 210 | 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) |
203 | 213 |
|
204 | 214 | commit0.harness.get_pytest_ids.main(repo_name, verbose=1) |
205 | 215 |
|
@@ -247,11 +257,14 @@ def test( |
247 | 257 | ) -> None: |
248 | 258 | """Run tests on a Commit0 repository.""" |
249 | 259 | check_commit0_path() |
| 260 | + commit0_config = read_commit0_dot_file(commit0_dot_file_path) |
250 | 261 | if repo_or_repo_path.endswith("/"): |
251 | 262 | 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) |
255 | 268 |
|
256 | 269 | if reference: |
257 | 270 | branch = "reference" |
@@ -316,7 +329,11 @@ def evaluate( |
316 | 329 | branch = "reference" |
317 | 330 |
|
318 | 331 | 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) |
320 | 337 |
|
321 | 338 | typer.echo(f"Evaluating repository split: {commit0_config['repo_split']}") |
322 | 339 | typer.echo(f"Branch: {branch}") |
@@ -391,7 +408,11 @@ def save( |
391 | 408 | """Save Commit0 split you choose in Setup Stage to GitHub.""" |
392 | 409 | check_commit0_path() |
393 | 410 | 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) |
395 | 416 |
|
396 | 417 | typer.echo(f"Saving repository split: {commit0_config['repo_split']}") |
397 | 418 | typer.echo(f"Owner: {owner}") |
|
0 commit comments