Skip to content

Commit e87ab9a

Browse files
committed
fixed all type errors
1 parent 4a33937 commit e87ab9a

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

commit0/harness/run_pytest_ids.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ def main(
8484
log_file = log_dir / "run_pytest.log"
8585
logger = setup_logger(repo_name, log_file, verbose=verbose)
8686

87-
if not isinstance(
88-
example, SimpleInstance
89-
): # if dataset_type is not simple, load git repo
87+
if isinstance(example, RepoInstance):
9088
try:
9189
local_repo = git.Repo(repo_or_repo_dir)
9290
logger.info(f"Loaded a git repo from {repo_or_repo_dir}")
@@ -130,7 +128,33 @@ def main(
130128
raise Exception(
131129
f"Branch {branch} does not exist locally or remotely."
132130
)
133-
if isinstance(example, SimpleInstance):
131+
132+
# make patch file
133+
if "swe" in dataset_name.lower():
134+
if branch == "reference":
135+
patch = (
136+
example["test"]["patch"] + "\n\n" + example["test"]["test_patch"]
137+
)
138+
else:
139+
patch = generate_patch_between_commits(
140+
local_repo, example["base_commit"], commit_id
141+
)
142+
patch += "\n\n" + example["test"]["test_patch"]
143+
else:
144+
patch = generate_patch_between_commits(
145+
local_repo, example["base_commit"], commit_id
146+
)
147+
148+
# make eval file
149+
if coverage:
150+
coverage_text = (
151+
f" --cov={example['src_dir']} --cov-branch --cov-report json"
152+
)
153+
else:
154+
coverage_text = ""
155+
eval_script = spec.eval_script.format(test_ids=test_ids, coverage=coverage_text)
156+
157+
else: # if example is of type SimpleInstance
134158
if branch == "reference":
135159
patch = (
136160
example["prompt"]
@@ -150,32 +174,10 @@ def main(
150174
solution = example["prompt"] + "\n\n" + solution
151175
patch = solution + "\n\n" + example["test"]
152176
patch = patch + "\n\n" + f"check({example['entry_point']})"
153-
elif "swe" in dataset_name.lower():
154-
if branch == "reference":
155-
patch = example["test"]["patch"] + "\n\n" + example["test"]["test_patch"]
156-
else:
157-
patch = generate_patch_between_commits(
158-
local_repo, example["base_commit"], commit_id
159-
)
160-
patch += "\n\n" + example["test"]["test_patch"]
161-
else:
162-
patch = generate_patch_between_commits(
163-
local_repo, example["base_commit"], commit_id
164-
)
177+
eval_script = spec.eval_script
178+
165179
patch_file = Path(log_dir / "patch.diff")
166180
patch_file.write_text(patch, encoding="utf-8", errors="ignore")
167-
168-
if not isinstance(example, SimpleInstance):
169-
# make eval file
170-
if coverage:
171-
coverage_text = (
172-
f" --cov={example['src_dir']} --cov-branch --cov-report json"
173-
)
174-
else:
175-
coverage_text = ""
176-
eval_script = spec.eval_script.format(test_ids=test_ids, coverage=coverage_text)
177-
else:
178-
eval_script = spec.eval_script
179181
eval_file = Path(log_dir / "eval.sh")
180182
eval_file.write_text(eval_script)
181183

0 commit comments

Comments
 (0)