Download tools/validate.py from noodcon/TerminalBench-DockerLess: direct link, hf CLI and curl.
- Browser
- Download file 4.69 kB
-
https://huggingface.co/datasets/noodcon/TerminalBench-DockerLess/resolve/main/tools/validate.py
- Command line
-
hf download hf://datasets/noodcon/TerminalBench-DockerLess/tools/validate.py
-
curl -L -o validate.py https://huggingface.co/datasets/noodcon/TerminalBench-DockerLess/resolve/main/tools/validate.py
4.69 kB
| """Structural validation for TerminalBench-DockerLess.jsonl. | |
| Checks that every row carries the classic Terminal-Bench task.yaml fields and the | |
| Harbor task.toml rendering, that the embedded task directory is complete, that | |
| the verifier and instruction do not leak each other, and that every task is | |
| non-trivial (something must fail before any agent acts). | |
| Run with: python tools/validate.py | |
| """ | |
| import json | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| DATASET = ROOT / "TerminalBench-DockerLess.jsonl" | |
| TB_FIELDS = [ | |
| "task_id", | |
| "instruction", | |
| "author_name", | |
| "author_email", | |
| "difficulty", | |
| "category", | |
| "tags", | |
| "parser_name", | |
| "max_agent_timeout_sec", | |
| "max_test_timeout_sec", | |
| "expert_time_estimate_min", | |
| "junior_time_estimate_min", | |
| "task_yaml", | |
| "task_toml", | |
| "dockerfile", | |
| "solution", | |
| "tests", | |
| "dockerless", | |
| ] | |
| REQUIRED_FILES = ["instruction.md", "environment/Dockerfile", "solution/solve.sh", "tests/test.sh"] | |
| MAX_INSTRUCTION_CHARS = 4000 | |
| MIN_AGENT_TIMEOUT = 60 | |
| MIN_TEST_TIMEOUT = 30 | |
| failures = [] | |
| def check(condition, message): | |
| if not condition: | |
| failures.append(message) | |
| def main(): | |
| rows = [json.loads(line) for line in open(DATASET, encoding="utf-8") if line.strip()] | |
| check(len(rows) == 4, "expected 4 rows, found %d" % len(rows)) | |
| seen = set() | |
| for row in rows: | |
| tid = row.get("task_id", "<missing>") | |
| for field in TB_FIELDS: | |
| check(field in row, "%s: missing field %s" % (tid, field)) | |
| check(tid not in seen, "%s: duplicate task_id" % tid) | |
| seen.add(tid) | |
| instruction = row["instruction"] | |
| check(len(instruction.strip()) > 200, "%s: instruction too short" % tid) | |
| check(len(instruction) <= MAX_INSTRUCTION_CHARS, "%s: instruction too long" % tid) | |
| check("::" not in instruction, "%s: instruction leaks a test node id" % tid) | |
| check("test_outputs" not in instruction, "%s: instruction names the verifier file" % tid) | |
| check(row["parser_name"] == "pytest", "%s: parser_name must be pytest" % tid) | |
| check(row["difficulty"] in ("easy", "medium", "hard"), "%s: bad difficulty" % tid) | |
| check(row["max_agent_timeout_sec"] >= MIN_AGENT_TIMEOUT, "%s: agent timeout too small" % tid) | |
| check(row["max_test_timeout_sec"] >= MIN_TEST_TIMEOUT, "%s: test timeout too small" % tid) | |
| yaml = row["task_yaml"] | |
| for needle in ("instruction: |", "parser_name: pytest", "difficulty: ", "max_agent_timeout_sec:"): | |
| check(needle in yaml, "%s: task_yaml missing %r" % (tid, needle)) | |
| toml = row["task_toml"] | |
| for needle in ('schema_version = "1.4"', "[verifier]", "[agent]", "[environment]"): | |
| check(needle in toml, "%s: task_toml missing %r" % (tid, needle)) | |
| tests = row["tests"] | |
| check("test.sh" in tests, "%s: tests/test.sh missing" % tid) | |
| check("test_outputs.py" in tests, "%s: tests/test_outputs.py missing" % tid) | |
| check(row["solution"].strip() != "", "%s: empty solution" % tid) | |
| check("FROM " in row["dockerfile"], "%s: dockerfile does not look like a Dockerfile" % tid) | |
| dockerless = row["dockerless"] | |
| files = dockerless["files"] | |
| for rel in files: | |
| check(not rel.startswith("/"), "%s: absolute path in snapshot: %s" % (tid, rel)) | |
| check(".." not in Path(rel).parts, "%s: escaping path in snapshot: %s" % (tid, rel)) | |
| check("Dockerfile" not in files, "%s: snapshot contains the Dockerfile" % tid) | |
| check("setup.sh" not in files, "%s: snapshot contains setup.sh" % tid) | |
| check( | |
| bool(dockerless["baseline_failures"]), | |
| "%s: nothing fails before the agent acts" % tid, | |
| ) | |
| check( | |
| bool(dockerless.get("setup", "").strip()) or bool(files), | |
| "%s: task has neither setup script nor files" % tid, | |
| ) | |
| print( | |
| "%-24s %-6s files=%-2d tests=%-2d baseline_fail=%-2d instr=%d chars" | |
| % ( | |
| tid, | |
| row["difficulty"], | |
| len(files), | |
| len(tests) - 1, | |
| len(dockerless["baseline_failures"]), | |
| len(instruction), | |
| ) | |
| ) | |
| total_chars = DATASET.stat().st_size | |
| print("\n%d tasks, %.1f KiB (~%d tokens)" % (len(rows), total_chars / 1024.0, total_chars // 4)) | |
| if failures: | |
| print("\nFAILED %d checks:" % len(failures)) | |
| for message in failures: | |
| print(" - %s" % message) | |
| return 1 | |
| print("all checks passed") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |