@@ -84,9 +84,7 @@ def main(
84
84
log_file = log_dir / "run_pytest.log"
85
85
logger = setup_logger (repo_name , log_file , verbose = verbose )
86
86
87
- if not isinstance (
88
- example , SimpleInstance
89
- ): # if dataset_type is not simple, load git repo
87
+ if isinstance (example , RepoInstance ):
90
88
try :
91
89
local_repo = git .Repo (repo_or_repo_dir )
92
90
logger .info (f"Loaded a git repo from { repo_or_repo_dir } " )
@@ -130,7 +128,33 @@ def main(
130
128
raise Exception (
131
129
f"Branch { branch } does not exist locally or remotely."
132
130
)
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
134
158
if branch == "reference" :
135
159
patch = (
136
160
example ["prompt" ]
@@ -150,32 +174,10 @@ def main(
150
174
solution = example ["prompt" ] + "\n \n " + solution
151
175
patch = solution + "\n \n " + example ["test" ]
152
176
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
+
165
179
patch_file = Path (log_dir / "patch.diff" )
166
180
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
179
181
eval_file = Path (log_dir / "eval.sh" )
180
182
eval_file .write_text (eval_script )
181
183
0 commit comments