Skip to content

Commit 0c9fc0f

Browse files
authored
Align Multi-SWE patch extraction with upstream (#1523)
* Align Multi-SWE patch extraction with upstream * Group Multi-SWE taskset files
1 parent e1e3f12 commit 0c9fc0f

4 files changed

Lines changed: 68 additions & 41 deletions

File tree

verifiers/envs/experimental/composable/tasksets/swe/create_fix_patch.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .taskset import MultiSWERubric, MultiSWETaskSet, restore_row
2+
3+
__all__ = ["MultiSWERubric", "MultiSWETaskSet", "restore_row"]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Generate /home/fix.patch from the current working-tree diff using the same
4+
# fix_patch/test_patch path split as upstream Multi-SWE dataset construction.
5+
6+
set -euo pipefail
7+
8+
REPO_DIR="${1:-$(pwd)}"
9+
BASE_COMMIT="${2:-HEAD}"
10+
OUTPUT_PATH="${3:-/home/fix.patch}"
11+
cd "$REPO_DIR"
12+
13+
if [ -z "$BASE_COMMIT" ]; then
14+
BASE_COMMIT="HEAD"
15+
fi
16+
17+
FIX_FILES=()
18+
TEST_FILES=()
19+
UNTRACKED_FILES=()
20+
21+
while IFS= read -r -d '' file; do
22+
UNTRACKED_FILES+=("$file")
23+
done < <(git ls-files --others --exclude-standard -z)
24+
25+
if [ "${#UNTRACKED_FILES[@]}" -gt 0 ]; then
26+
git add --intent-to-add -- "${UNTRACKED_FILES[@]}"
27+
fi
28+
29+
while IFS= read -r -d '' file; do
30+
lowered="$(printf '%s' "$file" | tr '[:upper:]' '[:lower:]')"
31+
if [[ "$lowered" == *"test"* ]] || [[ "$lowered" == *"tests"* ]] || [[ "$lowered" == *"e2e"* ]] || [[ "$lowered" == *"testing"* ]]; then
32+
TEST_FILES+=("$file")
33+
else
34+
FIX_FILES+=("$file")
35+
fi
36+
done < <(git diff --name-only -z "$BASE_COMMIT" --)
37+
38+
if [ "${#FIX_FILES[@]}" -eq 0 ]; then
39+
: > "$OUTPUT_PATH"
40+
else
41+
git diff --binary "$BASE_COMMIT" -- "${FIX_FILES[@]}" > "$OUTPUT_PATH"
42+
fi
43+
44+
if [ "${#TEST_FILES[@]}" -gt 0 ]; then
45+
printf 'Dropped %d test-like file(s) from Multi-SWE fix patch.\n' "${#TEST_FILES[@]}" >&2
46+
fi
47+
48+
if [ ! -s "$OUTPUT_PATH" ]; then
49+
: > "$OUTPUT_PATH"
50+
fi
51+
52+
git reset --hard "$BASE_COMMIT" >/dev/null
53+
if [ "${#UNTRACKED_FILES[@]}" -gt 0 ]; then
54+
git clean -fd -- "${UNTRACKED_FILES[@]}" >/dev/null
55+
fi

verifiers/envs/experimental/composable/tasksets/swe/multi_swe.py renamed to verifiers/envs/experimental/composable/tasksets/swe/multi_swe/taskset.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ async def setup(self, state) -> None:
261261
# Acquire::Retries=3: harden against transient archive.ubuntu.com CDN
262262
# mirror-sync mismatches mid-rollout (launchpad bug #1876035).
263263
"command -v patch || (apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 install -y patch)",
264-
"rm -f /home/fix.patch /home/test_output.txt /home/create_fix_patch.sh",
264+
"rm -f /home/fix.patch /home/test_output.txt /home/create_fix_patch.sh /home/extract_multiswe_fix_patch.sh",
265265
]
266266
for command in commands:
267267
results = await sandbox_client.execute_command(
@@ -281,21 +281,26 @@ async def _run_tests(
281281
test_timeout: int,
282282
) -> str:
283283
repo_path = self.get_workdir(state["info"])
284-
script_path = SCRIPTS_DIR / "create_fix_patch.sh"
284+
multiswe_row = restore_row(state["info"])
285+
base = multiswe_row.get("base")
286+
base_commit = base.get("sha") if isinstance(base, dict) else None
287+
base_commit = base_commit or "HEAD"
288+
script_path = SCRIPTS_DIR / "extract_fix_patch.sh"
285289
await sandbox_client.upload_file(
286-
sandbox_id, "/home/create_fix_patch.sh", str(script_path)
290+
sandbox_id, "/home/extract_multiswe_fix_patch.sh", str(script_path)
287291
)
288292

289293
prep = await sandbox_client.execute_command(
290294
sandbox_id,
291-
"chmod +x /home/create_fix_patch.sh && bash /home/create_fix_patch.sh",
295+
"chmod +x /home/extract_multiswe_fix_patch.sh"
296+
f" && bash /home/extract_multiswe_fix_patch.sh . {shlex.quote(base_commit)}",
292297
working_dir=repo_path,
293298
timeout=min(test_timeout, 300),
294299
)
295300
if prep.exit_code != 0:
296301
stderr = (prep.stderr or "")[:1000]
297302
raise RuntimeError(
298-
f"Failed to create Multi-SWE fix patch: exit_code={prep.exit_code} stderr={stderr}"
303+
f"Failed to extract Multi-SWE fix patch: exit_code={prep.exit_code} stderr={stderr}"
299304
)
300305

301306
command = "bash -o pipefail -c 'bash /home/fix-run.sh 2>&1 | tee /home/test_output.txt'"

0 commit comments

Comments
 (0)