Download code/run_all.py from PureOne/elysian-noctilucent-algebra: direct link, hf CLI and curl.
- Browser
- Download file 7 kB
-
https://huggingface.co/datasets/PureOne/elysian-noctilucent-algebra/resolve/main/code/run_all.py
- Command line
-
hf download hf://datasets/PureOne/elysian-noctilucent-algebra/code/run_all.py
-
curl -L -o run_all.py https://huggingface.co/datasets/PureOne/elysian-noctilucent-algebra/resolve/main/code/run_all.py
7 kB
| #!/usr/bin/env python3 | |
| """Run ELYSIÆN verification in a clean directory without altering bundled records. | |
| This orchestrator measures verification duration only. Its elapsed seconds are | |
| not rendering benchmarks or evidence of optical latency/energy advantage. | |
| No package or Python runtime is installed automatically. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| from datetime import datetime, timezone | |
| import hashlib | |
| from importlib import metadata | |
| import json | |
| import os | |
| from pathlib import Path | |
| import platform | |
| import shutil | |
| import subprocess | |
| import sys | |
| import time | |
| ROOT = Path(__file__).resolve().parent | |
| SUITES = ( | |
| "v4_engine.py", "v4_compiled_capsule.py", "v4_passive_verify.py", | |
| "v4_error_verify.py", "v4_capsule_certificate_verify.py", | |
| "v4_history_verify.py", "v5_physical_verify.py", | |
| "v5_compression_verify.py", "v5_dynamic_verify.py", | |
| ) | |
| def digest(path: Path) -> str: | |
| return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def quick_arguments(script: str) -> list[str]: | |
| if script in {"v4_engine.py", "v4_compiled_capsule.py"}: | |
| return ["--quick"] | |
| if script == "v4_history_verify.py": | |
| return ["--sequences", "6", "--steps", "20"] | |
| if script.startswith("v5_"): | |
| # The standalone v5 executables expose the same smoke-run switch. | |
| return ["--quick"] | |
| # The three earlier fixed-size suites are already small and are run fully. | |
| return [] | |
| def main() -> int: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--quick", action="store_true", | |
| help="Use smaller supported cases; this is not the full recorded run") | |
| parser.add_argument("--output-dir", type=Path, | |
| help="Empty destination for copied scripts, logs and generated results") | |
| parser.add_argument("--suites", nargs="+", choices=SUITES, | |
| help="Run selected standalone scripts; default runs all nine") | |
| parser.add_argument("--list", action="store_true", help="List suites and exit") | |
| parser.add_argument("--timeout", type=float, default=180.0, | |
| help="Per-suite execution timeout in seconds (default: 180)") | |
| args = parser.parse_args() | |
| if args.list: | |
| print("\n".join(SUITES)) | |
| return 0 | |
| if sys.version_info < (3, 10): | |
| parser.error("Python 3.10 or later is required; select an installed compatible runtime") | |
| if args.timeout <= 0: | |
| parser.error("--timeout must be positive") | |
| versions = {} | |
| missing = [] | |
| for package in ("numpy", "scipy", "matplotlib", "threadpoolctl"): | |
| try: | |
| versions[package] = metadata.version(package) | |
| except metadata.PackageNotFoundError: | |
| missing.append(package) | |
| if missing: | |
| print("Missing dependencies: " + ", ".join(missing), file=sys.stderr) | |
| print("Install the supplied requirements explicitly, then run again:", file=sys.stderr) | |
| print(f'"{sys.executable}" -m pip install -r "{ROOT / "requirements.txt"}"', file=sys.stderr) | |
| return 2 | |
| chosen = tuple(args.suites or SUITES) | |
| absent = [name for name in chosen if not (ROOT / name).is_file()] | |
| if absent: | |
| print("Missing bundled scripts: " + ", ".join(absent), file=sys.stderr) | |
| return 2 | |
| stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S%fZ") | |
| dest = (args.output_dir or ROOT / "verification_runs" / stamp).resolve() | |
| if dest.exists() and (not dest.is_dir() or any(dest.iterdir())): | |
| print(f"Refusing to overwrite a nonempty run directory: {dest}", file=sys.stderr) | |
| return 2 | |
| dest.mkdir(parents=True, exist_ok=True) | |
| for name in chosen: | |
| shutil.copy2(ROOT / name, dest / name) | |
| env = os.environ.copy() | |
| for key in ("OPENBLAS_NUM_THREADS", "OMP_NUM_THREADS", "MKL_NUM_THREADS"): | |
| env[key] = "1" | |
| env["MPLBACKEND"] = "Agg" | |
| env["PYTHONUTF8"] = "1" | |
| report = { | |
| "project": "ELYSIAEN standalone reproducibility run", | |
| "mode": "quick smoke" if args.quick else "full", | |
| "started_at_utc": datetime.now(timezone.utc).isoformat(), | |
| "python": platform.python_version(), "python_executable": sys.executable, | |
| "platform": platform.platform(), "dependency_versions": versions, | |
| "working_directory": str(dest), "scripts_copied_without_project_modules": True, | |
| "scope": "CPU verification only; ordinary floating-point assertions. Elapsed time is not a rendering or optical benchmark.", | |
| "runs": [], | |
| } | |
| summary = dest / "verification_summary.json" | |
| print(f"Running {'quick' if args.quick else 'full'} verification in {dest}", flush=True) | |
| failed = False | |
| for name in chosen: | |
| command = [sys.executable, name] + (quick_arguments(name) if args.quick else []) | |
| before = time.perf_counter() | |
| status, code = "passed", 0 | |
| try: | |
| result = subprocess.run(command, cwd=dest, env=env, capture_output=True, | |
| text=True, encoding="utf-8", errors="replace", timeout=args.timeout, check=False) | |
| stdout, stderr, code = result.stdout, result.stderr, result.returncode | |
| if code: | |
| status = "failed" | |
| except subprocess.TimeoutExpired as exc: | |
| status, code = "timeout", None | |
| stdout = exc.stdout or "" | |
| stderr = exc.stderr or "" | |
| if isinstance(stdout, bytes): stdout = stdout.decode("utf-8", errors="replace") | |
| if isinstance(stderr, bytes): stderr = stderr.decode("utf-8", errors="replace") | |
| stderr += f"\nPer-suite timeout exceeded: {args.timeout} seconds\n" | |
| except OSError as exc: | |
| status, code, stdout, stderr = "launch_error", None, "", str(exc) | |
| elapsed = time.perf_counter() - before | |
| (dest / f"{Path(name).stem}.stdout.log").write_text(stdout, encoding="utf-8") | |
| (dest / f"{Path(name).stem}.stderr.log").write_text(stderr, encoding="utf-8") | |
| report["runs"].append({"script": name, "script_sha256": digest(dest / name), | |
| "arguments": command[2:], "status": status, | |
| "exit_code": code, "verification_elapsed_seconds": elapsed}) | |
| failed |= status != "passed" | |
| report["status"] = "failed" if failed else "running" | |
| summary.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8") | |
| print(f"{name}: {status.upper()}", flush=True) | |
| report["status"] = "failed" if failed else "all selected suites passed" | |
| report["finished_at_utc"] = datetime.now(timezone.utc).isoformat() | |
| report["generated_files"] = [ | |
| {"path": p.name, "size_bytes": p.stat().st_size, "sha256": digest(p)} | |
| for p in sorted(dest.iterdir()) if p.is_file() and p != summary | |
| ] | |
| summary.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8") | |
| print(f"Summary: {summary}", flush=True) | |
| return 1 if failed else 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |