Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/format-code-task-000110/environment/Dockerfile +3 -0
- tasks/format-code-task-000110/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000110/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000110/tests/test.patch +188 -0
- tasks/format-code-task-000110/tests/test.sh +39 -0
- tasks/format-code-task-000110/tests/test_command.sh +1 -0
- tasks/format-code-task-000117/environment/Dockerfile +3 -0
- tasks/format-code-task-000117/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000117/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000117/tests/test.patch +197 -0
- tasks/format-code-task-000117/tests/test.sh +38 -0
- tasks/format-code-task-000117/tests/test_command.sh +1 -0
- tasks/format-code-task-000119/environment/Dockerfile +3 -0
- tasks/format-code-task-000119/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000119/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000119/tests/test.patch +79 -0
- tasks/format-code-task-000119/tests/test.sh +40 -0
- tasks/format-code-task-000119/tests/test_command.sh +1 -0
- tasks/format-code-task-000121/environment/Dockerfile +3 -0
- tasks/format-code-task-000121/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000121/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000121/tests/test.patch +229 -0
- tasks/format-code-task-000121/tests/test.sh +38 -0
- tasks/format-code-task-000121/tests/test_command.sh +1 -0
- tasks/format-code-task-000126/environment/Dockerfile +3 -0
- tasks/format-code-task-000126/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000126/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000126/tests/test.patch +379 -0
- tasks/format-code-task-000126/tests/test.sh +39 -0
- tasks/format-code-task-000126/tests/test_command.sh +1 -0
- tasks/format-code-task-000128/environment/Dockerfile +3 -0
- tasks/format-code-task-000128/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000128/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000128/tests/test.patch +79 -0
- tasks/format-code-task-000128/tests/test.sh +39 -0
- tasks/format-code-task-000128/tests/test_command.sh +1 -0
- tasks/format-code-task-000142/environment/Dockerfile +3 -0
- tasks/format-code-task-000142/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000142/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000142/tests/test.patch +122 -0
- tasks/format-code-task-000142/tests/test.sh +39 -0
- tasks/format-code-task-000142/tests/test_command.sh +1 -0
- tasks/format-code-task-000143/environment/Dockerfile +3 -0
- tasks/format-code-task-000143/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000143/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000143/tests/test.patch +97 -0
- tasks/format-code-task-000143/tests/test.sh +39 -0
- tasks/format-code-task-000143/tests/test_command.sh +1 -0
- tasks/format-code-task-000145/environment/Dockerfile +3 -0
- tasks/format-code-task-000145/environment/setup/files/blocklist +33 -0
tasks/format-code-task-000110/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:73c51c6bcc159c75a12110d77e2a379dcbb68af16798259578598546132f5ca2
|
tasks/format-code-task-000110/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000110/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000110/tests/test.patch
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 0000000..0b5744f
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/test_commands.json
|
| 6 |
+
@@ -0,0 +1,3 @@
|
| 7 |
+
+{
|
| 8 |
+
+ "test_commands": ["python -m pytest tests/apps/test_paint_annotations.py -v"]
|
| 9 |
+
+}
|
| 10 |
+
diff --git a/tests/apps/test_paint_annotations.py b/tests/apps/test_paint_annotations.py
|
| 11 |
+
index b349c03..bb54615 100644
|
| 12 |
+
--- a/tests/apps/test_paint_annotations.py
|
| 13 |
+
+++ b/tests/apps/test_paint_annotations.py
|
| 14 |
+
@@ -2,12 +2,161 @@ import json
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
+
import numpy as np
|
| 18 |
+
+import pytest
|
| 19 |
+
from matplotlib import cm
|
| 20 |
+
from PIL import Image
|
| 21 |
+
|
| 22 |
+
from pyodi.apps.paint_annotations import paint_annotations
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
+def _make_crowd_dataset(tmp_path):
|
| 26 |
+
+ """Helper: 1 image, 2 annotations - one normal (cat 0) and one crowd (cat 1)."""
|
| 27 |
+
+ images_folder = tmp_path / "images"
|
| 28 |
+
+ Path(images_folder).mkdir(exist_ok=True, parents=True)
|
| 29 |
+
+
|
| 30 |
+
+ output_folder = tmp_path / "test_result"
|
| 31 |
+
+ Path(output_folder).mkdir(exist_ok=True, parents=True)
|
| 32 |
+
+
|
| 33 |
+
+ images = [
|
| 34 |
+
+ {"id": 0, "width": 10, "height": 10, "file_name": "test_0.png"},
|
| 35 |
+
+ ]
|
| 36 |
+
+
|
| 37 |
+
+ annotations = [
|
| 38 |
+
+ {"image_id": 0, "category_id": 0, "bbox": [0, 0, 2, 2], "score": 1, "iscrowd": 0},
|
| 39 |
+
+ {"image_id": 0, "category_id": 1, "bbox": [5, 5, 2, 2], "score": 1, "iscrowd": 1},
|
| 40 |
+
+ ]
|
| 41 |
+
+
|
| 42 |
+
+ categories = [
|
| 43 |
+
+ {"id": 0, "name": "", "supercategory": "object"},
|
| 44 |
+
+ {"id": 1, "name": "", "supercategory": "object"},
|
| 45 |
+
+ ]
|
| 46 |
+
+
|
| 47 |
+
+ coco_data = dict(images=images, annotations=annotations, categories=categories)
|
| 48 |
+
+
|
| 49 |
+
+ image = np.zeros((10, 10, 3), dtype=np.uint8)
|
| 50 |
+
+ Image.fromarray(image).save(images_folder / "test_0.png")
|
| 51 |
+
+
|
| 52 |
+
+ annotation_path = tmp_path / "test_annotation.json"
|
| 53 |
+
+ with open(annotation_path, "w") as json_file:
|
| 54 |
+
+ json.dump(coco_data, json_file)
|
| 55 |
+
+
|
| 56 |
+
+ return annotation_path, images_folder, output_folder
|
| 57 |
+
+
|
| 58 |
+
+
|
| 59 |
+
+def _pixel_is_background(rgba_pixel):
|
| 60 |
+
+ """A non-painted pixel of a black source image should have R=G=B=0."""
|
| 61 |
+
+ return rgba_pixel[0] == 0 and rgba_pixel[1] == 0 and rgba_pixel[2] == 0
|
| 62 |
+
+
|
| 63 |
+
+
|
| 64 |
+
+def _pixel_is_painted(rgba_pixel):
|
| 65 |
+
+ return not _pixel_is_background(rgba_pixel)
|
| 66 |
+
+
|
| 67 |
+
+
|
| 68 |
+
+def test_default_filters_crowd_annotation(tmp_path):
|
| 69 |
+
+ """User calls paint_annotations with default args; crowd bbox area is NOT painted."""
|
| 70 |
+
+ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path)
|
| 71 |
+
+
|
| 72 |
+
+ paint_annotations(
|
| 73 |
+
+ annotation_path,
|
| 74 |
+
+ images_folder,
|
| 75 |
+
+ output_folder,
|
| 76 |
+
+ show_label=False,
|
| 77 |
+
+ )
|
| 78 |
+
+
|
| 79 |
+
+ result = np.asarray(Image.open(output_folder / "test_0_result.png"))
|
| 80 |
+
+
|
| 81 |
+
+ assert _pixel_is_background(result[6, 6]), (
|
| 82 |
+
+ f"Default should filter crowd box; pixel (6,6) is {result[6, 6]}"
|
| 83 |
+
+ )
|
| 84 |
+
+
|
| 85 |
+
+
|
| 86 |
+
+def test_filter_crowd_true_filters_crowd_annotation(tmp_path):
|
| 87 |
+
+ """Explicit filter_crowd=True: crowd bbox NOT painted."""
|
| 88 |
+
+ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path)
|
| 89 |
+
+
|
| 90 |
+
+ paint_annotations(
|
| 91 |
+
+ annotation_path,
|
| 92 |
+
+ images_folder,
|
| 93 |
+
+ output_folder,
|
| 94 |
+
+ show_label=False,
|
| 95 |
+
+ filter_crowd=True,
|
| 96 |
+
+ )
|
| 97 |
+
+
|
| 98 |
+
+ result = np.asarray(Image.open(output_folder / "test_0_result.png"))
|
| 99 |
+
+ assert _pixel_is_background(result[6, 6]), (
|
| 100 |
+
+ f"filter_crowd=True should not paint crowd; pixel (6,6) is {result[6, 6]}"
|
| 101 |
+
+ )
|
| 102 |
+
+
|
| 103 |
+
+
|
| 104 |
+
+def test_filter_crowd_false_paints_crowd_annotation(tmp_path):
|
| 105 |
+
+ """filter_crowd=False: crowd bbox IS painted."""
|
| 106 |
+
+ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path)
|
| 107 |
+
+
|
| 108 |
+
+ paint_annotations(
|
| 109 |
+
+ annotation_path,
|
| 110 |
+
+ images_folder,
|
| 111 |
+
+ output_folder,
|
| 112 |
+
+ show_label=False,
|
| 113 |
+
+ filter_crowd=False,
|
| 114 |
+
+ )
|
| 115 |
+
+
|
| 116 |
+
+ result = np.asarray(Image.open(output_folder / "test_0_result.png"))
|
| 117 |
+
+
|
| 118 |
+
+ assert _pixel_is_painted(result[6, 6]), (
|
| 119 |
+
+ f"filter_crowd=False should paint crowd box; pixel (6,6) is {result[6, 6]}"
|
| 120 |
+
+ )
|
| 121 |
+
+
|
| 122 |
+
+
|
| 123 |
+
+def test_non_crowd_annotation_painted_with_default(tmp_path):
|
| 124 |
+
+ """Default filter_crowd=True does NOT affect non-crowd annotations."""
|
| 125 |
+
+ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path)
|
| 126 |
+
+
|
| 127 |
+
+ paint_annotations(
|
| 128 |
+
+ annotation_path,
|
| 129 |
+
+ images_folder,
|
| 130 |
+
+ output_folder,
|
| 131 |
+
+ show_label=False,
|
| 132 |
+
+ )
|
| 133 |
+
+
|
| 134 |
+
+ result = np.asarray(Image.open(output_folder / "test_0_result.png"))
|
| 135 |
+
+
|
| 136 |
+
+ assert _pixel_is_painted(result[1, 1]), (
|
| 137 |
+
+ f"Non-crowd annotation must still be painted; pixel (1,1) is {result[1, 1]}"
|
| 138 |
+
+ )
|
| 139 |
+
+
|
| 140 |
+
+
|
| 141 |
+
+def test_annotation_without_iscrowd_key_is_painted(tmp_path):
|
| 142 |
+
+ """An annotation missing the iscrowd key is treated as non-crowd and painted."""
|
| 143 |
+
+ images_folder = tmp_path / "images"
|
| 144 |
+
+ Path(images_folder).mkdir(exist_ok=True, parents=True)
|
| 145 |
+
+ output_folder = tmp_path / "test_result"
|
| 146 |
+
+ Path(output_folder).mkdir(exist_ok=True, parents=True)
|
| 147 |
+
+
|
| 148 |
+
+ images = [{"id": 0, "width": 10, "height": 10, "file_name": "test_0.png"}]
|
| 149 |
+
+ annotations = [
|
| 150 |
+
+ {"image_id": 0, "category_id": 0, "bbox": [0, 0, 2, 2], "score": 1},
|
| 151 |
+
+ ]
|
| 152 |
+
+ categories = [{"id": 0, "name": "", "supercategory": "object"}]
|
| 153 |
+
+ coco_data = dict(images=images, annotations=annotations, categories=categories)
|
| 154 |
+
+
|
| 155 |
+
+ Image.fromarray(np.zeros((10, 10, 3), dtype=np.uint8)).save(images_folder / "test_0.png")
|
| 156 |
+
+ annotation_path = tmp_path / "test_annotation.json"
|
| 157 |
+
+ with open(annotation_path, "w") as f:
|
| 158 |
+
+ json.dump(coco_data, f)
|
| 159 |
+
+
|
| 160 |
+
+ paint_annotations(
|
| 161 |
+
+ annotation_path,
|
| 162 |
+
+ images_folder,
|
| 163 |
+
+ output_folder,
|
| 164 |
+
+ show_label=False,
|
| 165 |
+
+ )
|
| 166 |
+
+
|
| 167 |
+
+ result = np.asarray(Image.open(output_folder / "test_0_result.png"))
|
| 168 |
+
+ assert _pixel_is_painted(result[1, 1]), (
|
| 169 |
+
+ f"Annotation without iscrowd should still be painted; pixel (1,1) is {result[1, 1]}"
|
| 170 |
+
+ )
|
| 171 |
+
+
|
| 172 |
+
+
|
| 173 |
+
def test_image_annotations(tmp_path):
|
| 174 |
+
|
| 175 |
+
images_folder = tmp_path / "images"
|
| 176 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 177 |
+
new file mode 100755
|
| 178 |
+
--- /dev/null
|
| 179 |
+
+++ b/mimo_test_command.sh
|
| 180 |
+
@@ -0,0 +1,8 @@
|
| 181 |
+
+#!/usr/bin/env bash
|
| 182 |
+
+
|
| 183 |
+
+set -uo pipefail
|
| 184 |
+
+cd /testbed
|
| 185 |
+
+rc=0
|
| 186 |
+
+python -m pytest -v -rA tests/apps/test_paint_annotations.py::test_default_filters_crowd_annotation tests/apps/test_paint_annotations.py::test_filter_crowd_true_filters_crowd_annotation tests/apps/test_paint_annotations.py::test_filter_crowd_false_paints_crowd_annotation tests/apps/test_paint_annotations.py::test_non_crowd_annotation_painted_with_default tests/apps/test_paint_annotations.py::test_annotation_without_iscrowd_key_is_painted
|
| 187 |
+
+rc=$(( rc | $? ))
|
| 188 |
+
+exit $rc
|
tasks/format-code-task-000110/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
test_commands.json
|
| 25 |
+
tests/apps/test_paint_annotations.py
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000110/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000117/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d399cf81531fbbaff66230c2417fa781c8392f7bb9d1478ef170d52b92f771f1
|
tasks/format-code-task-000117/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000117/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000117/tests/test.patch
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go b/ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 000000000..34c8321f0
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go
|
| 6 |
+
@@ -0,0 +1,165 @@
|
| 7 |
+
+package ibm
|
| 8 |
+
+
|
| 9 |
+
+import (
|
| 10 |
+
+ "strings"
|
| 11 |
+
+ "testing"
|
| 12 |
+
+
|
| 13 |
+
+ tfconfig "github.com/hashicorp/terraform/config"
|
| 14 |
+
+ "github.com/hashicorp/terraform/helper/schema"
|
| 15 |
+
+ "github.com/hashicorp/terraform/terraform"
|
| 16 |
+
+)
|
| 17 |
+
+
|
| 18 |
+
+
|
| 19 |
+
+
|
| 20 |
+
+func collectionElemType(t *testing.T, s *schema.Schema, field string) schema.ValueType {
|
| 21 |
+
+ t.Helper()
|
| 22 |
+
+ if s.Type != schema.TypeList && s.Type != schema.TypeSet {
|
| 23 |
+
+ t.Fatalf("expected %q to be a list or set, got %v", field, s.Type)
|
| 24 |
+
+ }
|
| 25 |
+
+ elem, ok := s.Elem.(*schema.Schema)
|
| 26 |
+
+ if !ok {
|
| 27 |
+
+ t.Fatalf("expected %q to have a scalar element schema", field)
|
| 28 |
+
+ }
|
| 29 |
+
+ return elem.Type
|
| 30 |
+
+}
|
| 31 |
+
+
|
| 32 |
+
+func validateResourceConfig(t *testing.T, resourceType string, raw map[string]interface{}) []error {
|
| 33 |
+
+ t.Helper()
|
| 34 |
+
+ p := Provider().(*schema.Provider)
|
| 35 |
+
+ if _, ok := p.ResourcesMap[resourceType]; !ok {
|
| 36 |
+
+ t.Fatalf("resource %s is not registered", resourceType)
|
| 37 |
+
+ }
|
| 38 |
+
+ c, err := tfconfig.NewRawConfig(raw)
|
| 39 |
+
+ if err != nil {
|
| 40 |
+
+ t.Fatalf("err building raw config: %s", err)
|
| 41 |
+
+ }
|
| 42 |
+
+ _, errs := p.ValidateResource(resourceType, terraform.NewResourceConfig(c))
|
| 43 |
+
+ return errs
|
| 44 |
+
+}
|
| 45 |
+
+
|
| 46 |
+
+func TestDNSDomainRegistrationDataSourceRegistered(t *testing.T) {
|
| 47 |
+
+ p := Provider().(*schema.Provider)
|
| 48 |
+
+ ds, ok := p.DataSourcesMap["ibm_dns_domain_registration"]
|
| 49 |
+
+ if !ok {
|
| 50 |
+
+ t.Fatal("expected data source ibm_dns_domain_registration to be registered")
|
| 51 |
+
+ }
|
| 52 |
+
+
|
| 53 |
+
+ name, ok := ds.Schema["name"]
|
| 54 |
+
+ if !ok {
|
| 55 |
+
+ t.Fatal("data source missing 'name' argument")
|
| 56 |
+
+ }
|
| 57 |
+
+ if !name.Required {
|
| 58 |
+
+ t.Error("data source 'name' must be required")
|
| 59 |
+
+ }
|
| 60 |
+
+ if name.Type != schema.TypeString {
|
| 61 |
+
+ t.Errorf("data source 'name' must be a string, got %v", name.Type)
|
| 62 |
+
+ }
|
| 63 |
+
+
|
| 64 |
+
+ ns, ok := ds.Schema["name_servers"]
|
| 65 |
+
+ if !ok {
|
| 66 |
+
+ t.Fatal("data source missing 'name_servers' attribute")
|
| 67 |
+
+ }
|
| 68 |
+
+ if !ns.Computed {
|
| 69 |
+
+ t.Error("data source 'name_servers' must be computed")
|
| 70 |
+
+ }
|
| 71 |
+
+ if et := collectionElemType(t, ns, "name_servers"); et != schema.TypeString {
|
| 72 |
+
+ t.Errorf("data source 'name_servers' elements must be strings, got %v", et)
|
| 73 |
+
+ }
|
| 74 |
+
+}
|
| 75 |
+
+
|
| 76 |
+
+func TestDNSDomainRegistrationNameserversResourceRegistered(t *testing.T) {
|
| 77 |
+
+ p := Provider().(*schema.Provider)
|
| 78 |
+
+ r, ok := p.ResourcesMap["ibm_dns_domain_registration_nameservers"]
|
| 79 |
+
+ if !ok {
|
| 80 |
+
+ t.Fatal("expected resource ibm_dns_domain_registration_nameservers to be registered")
|
| 81 |
+
+ }
|
| 82 |
+
+
|
| 83 |
+
+ id, ok := r.Schema["dns_registration_id"]
|
| 84 |
+
+ if !ok {
|
| 85 |
+
+ t.Fatal("resource missing 'dns_registration_id' argument")
|
| 86 |
+
+ }
|
| 87 |
+
+ if !id.Required {
|
| 88 |
+
+ t.Error("resource 'dns_registration_id' must be required")
|
| 89 |
+
+ }
|
| 90 |
+
+ if id.Type != schema.TypeString {
|
| 91 |
+
+ t.Errorf("resource 'dns_registration_id' must be a string, got %v", id.Type)
|
| 92 |
+
+ }
|
| 93 |
+
+
|
| 94 |
+
+ ns, ok := r.Schema["name_servers"]
|
| 95 |
+
+ if !ok {
|
| 96 |
+
+ t.Fatal("resource missing 'name_servers' argument")
|
| 97 |
+
+ }
|
| 98 |
+
+ if !ns.Required {
|
| 99 |
+
+ t.Error("resource 'name_servers' must be required")
|
| 100 |
+
+ }
|
| 101 |
+
+ if et := collectionElemType(t, ns, "name_servers"); et != schema.TypeString {
|
| 102 |
+
+ t.Errorf("resource 'name_servers' elements must be strings, got %v", et)
|
| 103 |
+
+ }
|
| 104 |
+
+
|
| 105 |
+
+ orig, ok := r.Schema["original_name_servers"]
|
| 106 |
+
+ if !ok {
|
| 107 |
+
+ t.Fatal("resource missing 'original_name_servers' attribute")
|
| 108 |
+
+ }
|
| 109 |
+
+ if !orig.Computed {
|
| 110 |
+
+ t.Error("resource 'original_name_servers' must be computed")
|
| 111 |
+
+ }
|
| 112 |
+
+ if et := collectionElemType(t, orig, "original_name_servers"); et != schema.TypeString {
|
| 113 |
+
+ t.Errorf("resource 'original_name_servers' elements must be strings, got %v", et)
|
| 114 |
+
+ }
|
| 115 |
+
+}
|
| 116 |
+
+
|
| 117 |
+
+func TestProviderInternalValidateWithDNSRegistration(t *testing.T) {
|
| 118 |
+
+ if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
|
| 119 |
+
+ t.Fatalf("provider internal validation failed: %s", err)
|
| 120 |
+
+ }
|
| 121 |
+
+}
|
| 122 |
+
+
|
| 123 |
+
+func TestDNSDomainRegistrationNameserversValidation(t *testing.T) {
|
| 124 |
+
+ valid := []string{
|
| 125 |
+
+ "ns1.example.com",
|
| 126 |
+
+ "a.bb.ccc",
|
| 127 |
+
+ "ns-01.example.co.uk",
|
| 128 |
+
+ "NS1.Example.COM",
|
| 129 |
+
+ }
|
| 130 |
+
+ for _, v := range valid {
|
| 131 |
+
+ raw := map[string]interface{}{
|
| 132 |
+
+ "dns_registration_id": "123456",
|
| 133 |
+
+ "name_servers": []interface{}{v},
|
| 134 |
+
+ }
|
| 135 |
+
+ errs := validateResourceConfig(t, "ibm_dns_domain_registration_nameservers", raw)
|
| 136 |
+
+ if len(errs) != 0 {
|
| 137 |
+
+ t.Errorf("expected %q to be a valid nameserver, got errors: %v", v, errs)
|
| 138 |
+
+ }
|
| 139 |
+
+ }
|
| 140 |
+
+
|
| 141 |
+
+ invalid := []string{
|
| 142 |
+
+ "",
|
| 143 |
+
+ "localhost",
|
| 144 |
+
+ "-bad.example.com",
|
| 145 |
+
+ "bad-.example.com",
|
| 146 |
+
+ "ns1 .example.com",
|
| 147 |
+
+ "ns_1.example.com",
|
| 148 |
+
+ strings.Repeat("a", 64) + ".com",
|
| 149 |
+
+ }
|
| 150 |
+
+ for _, v := range invalid {
|
| 151 |
+
+ raw := map[string]interface{}{
|
| 152 |
+
+ "dns_registration_id": "123456",
|
| 153 |
+
+ "name_servers": []interface{}{v},
|
| 154 |
+
+ }
|
| 155 |
+
+ errs := validateResourceConfig(t, "ibm_dns_domain_registration_nameservers", raw)
|
| 156 |
+
+ if len(errs) == 0 {
|
| 157 |
+
+ t.Errorf("expected %q to be rejected as an invalid nameserver", v)
|
| 158 |
+
+ }
|
| 159 |
+
+ }
|
| 160 |
+
+}
|
| 161 |
+
+
|
| 162 |
+
+func TestDNSDomainRegistrationNameserversValidationMixed(t *testing.T) {
|
| 163 |
+
+ raw := map[string]interface{}{
|
| 164 |
+
+ "dns_registration_id": "123456",
|
| 165 |
+
+ "name_servers": []interface{}{"ns1.example.com", "bad_host"},
|
| 166 |
+
+ }
|
| 167 |
+
+ errs := validateResourceConfig(t, "ibm_dns_domain_registration_nameservers", raw)
|
| 168 |
+
+ if len(errs) == 0 {
|
| 169 |
+
+ t.Error("expected validation errors when one of several nameservers is invalid")
|
| 170 |
+
+ }
|
| 171 |
+
+}
|
| 172 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 173 |
+
new file mode 100755
|
| 174 |
+
--- /dev/null
|
| 175 |
+
+++ b/mimo_test_command.sh
|
| 176 |
+
@@ -0,0 +1,21 @@
|
| 177 |
+
+#!/usr/bin/env bash
|
| 178 |
+
+
|
| 179 |
+
+
|
| 180 |
+
+
|
| 181 |
+
+set -euo pipefail
|
| 182 |
+
+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 183 |
+
+cd /testbed
|
| 184 |
+
+
|
| 185 |
+
+
|
| 186 |
+
+
|
| 187 |
+
+
|
| 188 |
+
+
|
| 189 |
+
+export GO111MODULE=off
|
| 190 |
+
+REPO_DIR="$(go env GOPATH)/src/github.com/IBM-Cloud/terraform-provider-ibm"
|
| 191 |
+
+cd "$REPO_DIR"
|
| 192 |
+
+
|
| 193 |
+
+
|
| 194 |
+
+go test ./ibm/ -vet=off -run 'TestProvider$|TestProvider_impl' -count=1
|
| 195 |
+
+
|
| 196 |
+
+
|
| 197 |
+
+go test ./ibm/ -vet=off -run 'TestDNSDomainRegistration|TestProviderInternalValidateWithDNSRegistration' -count=1
|
tasks/format-code-task-000117/tests/test.sh
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go
|
| 25 |
+
mimo_test_command.sh
|
| 26 |
+
EOF_RESET_TEST_FILES
|
| 27 |
+
|
| 28 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 29 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 30 |
+
cat "$V/apply.log" >&2
|
| 31 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 32 |
+
exit 1
|
| 33 |
+
fi
|
| 34 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 35 |
+
RC=$?
|
| 36 |
+
tail -c 12000 "$V/test_output.log"
|
| 37 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 38 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000117/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000119/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f3640b92ffdfa97570fac3bb9dc014e9b682256527ce3507d9eaed0410ef62ba
|
tasks/format-code-task-000119/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000119/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000119/tests/test.patch
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/test/test_autoai_libs.py b/test/test_autoai_libs.py
|
| 2 |
+
index 5dd6bd5dd..ddf857ede 100644
|
| 3 |
+
--- a/test/test_autoai_libs.py
|
| 4 |
+
+++ b/test/test_autoai_libs.py
|
| 5 |
+
@@ -123,6 +123,15 @@ def test_NumpyPermuteArray(self):
|
| 6 |
+
self.doTest(trainable, **self._iris)
|
| 7 |
+
self.do1DTest(trainable, **self._iris)
|
| 8 |
+
|
| 9 |
+
+ def test_TNoOp(self):
|
| 10 |
+
+ from autoai_libs.utils.fc_methods import is_not_categorical
|
| 11 |
+
+ trainable = lale.lib.autoai_libs.TNoOp(
|
| 12 |
+
+ fun=np.rint,
|
| 13 |
+
+ name='do nothing',
|
| 14 |
+
+ datatypes=['numeric'], feat_constraints=[is_not_categorical],
|
| 15 |
+
+ )
|
| 16 |
+
+ self.doTest(trainable, **self._iris)
|
| 17 |
+
+
|
| 18 |
+
def test_TA1(self):
|
| 19 |
+
from autoai_libs.utils.fc_methods import is_not_categorical
|
| 20 |
+
float32 = np.dtype('float32')
|
| 21 |
+
diff --git a/test/test_json_pretty_viz.py b/test/test_json_pretty_viz.py
|
| 22 |
+
index f8456bc1e..edeb20dfc 100644
|
| 23 |
+
--- a/test/test_json_pretty_viz.py
|
| 24 |
+
+++ b/test/test_json_pretty_viz.py
|
| 25 |
+
@@ -361,7 +361,6 @@ def test_autoai_libs_tam_2(self):
|
| 26 |
+
tam = TAM(tans_class=pca, name='pca', col_names=['a', 'b', 'c'], col_dtypes=[np.dtype('float32'), np.dtype('float32'), np.dtype('float32')])
|
| 27 |
+
lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18)
|
| 28 |
+
pipeline = make_pipeline(tam, lgbm_classifier)
|
| 29 |
+
- import lale.helpers
|
| 30 |
+
expected = \
|
| 31 |
+
"""from lale.lib.autoai_libs import TAM
|
| 32 |
+
import sklearn.decomposition.pca
|
| 33 |
+
@@ -393,6 +392,23 @@ def test_autoai_libs_ta1(self):
|
| 34 |
+
pipeline = ta1 >> LR()"""
|
| 35 |
+
self._roundtrip(expected, lale.pretty_print.to_string(pipeline))
|
| 36 |
+
|
| 37 |
+
+ def test_autoai_libs_t_no_op(self):
|
| 38 |
+
+ from lale.lib.autoai_libs import TNoOp
|
| 39 |
+
+ from lightgbm import LGBMClassifier
|
| 40 |
+
+ from lale.operators import make_pipeline
|
| 41 |
+
+ t_no_op = TNoOp(name='no_action', datatypes='x', feat_constraints=[])
|
| 42 |
+
+ lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18)
|
| 43 |
+
+ pipeline = make_pipeline(t_no_op, lgbm_classifier)
|
| 44 |
+
+ expected = \
|
| 45 |
+
+"""from lale.lib.autoai_libs import TNoOp
|
| 46 |
+
+from lightgbm import LGBMClassifier
|
| 47 |
+
+from lale.operators import make_pipeline
|
| 48 |
+
+
|
| 49 |
+
+t_no_op = TNoOp(name='no_action', datatypes='x', feat_constraints=[])
|
| 50 |
+
+lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18)
|
| 51 |
+
+pipeline = make_pipeline(t_no_op, lgbm_classifier)"""
|
| 52 |
+
+ self._roundtrip(expected, lale.pretty_print.to_string(pipeline, combinators=False))
|
| 53 |
+
+
|
| 54 |
+
|
| 55 |
+
class TestToAndFromJSON(unittest.TestCase):
|
| 56 |
+
def test_trainable_individual_op(self):
|
| 57 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 58 |
+
new file mode 100644
|
| 59 |
+
--- /dev/null
|
| 60 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 61 |
+
@@ -0,0 +1,7 @@
|
| 62 |
+
+H4sIAAAAAAAAA+3ST0vDMBgG8J77KeLcQQ9tl2xdQVDwMNhFJzIET6Vdg41kTWjT4vz0ph26TdRd
|
| 63 |
+
+NkR8fof+yfM2TXjjp7WQWcyLJnCOZWBFYdjdrc/37pmGjDLGBnTInAGl4ThySHi0FW2pK5OUhDil
|
| 64 |
+
+Uuanun35H+Vv+m94ZeKFWi6TIvOr/HD/2Nf/kW32uv80Cpkdp6Mxow4ZHG4J3/vn/T89CVJRBGlS
|
| 65 |
+
+5e4iI90hSHnmuvxFq9KQu8fJ7UN8P5vNL3v96exmEvh6ZU9L76Pgej610aaune+i3w7bmiaRpNc/
|
| 66 |
+
+6z4hohCGeJ5OTH7+dWaH169PUqU2HvqRTyPX1ULbCtspKYnHiW9nKZSXcV0RdhVkvAmKWsqdMr1q
|
| 67 |
+
+t7IT27lNrgriLd/T9rI+90ltVCJiKdLKbnAreK5UEeuSG7OKG/Hahl7j/nbbAAAAAAAAAAAAAAAA
|
| 68 |
+
+AAAAAAA6b8BQnlUAKAAA
|
| 69 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 70 |
+
new file mode 100755
|
| 71 |
+
--- /dev/null
|
| 72 |
+
+++ b/mimo_test_command.sh
|
| 73 |
+
@@ -0,0 +1,6 @@
|
| 74 |
+
+#!/usr/bin/env bash
|
| 75 |
+
+
|
| 76 |
+
+set -uo pipefail
|
| 77 |
+
+cd /testbed || exit 1
|
| 78 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 79 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000119/tests/test.sh
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
test/test_autoai_libs.py
|
| 25 |
+
test/test_json_pretty_viz.py
|
| 26 |
+
mimo_build_env.tar.gz.b64
|
| 27 |
+
mimo_test_command.sh
|
| 28 |
+
EOF_RESET_TEST_FILES
|
| 29 |
+
|
| 30 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 31 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 32 |
+
cat "$V/apply.log" >&2
|
| 33 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 34 |
+
exit 1
|
| 35 |
+
fi
|
| 36 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 37 |
+
RC=$?
|
| 38 |
+
tail -c 12000 "$V/test_output.log"
|
| 39 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 40 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000119/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000121/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:85e99dbe4a8e4136fd93050e6c3a18b1decd7806bf1c55bec1d73152919e5ea8
|
tasks/format-code-task-000121/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000121/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000121/tests/test.patch
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git ab/balance_strategy_roundrobin_global_test.go b/balance_strategy_roundrobin_global_test.go
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 0000000..98dd53a
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/balance_strategy_roundrobin_global_test.go
|
| 6 |
+
@@ -0,0 +1,123 @@
|
| 7 |
+
+package sarama
|
| 8 |
+
+
|
| 9 |
+
+import (
|
| 10 |
+
+ "reflect"
|
| 11 |
+
+ "sort"
|
| 12 |
+
+ "testing"
|
| 13 |
+
+)
|
| 14 |
+
+
|
| 15 |
+
+func roundRobinTestMetadata(memberTopics map[string][]string) map[string]ConsumerGroupMemberMetadata {
|
| 16 |
+
+ members := make(map[string]ConsumerGroupMemberMetadata, len(memberTopics))
|
| 17 |
+
+ for memberID, topics := range memberTopics {
|
| 18 |
+
+ members[memberID] = ConsumerGroupMemberMetadata{Topics: topics}
|
| 19 |
+
+ }
|
| 20 |
+
+ return members
|
| 21 |
+
+}
|
| 22 |
+
+
|
| 23 |
+
+func assertRoundRobinPlan(t *testing.T, plan BalanceStrategyPlan, err error, expected BalanceStrategyPlan) {
|
| 24 |
+
+ t.Helper()
|
| 25 |
+
+ if err != nil {
|
| 26 |
+
+ t.Fatalf("BalanceStrategyRoundRobin.Plan returned error: %v", err)
|
| 27 |
+
+ }
|
| 28 |
+
+ normalizedPlan := normalizeRoundRobinPlan(plan)
|
| 29 |
+
+ normalizedExpected := normalizeRoundRobinPlan(expected)
|
| 30 |
+
+ if !reflect.DeepEqual(normalizedPlan, normalizedExpected) {
|
| 31 |
+
+ t.Fatalf("unexpected round-robin plan\nexpected: %#v\nactual: %#v", normalizedExpected, normalizedPlan)
|
| 32 |
+
+ }
|
| 33 |
+
+}
|
| 34 |
+
+
|
| 35 |
+
+func normalizeRoundRobinPlan(plan BalanceStrategyPlan) BalanceStrategyPlan {
|
| 36 |
+
+ normalized := make(BalanceStrategyPlan, len(plan))
|
| 37 |
+
+ for memberID, topics := range plan {
|
| 38 |
+
+ topicCopy := make(map[string][]int32, len(topics))
|
| 39 |
+
+ for topic, partitions := range topics {
|
| 40 |
+
+ if len(partitions) == 0 {
|
| 41 |
+
+ continue
|
| 42 |
+
+ }
|
| 43 |
+
+ partitionsCopy := append([]int32(nil), partitions...)
|
| 44 |
+
+ sort.Slice(partitionsCopy, func(i, j int) bool {
|
| 45 |
+
+ return partitionsCopy[i] < partitionsCopy[j]
|
| 46 |
+
+ })
|
| 47 |
+
+ topicCopy[topic] = partitionsCopy
|
| 48 |
+
+ }
|
| 49 |
+
+ if len(topicCopy) > 0 {
|
| 50 |
+
+ normalized[memberID] = topicCopy
|
| 51 |
+
+ }
|
| 52 |
+
+ }
|
| 53 |
+
+ return normalized
|
| 54 |
+
+}
|
| 55 |
+
+
|
| 56 |
+
+func TestBalanceStrategyRoundRobinGlobalAcrossSinglePartitionTopics(t *testing.T) {
|
| 57 |
+
+ members := roundRobinTestMetadata(map[string][]string{
|
| 58 |
+
+ "M1": {"T1", "T2", "T3"},
|
| 59 |
+
+ "M2": {"T1", "T2", "T3"},
|
| 60 |
+
+ "M3": {"T1", "T2", "T3"},
|
| 61 |
+
+ })
|
| 62 |
+
+ topics := map[string][]int32{
|
| 63 |
+
+ "T1": {0},
|
| 64 |
+
+ "T2": {0},
|
| 65 |
+
+ "T3": {0},
|
| 66 |
+
+ }
|
| 67 |
+
+
|
| 68 |
+
+ plan, err := BalanceStrategyRoundRobin.Plan(members, topics)
|
| 69 |
+
+ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{
|
| 70 |
+
+ "M1": map[string][]int32{"T1": {0}},
|
| 71 |
+
+ "M2": map[string][]int32{"T2": {0}},
|
| 72 |
+
+ "M3": map[string][]int32{"T3": {0}},
|
| 73 |
+
+ })
|
| 74 |
+
+}
|
| 75 |
+
+
|
| 76 |
+
+func TestBalanceStrategyRoundRobinGlobalAcrossMixedPartitionCounts(t *testing.T) {
|
| 77 |
+
+ members := roundRobinTestMetadata(map[string][]string{
|
| 78 |
+
+ "M1": {"T1", "T2", "T3"},
|
| 79 |
+
+ "M2": {"T1", "T2", "T3"},
|
| 80 |
+
+ })
|
| 81 |
+
+ topics := map[string][]int32{
|
| 82 |
+
+ "T1": {0},
|
| 83 |
+
+ "T2": {0, 1},
|
| 84 |
+
+ "T3": {0, 1, 2, 3},
|
| 85 |
+
+ }
|
| 86 |
+
+
|
| 87 |
+
+ plan, err := BalanceStrategyRoundRobin.Plan(members, topics)
|
| 88 |
+
+ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{
|
| 89 |
+
+ "M1": map[string][]int32{"T1": {0}, "T2": {1}, "T3": {1, 3}},
|
| 90 |
+
+ "M2": map[string][]int32{"T2": {0}, "T3": {0, 2}},
|
| 91 |
+
+ })
|
| 92 |
+
+}
|
| 93 |
+
+
|
| 94 |
+
+func TestBalanceStrategyRoundRobinSkipsUnsubscribedMembersWithoutResettingProgress(t *testing.T) {
|
| 95 |
+
+ members := roundRobinTestMetadata(map[string][]string{
|
| 96 |
+
+ "M1": {"T1", "T2", "T3"},
|
| 97 |
+
+ "M2": {"T1", "T3"},
|
| 98 |
+
+ })
|
| 99 |
+
+ topics := map[string][]int32{
|
| 100 |
+
+ "T1": {0},
|
| 101 |
+
+ "T2": {0},
|
| 102 |
+
+ "T3": {0},
|
| 103 |
+
+ }
|
| 104 |
+
+
|
| 105 |
+
+ plan, err := BalanceStrategyRoundRobin.Plan(members, topics)
|
| 106 |
+
+ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{
|
| 107 |
+
+ "M1": map[string][]int32{"T1": {0}, "T2": {0}},
|
| 108 |
+
+ "M2": map[string][]int32{"T3": {0}},
|
| 109 |
+
+ })
|
| 110 |
+
+}
|
| 111 |
+
+
|
| 112 |
+
+func TestBalanceStrategyRoundRobinSkipsMultipleIneligibleMembers(t *testing.T) {
|
| 113 |
+
+ members := roundRobinTestMetadata(map[string][]string{
|
| 114 |
+
+ "A": {"T1", "T2", "T3"},
|
| 115 |
+
+ "B": {"T1"},
|
| 116 |
+
+ "C": {"T1", "T3"},
|
| 117 |
+
+ })
|
| 118 |
+
+ topics := map[string][]int32{
|
| 119 |
+
+ "T1": {0},
|
| 120 |
+
+ "T2": {0},
|
| 121 |
+
+ "T3": {0, 1},
|
| 122 |
+
+ }
|
| 123 |
+
+
|
| 124 |
+
+ plan, err := BalanceStrategyRoundRobin.Plan(members, topics)
|
| 125 |
+
+ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{
|
| 126 |
+
+ "A": map[string][]int32{"T1": {0}, "T2": {0}, "T3": {1}},
|
| 127 |
+
+ "C": map[string][]int32{"T3": {0}},
|
| 128 |
+
+ })
|
| 129 |
+
+}
|
| 130 |
+
diff --git a/balance_strategy_test.go b/balance_strategy_test.go
|
| 131 |
+
index 25a51adaa..66af3d1c9 100644
|
| 132 |
+
--- a/balance_strategy_test.go
|
| 133 |
+
+++ b/balance_strategy_test.go
|
| 134 |
+
@@ -90,26 +90,64 @@ func TestBalanceStrategyRoundRobin(t *testing.T) {
|
| 135 |
+
expected BalanceStrategyPlan
|
| 136 |
+
}{
|
| 137 |
+
{
|
| 138 |
+
- members: map[string][]string{"M1": {"T1", "T2"}, "M2": {"T1", "T2"}},
|
| 139 |
+
- topics: map[string][]int32{"T1": {0, 1, 2, 3}, "T2": {0, 1, 2, 3}},
|
| 140 |
+
+ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1", "T2", "T3"}},
|
| 141 |
+
+ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}},
|
| 142 |
+
expected: BalanceStrategyPlan{
|
| 143 |
+
- "M1": map[string][]int32{"T1": {0, 2}, "T2": {1, 3}},
|
| 144 |
+
- "M2": map[string][]int32{"T1": {1, 3}, "T2": {0, 2}},
|
| 145 |
+
+ "M1": map[string][]int32{"T1": {0}, "T3": {0}},
|
| 146 |
+
+ "M2": map[string][]int32{"T2": {0}},
|
| 147 |
+
},
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
- members: map[string][]string{"M1": {"T1", "T2"}, "M2": {"T1", "T2"}},
|
| 151 |
+
- topics: map[string][]int32{"T1": {0, 1, 2}, "T2": {0, 1, 2}},
|
| 152 |
+
+ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1", "T2", "T3"}},
|
| 153 |
+
+ topics: map[string][]int32{"T1": {0}, "T2": {0, 1}, "T3": {0, 1, 2, 3}},
|
| 154 |
+
+ expected: BalanceStrategyPlan{
|
| 155 |
+
+ "M1": map[string][]int32{"T1": {0}, "T2": {1}, "T3": {1, 3}},
|
| 156 |
+
+ "M2": map[string][]int32{"T2": {0}, "T3": {0, 2}},
|
| 157 |
+
+ },
|
| 158 |
+
+ },
|
| 159 |
+
+ {
|
| 160 |
+
+ members: map[string][]string{"M1": {"T1"}, "M2": {"T1"}},
|
| 161 |
+
+ topics: map[string][]int32{"T1": {0}},
|
| 162 |
+
+ expected: BalanceStrategyPlan{
|
| 163 |
+
+ "M1": map[string][]int32{"T1": {0}},
|
| 164 |
+
+ },
|
| 165 |
+
+ },
|
| 166 |
+
+ {
|
| 167 |
+
+ members: map[string][]string{"M1": {"T1", "T2", "T3"}},
|
| 168 |
+
+ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0, 1, 2}},
|
| 169 |
+
expected: BalanceStrategyPlan{
|
| 170 |
+
- "M1": map[string][]int32{"T1": {0, 2}, "T2": {1}},
|
| 171 |
+
- "M2": map[string][]int32{"T1": {1}, "T2": {0, 2}},
|
| 172 |
+
+ "M1": map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0, 1, 2}},
|
| 173 |
+
+ },
|
| 174 |
+
+ },
|
| 175 |
+
+ {
|
| 176 |
+
+ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1"}},
|
| 177 |
+
+ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}},
|
| 178 |
+
+ expected: BalanceStrategyPlan{
|
| 179 |
+
+ "M1": map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}},
|
| 180 |
+
+ },
|
| 181 |
+
+ },
|
| 182 |
+
+ {
|
| 183 |
+
+ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1", "T3"}},
|
| 184 |
+
+ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}},
|
| 185 |
+
+ expected: BalanceStrategyPlan{
|
| 186 |
+
+ "M1": map[string][]int32{"T1": {0}, "T2": {0}},
|
| 187 |
+
+ "M2": map[string][]int32{"T3": {0}},
|
| 188 |
+
+ },
|
| 189 |
+
+ },
|
| 190 |
+
+ {
|
| 191 |
+
+ members: map[string][]string{"M": {"T1", "T2", "TT2"}, "M2": {"T1", "T2", "TT2"}, "M3": {"T1", "T2", "TT2"}},
|
| 192 |
+
+ topics: map[string][]int32{"T1": {0}, "T2": {0}, "TT2": {0}},
|
| 193 |
+
+ expected: BalanceStrategyPlan{
|
| 194 |
+
+ "M": map[string][]int32{"T1": {0}},
|
| 195 |
+
+ "M2": map[string][]int32{"T2": {0}},
|
| 196 |
+
+ "M3": map[string][]int32{"TT2": {0}},
|
| 197 |
+
},
|
| 198 |
+
},
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
strategy := BalanceStrategyRoundRobin
|
| 202 |
+
if strategy.Name() != "roundrobin" {
|
| 203 |
+
- t.Errorf("Unexpected stategy name\nexpected: range\nactual: %v", strategy.Name())
|
| 204 |
+
+ t.Errorf("Unexpected strategy name\nexpected: roundrobin\nactual: %v", strategy.Name())
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
for _, test := range tests {
|
| 208 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 209 |
+
new file mode 100755
|
| 210 |
+
--- /dev/null
|
| 211 |
+
+++ b/mimo_test_command.sh
|
| 212 |
+
@@ -0,0 +1,17 @@
|
| 213 |
+
+#!/usr/bin/env bash
|
| 214 |
+
+set -uo pipefail
|
| 215 |
+
+
|
| 216 |
+
+cd /testbed
|
| 217 |
+
+
|
| 218 |
+
+case "${1:-}" in
|
| 219 |
+
+ base)
|
| 220 |
+
+ go test -v -run '^TestBalanceStrategyRoundRobin$' -count=1 .
|
| 221 |
+
+ ;;
|
| 222 |
+
+ new)
|
| 223 |
+
+ go test -v -run '^(TestBalanceStrategyRoundRobin|TestBalanceStrategyRoundRobinGlobalAcrossSinglePartitionTopics|TestBalanceStrategyRoundRobinGlobalAcrossMixedPartitionCounts|TestBalanceStrategyRoundRobinSkipsUnsubscribedMembersWithoutResettingProgress|TestBalanceStrategyRoundRobinSkipsMultipleIneligibleMembers)$' -count=1 .
|
| 224 |
+
+ ;;
|
| 225 |
+
+ *)
|
| 226 |
+
+ echo "usage: $0 base|new"
|
| 227 |
+
+ exit 2
|
| 228 |
+
+ ;;
|
| 229 |
+
+esac
|
tasks/format-code-task-000121/tests/test.sh
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
balance_strategy_test.go
|
| 25 |
+
mimo_test_command.sh
|
| 26 |
+
EOF_RESET_TEST_FILES
|
| 27 |
+
|
| 28 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 29 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 30 |
+
cat "$V/apply.log" >&2
|
| 31 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 32 |
+
exit 1
|
| 33 |
+
fi
|
| 34 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 35 |
+
RC=$?
|
| 36 |
+
tail -c 12000 "$V/test_output.log"
|
| 37 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 38 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000121/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new
|
tasks/format-code-task-000126/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2e8c08eee42d867ac90d079d37f476b1a67579508fc181b53321a93a674ff4a7
|
tasks/format-code-task-000126/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000126/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000126/tests/test.patch
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/tests/test_conf_branch_pipeline.py b/tests/test_conf_branch_pipeline.py
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 0000000..a3c0538
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/tests/test_conf_branch_pipeline.py
|
| 6 |
+
@@ -0,0 +1,227 @@
|
| 7 |
+
+import math
|
| 8 |
+
+import sys
|
| 9 |
+
+import types
|
| 10 |
+
+from pathlib import Path
|
| 11 |
+
+
|
| 12 |
+
+import pytest
|
| 13 |
+
+import torch
|
| 14 |
+
+import torch.nn as nn
|
| 15 |
+
+import yaml
|
| 16 |
+
+
|
| 17 |
+
+
|
| 18 |
+
+def _install_optional_dependency_stubs():
|
| 19 |
+
+ class Registry:
|
| 20 |
+
+ def register_module(self, *args, **kwargs):
|
| 21 |
+
+ def decorate(cls):
|
| 22 |
+
+ return cls
|
| 23 |
+
+
|
| 24 |
+
+ return decorate
|
| 25 |
+
+
|
| 26 |
+
+ mmcls = types.ModuleType("mmcls")
|
| 27 |
+
+ mmcls_models = types.ModuleType("mmcls.models")
|
| 28 |
+
+ mmcls_apis = types.ModuleType("mmcls.apis")
|
| 29 |
+
+ mmcls_models.CLASSIFIERS = Registry()
|
| 30 |
+
+ mmcls_models.ImageClassifier = nn.Module
|
| 31 |
+
+ mmcls_apis.init_model = lambda *args, **kwargs: None
|
| 32 |
+
+ mmcls.models = mmcls_models
|
| 33 |
+
+ mmcls.apis = mmcls_apis
|
| 34 |
+
+ sys.modules.setdefault("mmcls", mmcls)
|
| 35 |
+
+ sys.modules.setdefault("mmcls.models", mmcls_models)
|
| 36 |
+
+ sys.modules.setdefault("mmcls.apis", mmcls_apis)
|
| 37 |
+
+
|
| 38 |
+
+ mmcv = types.ModuleType("mmcv")
|
| 39 |
+
+
|
| 40 |
+
+ class Config:
|
| 41 |
+
+ @classmethod
|
| 42 |
+
+ def fromfile(cls, *args, **kwargs):
|
| 43 |
+
+ return cls()
|
| 44 |
+
+
|
| 45 |
+
+ mmcv.Config = Config
|
| 46 |
+
+ sys.modules.setdefault("mmcv", mmcv)
|
| 47 |
+
+
|
| 48 |
+
+ turtle = types.ModuleType("turtle")
|
| 49 |
+
+ turtle.forward = lambda *args, **kwargs: None
|
| 50 |
+
+ sys.modules.setdefault("turtle", turtle)
|
| 51 |
+
+
|
| 52 |
+
+ diffdist = types.ModuleType("diffdist")
|
| 53 |
+
+ diffdist_functional = types.ModuleType("diffdist.functional")
|
| 54 |
+
+ diffdist.functional = diffdist_functional
|
| 55 |
+
+ sys.modules.setdefault("diffdist", diffdist)
|
| 56 |
+
+ sys.modules.setdefault("diffdist.functional", diffdist_functional)
|
| 57 |
+
+
|
| 58 |
+
+ sys.modules.setdefault("libmr", types.ModuleType("libmr"))
|
| 59 |
+
+ sys.modules.setdefault("faiss", types.ModuleType("faiss"))
|
| 60 |
+
+
|
| 61 |
+
+
|
| 62 |
+
+_install_optional_dependency_stubs()
|
| 63 |
+
+
|
| 64 |
+
+from openood.networks.conf_branch_net import ConfBranchNet
|
| 65 |
+
+from openood.recorders.utils import get_recorder
|
| 66 |
+
+
|
| 67 |
+
+
|
| 68 |
+
+class AttrDict(dict):
|
| 69 |
+
+
|
| 70 |
+
+
|
| 71 |
+
+ def __getattr__(self, name):
|
| 72 |
+
+ try:
|
| 73 |
+
+ value = self[name]
|
| 74 |
+
+ except KeyError as exc:
|
| 75 |
+
+ raise AttributeError(name) from exc
|
| 76 |
+
+ if isinstance(value, dict):
|
| 77 |
+
+ value = AttrDict(value)
|
| 78 |
+
+ self[name] = value
|
| 79 |
+
+ return value
|
| 80 |
+
+
|
| 81 |
+
+ def __setattr__(self, name, value):
|
| 82 |
+
+ self[name] = value
|
| 83 |
+
+
|
| 84 |
+
+
|
| 85 |
+
+def _to_attrdict(value):
|
| 86 |
+
+ if isinstance(value, dict):
|
| 87 |
+
+ return AttrDict({key: _to_attrdict(val) for key, val in value.items()})
|
| 88 |
+
+ if isinstance(value, list):
|
| 89 |
+
+ return [_to_attrdict(item) for item in value]
|
| 90 |
+
+ return value
|
| 91 |
+
+
|
| 92 |
+
+
|
| 93 |
+
+class DeterministicBackbone(nn.Module):
|
| 94 |
+
+ def __init__(self, num_classes, feature_size):
|
| 95 |
+
+ super().__init__()
|
| 96 |
+
+ self.num_classes = num_classes
|
| 97 |
+
+ self.feature_size = feature_size
|
| 98 |
+
+
|
| 99 |
+
+ def forward(self, x, *args, **kwargs):
|
| 100 |
+
+ batch = x.shape[0]
|
| 101 |
+
+ signal = x.reshape(batch, -1).mean(dim=1, keepdim=True)
|
| 102 |
+
+ logits = signal.repeat(1, self.num_classes)
|
| 103 |
+
+ feature_scale = torch.arange(
|
| 104 |
+
+ 1, self.feature_size + 1, dtype=x.dtype, device=x.device
|
| 105 |
+
+ ).unsqueeze(0)
|
| 106 |
+
+ features = signal.repeat(1, self.feature_size) * feature_scale
|
| 107 |
+
+ return logits, features
|
| 108 |
+
+
|
| 109 |
+
+
|
| 110 |
+
+@pytest.mark.parametrize(
|
| 111 |
+
+ "batch_size,num_classes,feature_size",
|
| 112 |
+
+ [(2, 7, 19), (3, 5, 13)],
|
| 113 |
+
+)
|
| 114 |
+
+def test_conf_branch_forward_accepts_multiple_nontrivial_backbones(
|
| 115 |
+
+ batch_size, num_classes, feature_size
|
| 116 |
+
+):
|
| 117 |
+
+ net = ConfBranchNet(
|
| 118 |
+
+ DeterministicBackbone(num_classes=num_classes, feature_size=feature_size),
|
| 119 |
+
+ num_classes=num_classes,
|
| 120 |
+
+ )
|
| 121 |
+
+ x = torch.randn(batch_size, 3, 4, 4)
|
| 122 |
+
+
|
| 123 |
+
+ pred = net(x)
|
| 124 |
+
+
|
| 125 |
+
+ assert pred.shape == (batch_size, num_classes)
|
| 126 |
+
+
|
| 127 |
+
+
|
| 128 |
+
+def test_conf_branch_forward_uses_backbone_dependent_signal_for_outputs():
|
| 129 |
+
+ net = ConfBranchNet(DeterministicBackbone(num_classes=6, feature_size=17), 6)
|
| 130 |
+
+ x_low = torch.zeros(2, 3, 4, 4)
|
| 131 |
+
+ x_high = torch.ones(2, 3, 4, 4)
|
| 132 |
+
+
|
| 133 |
+
+ pred_low, conf_low = net(x_low, return_confidence=True)
|
| 134 |
+
+ pred_high, conf_high = net(x_high, return_confidence=True)
|
| 135 |
+
+
|
| 136 |
+
+ assert pred_low.shape == (2, 6)
|
| 137 |
+
+ assert conf_low.shape == (2, 1)
|
| 138 |
+
+ assert pred_high.shape == (2, 6)
|
| 139 |
+
+ assert conf_high.shape == (2, 1)
|
| 140 |
+
+ assert (not torch.allclose(pred_low, pred_high)) or (
|
| 141 |
+
+ not torch.allclose(conf_low, conf_high)
|
| 142 |
+
+ )
|
| 143 |
+
+
|
| 144 |
+
+
|
| 145 |
+
+def test_train_conf_branch_config_uses_constructible_recorder(tmp_path):
|
| 146 |
+
+ config_path = (
|
| 147 |
+
+ Path(__file__).resolve().parents[1]
|
| 148 |
+
+ / "configs"
|
| 149 |
+
+ / "pipelines"
|
| 150 |
+
+ / "train"
|
| 151 |
+
+ / "train_conf_branch.yml"
|
| 152 |
+
+ )
|
| 153 |
+
+ config = _to_attrdict(yaml.safe_load(config_path.read_text()))
|
| 154 |
+
+ config.output_dir = str(tmp_path)
|
| 155 |
+
+
|
| 156 |
+
+ recorder = get_recorder(config)
|
| 157 |
+
+
|
| 158 |
+
+ assert all(hasattr(recorder, name) for name in ("report", "save_model", "summary"))
|
| 159 |
+
+
|
| 160 |
+
+
|
| 161 |
+
+class TinyLoader:
|
| 162 |
+
+ def __init__(self, batches):
|
| 163 |
+
+ self.batches = batches
|
| 164 |
+
+ self._idx = 0
|
| 165 |
+
+
|
| 166 |
+
+ def __iter__(self):
|
| 167 |
+
+ self._idx = 0
|
| 168 |
+
+ return self
|
| 169 |
+
+
|
| 170 |
+
+ def __len__(self):
|
| 171 |
+
+ return len(self.batches)
|
| 172 |
+
+
|
| 173 |
+
+ def __next__(self):
|
| 174 |
+
+ if self._idx >= len(self.batches):
|
| 175 |
+
+ raise StopIteration
|
| 176 |
+
+ batch = self.batches[self._idx]
|
| 177 |
+
+ self._idx += 1
|
| 178 |
+
+ return batch
|
| 179 |
+
+
|
| 180 |
+
+
|
| 181 |
+
+def test_conf_branch_train_epoch_metrics_include_loss(monkeypatch):
|
| 182 |
+
+ from openood.trainers.conf_branch_trainer import ConfBranchTrainer
|
| 183 |
+
+
|
| 184 |
+
+ monkeypatch.setattr(torch.Tensor, "cuda", lambda self, *args, **kwargs: self)
|
| 185 |
+
+ monkeypatch.setattr(nn.Module, "cuda", lambda self, *args, **kwargs: self)
|
| 186 |
+
+
|
| 187 |
+
+ class TinyConfNet(nn.Module):
|
| 188 |
+
+ def __init__(self):
|
| 189 |
+
+ super().__init__()
|
| 190 |
+
+ self.linear = nn.Linear(4, 3)
|
| 191 |
+
+ self.confidence = nn.Linear(4, 1)
|
| 192 |
+
+
|
| 193 |
+
+ def forward(self, x, return_confidence=False):
|
| 194 |
+
+ flat = x.view(x.shape[0], -1)
|
| 195 |
+
+ pred = self.linear(flat)
|
| 196 |
+
+ confidence = self.confidence(flat)
|
| 197 |
+
+ if return_confidence:
|
| 198 |
+
+ return pred, confidence
|
| 199 |
+
+ return pred
|
| 200 |
+
+
|
| 201 |
+
+ config = AttrDict(
|
| 202 |
+
+ {
|
| 203 |
+
+ "baseline": False,
|
| 204 |
+
+ "num_classes": 3,
|
| 205 |
+
+ "trainer": {"budget": 0.3, "lmbda": 0.1, "eps": 1.0e-12},
|
| 206 |
+
+ "optimizer": {
|
| 207 |
+
+ "lr": 0.01,
|
| 208 |
+
+ "momentum": 0.0,
|
| 209 |
+
+ "nesterov": False,
|
| 210 |
+
+ "weight_decay": 0.0,
|
| 211 |
+
+ },
|
| 212 |
+
+ "scheduler": {"milestones": [1], "gamma": 1.0},
|
| 213 |
+
+ }
|
| 214 |
+
+ )
|
| 215 |
+
+ loader = TinyLoader(
|
| 216 |
+
+ [
|
| 217 |
+
+ {
|
| 218 |
+
+ "data": torch.tensor(
|
| 219 |
+
+ [[[[0.0, 1.0], [2.0, 3.0]]], [[[1.0, 0.0], [1.0, 0.0]]]]
|
| 220 |
+
+ ),
|
| 221 |
+
+ "label": torch.tensor([0, 2]),
|
| 222 |
+
+ }
|
| 223 |
+
+ ]
|
| 224 |
+
+ )
|
| 225 |
+
+ trainer = ConfBranchTrainer(TinyConfNet(), loader, config)
|
| 226 |
+
+
|
| 227 |
+
+ _, metrics = trainer.train_epoch(epoch_idx=11)
|
| 228 |
+
+
|
| 229 |
+
+ assert isinstance(metrics, dict)
|
| 230 |
+
+ assert metrics["epoch_idx"] == 11
|
| 231 |
+
+ assert "train_acc" in metrics
|
| 232 |
+
+ assert "loss" in metrics
|
| 233 |
+
+ assert math.isfinite(float(torch.as_tensor(metrics["loss"]).item()))
|
| 234 |
+
diff --git a/tests/test_opengan_registry.py b/tests/test_opengan_registry.py
|
| 235 |
+
new file mode 100644
|
| 236 |
+
index 0000000..10afecf
|
| 237 |
+
--- /dev/null
|
| 238 |
+
+++ b/tests/test_opengan_registry.py
|
| 239 |
+
@@ -0,0 +1,89 @@
|
| 240 |
+
+import sys
|
| 241 |
+
+import types
|
| 242 |
+
+
|
| 243 |
+
+import torch
|
| 244 |
+
+import torch.nn as nn
|
| 245 |
+
+
|
| 246 |
+
+
|
| 247 |
+
+def _install_optional_dependency_stubs():
|
| 248 |
+
+ diffdist = types.ModuleType("diffdist")
|
| 249 |
+
+ diffdist_functional = types.ModuleType("diffdist.functional")
|
| 250 |
+
+ diffdist.functional = diffdist_functional
|
| 251 |
+
+ sys.modules.setdefault("diffdist", diffdist)
|
| 252 |
+
+ sys.modules.setdefault("diffdist.functional", diffdist_functional)
|
| 253 |
+
+ sys.modules.setdefault("libmr", types.ModuleType("libmr"))
|
| 254 |
+
+ sys.modules.setdefault("faiss", types.ModuleType("faiss"))
|
| 255 |
+
+
|
| 256 |
+
+
|
| 257 |
+
+_install_optional_dependency_stubs()
|
| 258 |
+
+
|
| 259 |
+
+from openood.postprocessors.opengan_postprocessor import OpenGanPostprocessor
|
| 260 |
+
+from openood.postprocessors.utils import get_postprocessor
|
| 261 |
+
+from openood.trainers.opengan_trainer import OpenGanTrainer
|
| 262 |
+
+from openood.trainers.utils import get_trainer
|
| 263 |
+
+
|
| 264 |
+
+
|
| 265 |
+
+class AttrDict(dict):
|
| 266 |
+
+ def __getattr__(self, name):
|
| 267 |
+
+ try:
|
| 268 |
+
+ value = self[name]
|
| 269 |
+
+ except KeyError as exc:
|
| 270 |
+
+ raise AttributeError(name) from exc
|
| 271 |
+
+ if isinstance(value, dict):
|
| 272 |
+
+ value = AttrDict(value)
|
| 273 |
+
+ self[name] = value
|
| 274 |
+
+ return value
|
| 275 |
+
+
|
| 276 |
+
+ def __setattr__(self, name, value):
|
| 277 |
+
+ self[name] = value
|
| 278 |
+
+
|
| 279 |
+
+
|
| 280 |
+
+def test_opengan_postprocessor_registry_accepts_lowercase_name():
|
| 281 |
+
+ config = AttrDict(
|
| 282 |
+
+ {
|
| 283 |
+
+ "postprocessor": {"name": "opengan"},
|
| 284 |
+
+ "network": {"name": "opengan"},
|
| 285 |
+
+ "dataset": {"name": "cifar10", "num_classes": 10},
|
| 286 |
+
+ "num_classes": 10,
|
| 287 |
+
+ }
|
| 288 |
+
+ )
|
| 289 |
+
+
|
| 290 |
+
+ postprocessor = get_postprocessor(config)
|
| 291 |
+
+
|
| 292 |
+
+ assert isinstance(postprocessor, OpenGanPostprocessor)
|
| 293 |
+
+
|
| 294 |
+
+
|
| 295 |
+
+class TinyGenerator(nn.Module):
|
| 296 |
+
+ def __init__(self):
|
| 297 |
+
+ super().__init__()
|
| 298 |
+
+ self.weight = nn.Parameter(torch.ones(1))
|
| 299 |
+
+
|
| 300 |
+
+ def forward(self, z):
|
| 301 |
+
+ return z[:, :1] * self.weight.view(1, 1, 1, 1)
|
| 302 |
+
+
|
| 303 |
+
+
|
| 304 |
+
+class TinyDiscriminator(nn.Module):
|
| 305 |
+
+ def __init__(self):
|
| 306 |
+
+ super().__init__()
|
| 307 |
+
+ self.weight = nn.Parameter(torch.ones(1))
|
| 308 |
+
+
|
| 309 |
+
+ def forward(self, x):
|
| 310 |
+
+ dims = tuple(range(1, x.ndim))
|
| 311 |
+
+ return torch.sigmoid(x.mean(dim=dims, keepdim=True) * self.weight)
|
| 312 |
+
+
|
| 313 |
+
+
|
| 314 |
+
+def test_opengan_trainer_registry_accepts_lowercase_name():
|
| 315 |
+
+ config = AttrDict(
|
| 316 |
+
+ {
|
| 317 |
+
+ "trainer": {"name": "opengan"},
|
| 318 |
+
+ "optimizer": {"num_epochs": 1, "lr": 0.001, "beta1": 0.5},
|
| 319 |
+
+ "dataset": {"num_classes": 10},
|
| 320 |
+
+ "network": {"name": "opengan", "nz": 2},
|
| 321 |
+
+ "num_classes": 10,
|
| 322 |
+
+ }
|
| 323 |
+
+ )
|
| 324 |
+
+ net = {"netG": TinyGenerator(), "netD": TinyDiscriminator()}
|
| 325 |
+
+
|
| 326 |
+
+ trainer = get_trainer(net, [], config)
|
| 327 |
+
+
|
| 328 |
+
+ assert isinstance(trainer, OpenGanTrainer)
|
| 329 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 330 |
+
new file mode 100755
|
| 331 |
+
--- /dev/null
|
| 332 |
+
+++ b/mimo_test_command.sh
|
| 333 |
+
@@ -0,0 +1,46 @@
|
| 334 |
+
+#!/bin/bash
|
| 335 |
+
+set -uo pipefail
|
| 336 |
+
+cd /testbed
|
| 337 |
+
+
|
| 338 |
+
+
|
| 339 |
+
+set +u
|
| 340 |
+
+source /testbed/.build_env/.venv/bin/activate
|
| 341 |
+
+set -u
|
| 342 |
+
+
|
| 343 |
+
+
|
| 344 |
+
+NEW_TESTS=(
|
| 345 |
+
+ tests/test_conf_branch_pipeline.py
|
| 346 |
+
+ tests/test_opengan_registry.py
|
| 347 |
+
+)
|
| 348 |
+
+
|
| 349 |
+
+case "${1:-}" in
|
| 350 |
+
+ base)
|
| 351 |
+
+ base_tests=()
|
| 352 |
+
+ if [ -d tests ]; then
|
| 353 |
+
+ while IFS= read -r test_file; do
|
| 354 |
+
+ skip=false
|
| 355 |
+
+ for new_test in "${NEW_TESTS[@]}"; do
|
| 356 |
+
+ if [ "$test_file" = "$new_test" ]; then
|
| 357 |
+
+ skip=true
|
| 358 |
+
+ break
|
| 359 |
+
+ fi
|
| 360 |
+
+ done
|
| 361 |
+
+ if [ "$skip" = false ]; then
|
| 362 |
+
+ base_tests+=("$test_file")
|
| 363 |
+
+ fi
|
| 364 |
+
+ done < <(find tests -type f -name 'test*.py' | sort)
|
| 365 |
+
+ fi
|
| 366 |
+
+ if [ "${#base_tests[@]}" -eq 0 ]; then
|
| 367 |
+
+ echo "No pre-existing tests to run for base regression."
|
| 368 |
+
+ exit 0
|
| 369 |
+
+ fi
|
| 370 |
+
+ python -m pytest -q "${base_tests[@]}"
|
| 371 |
+
+ ;;
|
| 372 |
+
+ new)
|
| 373 |
+
+ python -m pytest -q "${NEW_TESTS[@]}"
|
| 374 |
+
+ ;;
|
| 375 |
+
+ *)
|
| 376 |
+
+ echo "usage: $0 base|new"
|
| 377 |
+
+ exit 2
|
| 378 |
+
+ ;;
|
| 379 |
+
+esac
|
tasks/format-code-task-000126/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
tests/test_conf_branch_pipeline.py
|
| 25 |
+
tests/test_opengan_registry.py
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000126/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new
|
tasks/format-code-task-000128/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a25b8fadbd7967d3a6e5ac252a5f462ace826f0ba0ef615259bcdbafc444e7e2
|
tasks/format-code-task-000128/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000128/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000128/tests/test.patch
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/src/blocks/blockAllContributors.prettierIgnore.test.ts b/src/blocks/blockAllContributors.prettierIgnore.test.ts
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 0000000..ad10ef6
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/src/blocks/blockAllContributors.prettierIgnore.test.ts
|
| 6 |
+
@@ -0,0 +1,51 @@
|
| 7 |
+
+import { testBlock } from "bingo-stratum-testers";
|
| 8 |
+
+import { describe, expect, it } from "vitest";
|
| 9 |
+
+
|
| 10 |
+
+import { blockAllContributors } from "./blockAllContributors.js";
|
| 11 |
+
+import { blockPrettier } from "./blockPrettier.js";
|
| 12 |
+
+import { optionsBase } from "./options.fakes.js";
|
| 13 |
+
+
|
| 14 |
+
+describe("blockAllContributors prettier ignore", () => {
|
| 15 |
+
+ it("registers a Prettier addon ignoring .all-contributorsrc by default", () => {
|
| 16 |
+
+ const creation = testBlock(blockAllContributors, { options: optionsBase });
|
| 17 |
+
+
|
| 18 |
+
+ const prettierAddons = (creation.addons ?? []).filter(
|
| 19 |
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 20 |
+
+ (addon: any) => addon.block === blockPrettier,
|
| 21 |
+
+ );
|
| 22 |
+
+
|
| 23 |
+
+ expect(prettierAddons).toHaveLength(1);
|
| 24 |
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 25 |
+
+ expect((prettierAddons[0] as any).addons).toEqual({
|
| 26 |
+
+ ignores: ["/.all-contributorsrc"],
|
| 27 |
+
+ });
|
| 28 |
+
+ });
|
| 29 |
+
+
|
| 30 |
+
+ it("registers a Prettier addon ignoring .all-contributorsrc when contributors are provided", () => {
|
| 31 |
+
+ const creation = testBlock(blockAllContributors, {
|
| 32 |
+
+ options: {
|
| 33 |
+
+ ...optionsBase,
|
| 34 |
+
+ contributors: [
|
| 35 |
+
+ {
|
| 36 |
+
+ avatar_url: "https://avatars.githubusercontent.com/u/3335181?v=4",
|
| 37 |
+
+ contributions: ["code"],
|
| 38 |
+
+ login: "JoshuaKGoldberg",
|
| 39 |
+
+ name: "Josh Goldberg",
|
| 40 |
+
+ profile: "http://www.joshuakgoldberg.com",
|
| 41 |
+
+ },
|
| 42 |
+
+ ],
|
| 43 |
+
+ },
|
| 44 |
+
+ });
|
| 45 |
+
+
|
| 46 |
+
+ const prettierAddons = (creation.addons ?? []).filter(
|
| 47 |
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 48 |
+
+ (addon: any) => addon.block === blockPrettier,
|
| 49 |
+
+ );
|
| 50 |
+
+
|
| 51 |
+
+ expect(prettierAddons).toHaveLength(1);
|
| 52 |
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 53 |
+
+ expect((prettierAddons[0] as any).addons).toEqual({
|
| 54 |
+
+ ignores: ["/.all-contributorsrc"],
|
| 55 |
+
+ });
|
| 56 |
+
+ });
|
| 57 |
+
+});
|
| 58 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 59 |
+
new file mode 100644
|
| 60 |
+
index 0000000..850c589
|
| 61 |
+
--- /dev/null
|
| 62 |
+
+++ b/test_commands.json
|
| 63 |
+
@@ -0,0 +1,3 @@
|
| 64 |
+
+{
|
| 65 |
+
+ "test_commands": ["./node_modules/.bin/vitest run src/blocks/blockAllContributors.prettierIgnore.test.ts"]
|
| 66 |
+
+}
|
| 67 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 68 |
+
new file mode 100755
|
| 69 |
+
--- /dev/null
|
| 70 |
+
+++ b/mimo_test_command.sh
|
| 71 |
+
@@ -0,0 +1,8 @@
|
| 72 |
+
+#!/usr/bin/env bash
|
| 73 |
+
+
|
| 74 |
+
+set -uo pipefail
|
| 75 |
+
+cd /testbed
|
| 76 |
+
+rc=0
|
| 77 |
+
+./node_modules/.bin/vitest run src/blocks/blockAllContributors.prettierIgnore.test.ts
|
| 78 |
+
+rc=$(( rc | $? ))
|
| 79 |
+
+exit $rc
|
tasks/format-code-task-000128/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
src/blocks/blockAllContributors.prettierIgnore.test.ts
|
| 25 |
+
test_commands.json
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000128/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000142/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:49f7045c50e95318ff47ec2e37825352f8f359a7f4a14b8e909be303494378ce
|
tasks/format-code-task-000142/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000142/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000142/tests/test.patch
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 000000000..4a3500017
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/test_commands.json
|
| 6 |
+
@@ -0,0 +1,3 @@
|
| 7 |
+
+{
|
| 8 |
+
+ "test_commands": ["python -m pytest tests/utilities/test_parsing.py -p no:cacheprovider -v"]
|
| 9 |
+
+}
|
| 10 |
+
diff --git a/tests/utilities/test_parsing.py b/tests/utilities/test_parsing.py
|
| 11 |
+
index c07a016ed..8994ee939 100644
|
| 12 |
+
--- a/tests/utilities/test_parsing.py
|
| 13 |
+
+++ b/tests/utilities/test_parsing.py
|
| 14 |
+
@@ -12,6 +12,8 @@
|
| 15 |
+
# See the License for the specific language governing permissions and
|
| 16 |
+
# limitations under the License.
|
| 17 |
+
|
| 18 |
+
+import pytest
|
| 19 |
+
+
|
| 20 |
+
from pytorch_lightning.utilities.parsing import lightning_getattr, lightning_hasattr, lightning_setattr
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
@@ -126,3 +128,86 @@ def test_lightning_setattr(tmpdir):
|
| 24 |
+
'batch_size not correctly set'
|
| 25 |
+
assert lightning_getattr(model7, 'batch_size') == 128, \
|
| 26 |
+
'batch_size not correctly set'
|
| 27 |
+
+
|
| 28 |
+
+
|
| 29 |
+
+def test_lightning_getattr_raises_attribute_error_on_missing_model_only():
|
| 30 |
+
+ """lightning_getattr must raise AttributeError (not ValueError) when attribute is missing."""
|
| 31 |
+
+
|
| 32 |
+
+ class TestModel:
|
| 33 |
+
+ batch_size = 1
|
| 34 |
+
+
|
| 35 |
+
+ model = TestModel()
|
| 36 |
+
+ with pytest.raises(AttributeError):
|
| 37 |
+
+ lightning_getattr(model, 'learning_rate')
|
| 38 |
+
+
|
| 39 |
+
+
|
| 40 |
+
+def test_lightning_getattr_raises_attribute_error_on_missing_with_hparams_and_datamodule():
|
| 41 |
+
+ """lightning_getattr must raise AttributeError when attribute is missing across model/hparams/datamodule."""
|
| 42 |
+
+ models = _get_test_cases()
|
| 43 |
+
+
|
| 44 |
+
+ model4 = models[3]
|
| 45 |
+
+ with pytest.raises(AttributeError):
|
| 46 |
+
+ lightning_getattr(model4, 'learning_rate')
|
| 47 |
+
+
|
| 48 |
+
+
|
| 49 |
+
+ model5 = models[4]
|
| 50 |
+
+ with pytest.raises(AttributeError):
|
| 51 |
+
+ lightning_getattr(model5, 'learning_rate')
|
| 52 |
+
+
|
| 53 |
+
+
|
| 54 |
+
+def test_lightning_getattr_not_value_error():
|
| 55 |
+
+ """Regression: lightning_getattr must NOT raise ValueError when attribute is missing."""
|
| 56 |
+
+
|
| 57 |
+
+ class TestModel:
|
| 58 |
+
+ pass
|
| 59 |
+
+
|
| 60 |
+
+ model = TestModel()
|
| 61 |
+
+ with pytest.raises(AttributeError):
|
| 62 |
+
+ lightning_getattr(model, 'nonexistent_attr')
|
| 63 |
+
+
|
| 64 |
+
+ try:
|
| 65 |
+
+ lightning_getattr(model, 'nonexistent_attr')
|
| 66 |
+
+ except ValueError:
|
| 67 |
+
+ pytest.fail("lightning_getattr raised ValueError; expected AttributeError")
|
| 68 |
+
+ except AttributeError:
|
| 69 |
+
+ pass
|
| 70 |
+
+
|
| 71 |
+
+
|
| 72 |
+
+def test_lightning_setattr_raises_attribute_error_on_missing():
|
| 73 |
+
+ """lightning_setattr must raise AttributeError (not ValueError) when attribute is missing."""
|
| 74 |
+
+
|
| 75 |
+
+ class TestModel:
|
| 76 |
+
+ batch_size = 1
|
| 77 |
+
+
|
| 78 |
+
+ model = TestModel()
|
| 79 |
+
+ with pytest.raises(AttributeError):
|
| 80 |
+
+ lightning_setattr(model, 'learning_rate', 10)
|
| 81 |
+
+
|
| 82 |
+
+
|
| 83 |
+
+def test_lightning_setattr_not_value_error():
|
| 84 |
+
+ """Regression: lightning_setattr must NOT raise ValueError when attribute is missing."""
|
| 85 |
+
+
|
| 86 |
+
+ class TestModel:
|
| 87 |
+
+ pass
|
| 88 |
+
+
|
| 89 |
+
+ model = TestModel()
|
| 90 |
+
+ with pytest.raises(AttributeError):
|
| 91 |
+
+ lightning_setattr(model, 'nonexistent_attr', 1)
|
| 92 |
+
+ try:
|
| 93 |
+
+ lightning_setattr(model, 'nonexistent_attr', 1)
|
| 94 |
+
+ except ValueError:
|
| 95 |
+
+ pytest.fail("lightning_setattr raised ValueError; expected AttributeError")
|
| 96 |
+
+ except AttributeError:
|
| 97 |
+
+ pass
|
| 98 |
+
+
|
| 99 |
+
+
|
| 100 |
+
+def test_lightning_getattr_preserves_successful_access():
|
| 101 |
+
+ """Preservation: lightning_getattr still returns correct values for present attributes."""
|
| 102 |
+
+ models = _get_test_cases()
|
| 103 |
+
+ for i, m in enumerate(models[:3]):
|
| 104 |
+
+ assert lightning_getattr(m, 'learning_rate') == i
|
| 105 |
+
+
|
| 106 |
+
+ model5, model6, model7 = models[4:]
|
| 107 |
+
+ assert lightning_getattr(model5, 'batch_size') == 8
|
| 108 |
+
+ assert lightning_getattr(model6, 'batch_size') == 8
|
| 109 |
+
+ assert lightning_getattr(model7, 'batch_size') == 8
|
| 110 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 111 |
+
new file mode 100755
|
| 112 |
+
--- /dev/null
|
| 113 |
+
+++ b/mimo_test_command.sh
|
| 114 |
+
@@ -0,0 +1,8 @@
|
| 115 |
+
+#!/usr/bin/env bash
|
| 116 |
+
+
|
| 117 |
+
+set -uo pipefail
|
| 118 |
+
+cd /testbed
|
| 119 |
+
+rc=0
|
| 120 |
+
+python -m pytest tests/utilities/test_parsing.py -p no:cacheprovider -v
|
| 121 |
+
+rc=$(( rc | $? ))
|
| 122 |
+
+exit $rc
|
tasks/format-code-task-000142/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
test_commands.json
|
| 25 |
+
tests/utilities/test_parsing.py
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000142/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000143/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1d1b433a00baa9203ea86bf4697e820e0e2367fa0de8d9186f80fb6d3c2fbc11
|
tasks/format-code-task-000143/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000143/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000143/tests/test.patch
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 000000000..5c4667e36
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/test_commands.json
|
| 6 |
+
@@ -0,0 +1,3 @@
|
| 7 |
+
+{
|
| 8 |
+
+ "test_commands": ["python -m pytest tests/core/test_datamodules.py -k \"iterable or map_dataset_still\" -v"]
|
| 9 |
+
+}
|
| 10 |
+
diff --git a/tests/core/test_datamodules.py b/tests/core/test_datamodules.py
|
| 11 |
+
index c8808ec37..801f69751 100644
|
| 12 |
+
--- a/tests/core/test_datamodules.py
|
| 13 |
+
+++ b/tests/core/test_datamodules.py
|
| 14 |
+
@@ -497,3 +497,70 @@ def test_dm_init_from_datasets(tmpdir):
|
| 15 |
+
assert torch.all(next(iter(dm.val_dataloader()[1])) == torch.ones(4))
|
| 16 |
+
assert torch.all(next(iter(dm.test_dataloader()[0])) == torch.ones(4))
|
| 17 |
+
assert torch.all(next(iter(dm.test_dataloader()[1])) == torch.ones(4))
|
| 18 |
+
+
|
| 19 |
+
+
|
| 20 |
+
+class DummyIDS(torch.utils.data.IterableDataset):
|
| 21 |
+
+
|
| 22 |
+
+ def __iter__(self):
|
| 23 |
+
+ yield 1
|
| 24 |
+
+ yield 1
|
| 25 |
+
+ yield 1
|
| 26 |
+
+ yield 1
|
| 27 |
+
+
|
| 28 |
+
+
|
| 29 |
+
+def test_dm_init_from_datasets_iterable_train_single(tmpdir):
|
| 30 |
+
+ """Passing a single IterableDataset as train_dataset should not raise."""
|
| 31 |
+
+ train_ds = DummyIDS()
|
| 32 |
+
+ dm = LightningDataModule.from_datasets(train_ds, batch_size=4, num_workers=0)
|
| 33 |
+
+
|
| 34 |
+
+
|
| 35 |
+
+ batch = next(iter(dm.train_dataloader()))
|
| 36 |
+
+ assert torch.all(batch == torch.ones(4))
|
| 37 |
+
+
|
| 38 |
+
+
|
| 39 |
+
+def test_dm_init_from_datasets_iterable_train_sequence(tmpdir):
|
| 40 |
+
+ """Passing a Sequence of IterableDatasets as train_dataset should not raise."""
|
| 41 |
+
+ train_dss = [DummyIDS(), DummyIDS()]
|
| 42 |
+
+ dm = LightningDataModule.from_datasets(train_dss, batch_size=4, num_workers=0)
|
| 43 |
+
+ dls = dm.train_dataloader()
|
| 44 |
+
+ assert isinstance(dls, list) and len(dls) == 2
|
| 45 |
+
+ for dl in dls:
|
| 46 |
+
+ assert torch.all(next(iter(dl)) == torch.ones(4))
|
| 47 |
+
+
|
| 48 |
+
+
|
| 49 |
+
+def test_dm_init_from_datasets_iterable_train_mapping(tmpdir):
|
| 50 |
+
+ """Passing a Mapping of IterableDatasets as train_dataset should not raise."""
|
| 51 |
+
+ train_dss = {"a": DummyIDS(), "b": DummyIDS()}
|
| 52 |
+
+ dm = LightningDataModule.from_datasets(train_dss, batch_size=4, num_workers=0)
|
| 53 |
+
+ dls = dm.train_dataloader()
|
| 54 |
+
+ assert isinstance(dls, dict) and set(dls.keys()) == {"a", "b"}
|
| 55 |
+
+ for dl in dls.values():
|
| 56 |
+
+ assert torch.all(next(iter(dl)) == torch.ones(4))
|
| 57 |
+
+
|
| 58 |
+
+
|
| 59 |
+
+def test_dm_init_from_datasets_iterable_val_test(tmpdir):
|
| 60 |
+
+ """Passing IterableDatasets as val_dataset and test_dataset should not raise."""
|
| 61 |
+
+ train_ds = DummyIDS()
|
| 62 |
+
+ val_ds = DummyIDS()
|
| 63 |
+
+ test_ds = DummyIDS()
|
| 64 |
+
+ dm = LightningDataModule.from_datasets(train_ds, val_ds, test_ds, batch_size=4, num_workers=0)
|
| 65 |
+
+ assert torch.all(next(iter(dm.val_dataloader())) == torch.ones(4))
|
| 66 |
+
+ assert torch.all(next(iter(dm.test_dataloader())) == torch.ones(4))
|
| 67 |
+
+
|
| 68 |
+
+
|
| 69 |
+
+def test_dm_init_from_datasets_map_dataset_still_shuffled(tmpdir):
|
| 70 |
+
+ """Preservation: regular Datasets passed as train_dataset still get a shuffling sampler."""
|
| 71 |
+
+ from torch.utils.data.sampler import RandomSampler
|
| 72 |
+
+ train_ds = DummyDS()
|
| 73 |
+
+ dm = LightningDataModule.from_datasets(train_ds, batch_size=4, num_workers=0)
|
| 74 |
+
+ dl = dm.train_dataloader()
|
| 75 |
+
+ assert isinstance(dl.sampler, RandomSampler)
|
| 76 |
+
+
|
| 77 |
+
+
|
| 78 |
+
+def test_dm_init_from_datasets_iterable_train_no_random_sampler(tmpdir):
|
| 79 |
+
+ """Iterable train datasets must not be wrapped with a shuffling sampler."""
|
| 80 |
+
+ from torch.utils.data.sampler import RandomSampler
|
| 81 |
+
+ train_ds = DummyIDS()
|
| 82 |
+
+ dm = LightningDataModule.from_datasets(train_ds, batch_size=4, num_workers=0)
|
| 83 |
+
+ dl = dm.train_dataloader()
|
| 84 |
+
+ assert not isinstance(dl.sampler, RandomSampler)
|
| 85 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 86 |
+
new file mode 100755
|
| 87 |
+
--- /dev/null
|
| 88 |
+
+++ b/mimo_test_command.sh
|
| 89 |
+
@@ -0,0 +1,8 @@
|
| 90 |
+
+#!/usr/bin/env bash
|
| 91 |
+
+
|
| 92 |
+
+set -uo pipefail
|
| 93 |
+
+cd /testbed
|
| 94 |
+
+rc=0
|
| 95 |
+
+python -m pytest tests/core/test_datamodules.py -k "iterable or map_dataset_still" -v
|
| 96 |
+
+rc=$(( rc | $? ))
|
| 97 |
+
+exit $rc
|
tasks/format-code-task-000143/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
test_commands.json
|
| 25 |
+
tests/core/test_datamodules.py
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000143/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000145/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:29577823022722e55b070071b9ed4d0f80d6f61af23eac17daeb2db05a34210a
|
tasks/format-code-task-000145/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|