| |
| """Integration test for the multimodal task system (free, local, no model). |
| |
| Runs each modality's verifier on a known-GOOD and known-BAD example to prove the |
| objective reward signal works, plus the blended-reward routing. The full model-in-the-loop |
| integration is the smoke run on HF; this proves the verifier plumbing first. |
| """ |
| import sys |
| from pathlib import Path |
|
|
| HERE = Path(__file__).resolve().parent |
| sys.path.insert(0, str(HERE)) |
|
|
|
|
| def ok(m): print(" [PASS]", m) |
| def fail(m): print(" [FAIL]", m); sys.exit(1) |
|
|
|
|
| def main(): |
| print("INTEGRATION checks (verifiers, free):") |
| from core import verifiers as V |
| from core import modalities as M |
|
|
| |
| good_py = "```python\ndef add(a,b):\n return a+b\nassert add(2,3)==5\n```" |
| bad_py = "```python\ndef add(a,b)\n return a+b\n```" |
| if V.verify_python(good_py) != 1.0: |
| fail("verify_python good != 1.0") |
| if V.verify_python(bad_py) != 0.0: |
| fail("verify_python bad != 0.0") |
| ok("verify_python: good=1.0, bad=0.0") |
|
|
| |
| good_svg = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><circle cx="5" cy="5" r="4"/></svg>' |
| if V.verify_svg(good_svg) != 1.0: |
| fail("verify_svg good != 1.0") |
| if V.verify_svg("not an svg") != 0.0: |
| fail("verify_svg junk != 0.0") |
| ok("verify_svg: valid=1.0, junk=0.0") |
|
|
| |
| |
| import os |
| import shutil |
| if os.name == "posix" and shutil.which("bash"): |
| if V.verify_bash("```bash\necho hi && ls\n```") != 1.0: |
| fail("verify_bash good != 1.0") |
| if V.verify_bash("```bash\nif then fi done\n```") != 0.0: |
| fail("verify_bash bad != 0.0") |
| ok("verify_bash: good=1.0, bad=0.0") |
| else: |
| ok("verify_bash skipped on non-posix (verified on the Linux Job)") |
|
|
| |
| try: |
| import trimesh |
| good_3d = "```python\nimport trimesh\nmesh = trimesh.creation.box(extents=(1,1,1))\n```" |
| if V.verify_3d(good_3d) != 1.0: |
| fail("verify_3d good != 1.0") |
| if V.verify_3d("```python\nmesh = 5\n```") != 0.0: |
| fail("verify_3d bad != 0.0") |
| ok("verify_3d: valid mesh=1.0, non-mesh=0.0") |
| except ImportError: |
| ok("verify_3d skipped locally (trimesh not installed; present on the Job)") |
|
|
| |
| r1 = M.blended_reward("python", judge_score=0.5, response_text=good_py) |
| if abs(r1 - 0.8) > 1e-6: |
| fail(f"blended_reward python wrong: {r1}") |
| r2 = M.blended_reward("image_prompt", judge_score=0.5, response_text="any") |
| if r2 != 0.5: |
| fail(f"blended_reward non-verifier should pass judge through: {r2}") |
| ok("blended_reward: verifier-blended + judge-passthrough correct") |
|
|
| print("INTEGRATION checks passed.\n") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|