MiMo-V2.6-RL-harbor-terminal / tasks /candidate-0036-software-data-engineering /tests /test_outputs.py
Download tasks/candidate-0036-software-data-engineering/tests/test_outputs.py from FineEnvs/MiMo-V2.6-RL-harbor-terminal: direct link, hf CLI and curl.
- Browser
- Download file 3.04 kB
-
https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-terminal/resolve/main/tasks/candidate-0036-software-data-engineering/tests/test_outputs.py
- Command line
-
hf download hf://datasets/FineEnvs/MiMo-V2.6-RL-harbor-terminal/tasks/candidate-0036-software-data-engineering/tests/test_outputs.py
-
curl -L -o test_outputs.py https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-terminal/resolve/main/tasks/candidate-0036-software-data-engineering/tests/test_outputs.py
3.04 kB
| from __future__ import annotations | |
| import hashlib | |
| import json | |
| import re | |
| import subprocess | |
| from pathlib import Path | |
| APP = Path("/app") | |
| FIX = Path(__file__).parent / "fixtures" | |
| REPORT = APP / "output.json" | |
| RULES = APP / "vendor/snakemake/src/snakemake/rules.py" | |
| JOBS = APP / "vendor/snakemake/src/snakemake/jobs.py" | |
| def digest(path: Path) -> str: | |
| return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def parsed() -> dict: | |
| assert REPORT.is_file() | |
| value = json.loads(REPORT.read_text(encoding="utf-8")) | |
| assert value["output_schema_version"] == "workflow-repair-1" | |
| return value | |
| def test_gate_source_tree_and_report_contract() -> None: | |
| hashes = json.loads((FIX / "source_hashes.json").read_text()) | |
| for rel, expected in hashes["protected"].items(): | |
| assert digest(APP / rel) == expected, rel | |
| assert digest(RULES) != hashes["mutable_base"]["vendor/snakemake/src/snakemake/rules.py"] | |
| assert "self.touch_output = set()" not in RULES.read_text() | |
| assert "if f_ in self.rule.touch_output" not in JOBS.read_text() | |
| value = parsed() | |
| assert value["source_witness"]["both_mutable_modules_changed"] is True | |
| assert value["aggregate"]["complete"] is True | |
| def test_core_independent_touch_and_wildcard_recompute() -> None: | |
| value = parsed() | |
| jobs = value["jobs"] | |
| assert [j["wildcard"] for j in jobs] == ["alpha", "beta"] | |
| for job in jobs: | |
| expected = f"markers/{job['wildcard']}.ready" | |
| assert job["touch_output"] == [expected] | |
| assert job["outputs"][0]["path"] == expected | |
| assert job["outputs"][0]["flags"] == ["touch"] | |
| def test_core_independent_non_touch_flags_recompute() -> None: | |
| value = parsed() | |
| for job in value["jobs"]: | |
| name = job["wildcard"] | |
| assert job["temp_output"] == [f"cache/{name}.bin"] | |
| assert job["protected_output"] == [f"cache/{name}.bin"] | |
| assert job["pipe_or_service_output"] == [f"streams/{name}.pipe"] | |
| assert set(job["outputs"][1]["flags"]) == {"protected", "temp"} | |
| assert set(job["outputs"][2]["flags"]) == {"pipe", "service"} | |
| def test_edge_constraint_and_downstream_replay() -> None: | |
| value = parsed() | |
| assert value["aggregate"] == {"complete": True, "targets": ["alpha", "beta"]} | |
| assert all(j["downstream_complete"] for j in value["jobs"]) | |
| assert re.fullmatch(r"[a-z]+", "alpha") and not re.fullmatch(r"[a-z]+", "beta-2") | |
| rerun = subprocess.run(["python3", str(APP / "workflow_probe.py")], cwd=APP, text=True, capture_output=True) | |
| assert rerun.returncode == 0, rerun.stderr | |
| assert parsed()["jobs"] == value["jobs"] | |
| def test_edge_all_categories_are_derived_from_expanded_item() -> None: | |
| source = JOBS.read_text() | |
| for flag in ("temp", "protected", "touch"): | |
| assert f'is_flagged(f_, "{flag}")' in source | |
| assert "is_flagged(f_, \"pipe\")" in source or 'is_flagged(f_, "service")' in source | |
| rules = RULES.read_text() | |
| assert "self.protected_output = set()" not in rules | |
| assert "self.temp_output = set()" not in rules | |