Skip to content

Commit 83a3869

Browse files
committed
getting through all repos
1 parent 30556e0 commit 83a3869

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

commit0/harness/spec.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def repo_image_key(self) -> str:
5151
hash_object.update(str(self.setup_script).encode("utf-8"))
5252
hash_value = hash_object.hexdigest()
5353
val = hash_value[:22] # 22 characters is still very likely to be unique
54-
repo = self.repo.split("/")[-1]
54+
repo = self.repo.split("/")[-1].split('__')[-1].split('-')[0]
5555
# this is the image name created locally
5656
# once this image created, it will be tagged with repo_image_tag
5757
return f"commit0.repo.{repo}.{val}:v0".lower()
@@ -60,7 +60,15 @@ def repo_image_key(self) -> str:
6060
def repo_image_tag(self) -> str:
6161
"""Repo image tag that will be used throughout."""
6262
repo = self.repo.split("/")[-1]
63-
return f"wentingzhao/{repo}:v0".lower()
63+
tag = f"wentingzhao/{repo}:v0".lower()
64+
if '__' in repo: # this is a swebench instance
65+
repo = repo.split('__')[-1].split('-')[0]
66+
hash_object = hashlib.sha256()
67+
hash_object.update(str(self.setup_script).encode("utf-8"))
68+
hash_value = hash_object.hexdigest()
69+
val = hash_value[:22] # 22 characters is still very likely to be unique
70+
tag = f"wentingzhao/{repo}.{val}:v0".lower()
71+
return tag
6472

6573
def get_container_name(self, run_id: Optional[str] = None) -> str:
6674
repo = self.repo.split("/")[-1]
@@ -106,7 +114,6 @@ def make_repo_script_list(instance: RepoInstance, repo_directory: str) -> list[s
106114
f"git clone -o origin https://github.com/{repo} {repo_directory}",
107115
f"chmod -R 777 {repo_directory}", # So nonroot user can run tests
108116
f"cd {repo_directory}",
109-
f"git reset --hard {env_setup_commit}",
110117
# Remove the remote so the agent won't see newer commits.
111118
"git remote remove origin",
112119
f"uv venv --python {specs['python']}",
@@ -155,33 +162,34 @@ def make_repo_script_list(instance: RepoInstance, repo_directory: str) -> list[s
155162
pip_packages = " ".join(pip_packages)
156163
cmd = f"uv pip install {pip_packages}"
157164
setup_commands.append(cmd)
158-
159-
if "install" in specs and specs["install"] is not None:
160-
if specs["install"].startswith("python -m pip install"):
161-
specs["install"] = specs["install"].replace("python -m ", "")
162-
if specs["install"].startswith("pip"):
163-
install = "uv " + specs["install"]
164-
elif specs["install"].startswith("python setup.py"):
165-
install = specs["install"].replace("python ", "uv run ")
166-
else:
167-
raise ValueError(
168-
f"install command should always start with pip or python setup.py, but you have {specs['install']}"
169-
)
170-
setup_commands.append(install)
171165
setup_commands.append(
172166
"uv pip install -U pytest pytest-cov coverage pytest-json-report"
173167
)
174-
setup_commands.append(f"git reset --hard {base_commit}")
175168
return setup_commands
176169

177170

178171
def make_eval_script_list(instance: RepoInstance, repo_directory: str) -> list[str]:
179172
"""Run the tests."""
173+
specs = instance["setup"]
174+
if "install" in specs and specs["install"] is not None:
175+
installs = specs["install"].split('; ')
176+
results = []
177+
for one in installs:
178+
if one.startswith("python -m pip install"):
179+
install = one.replace("python -m ", "")
180+
else:
181+
install = one
182+
if install.startswith("pip"):
183+
install = "uv " + install
184+
elif install.startswith("python setup.py"):
185+
install = install.replace("python ", "uv run ")
186+
results.append(install)
180187
eval_script_list = [
181188
f"cd {repo_directory}",
182189
"source .venv/bin/activate",
183190
f"git reset --hard {instance['base_commit']}",
184191
"git apply --allow-empty -v /patch.diff",
192+
] + results + [
185193
"git status",
186194
f"{instance['test']['test_cmd']} --json-report --json-report-file=report.json --continue-on-collection-errors{{coverage}} {{test_ids}} > test_output.txt 2>&1",
187195
"echo $? > pytest_exit_code.txt",

0 commit comments

Comments
 (0)