Download bundle/verify_runtime.py from gwd200/orena-procedure-runtime: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/gwd200/orena-procedure-runtime/resolve/main/bundle/verify_runtime.py
- Command line
-
hf download hf://gwd200/orena-procedure-runtime/bundle/verify_runtime.py
-
curl -L -o verify_runtime.py https://huggingface.co/gwd200/orena-procedure-runtime/resolve/main/bundle/verify_runtime.py
2.88 kB
| """Verify the exact Python/CUDA package surface used by the runtime.""" | |
| from __future__ import annotations | |
| import hashlib | |
| import importlib | |
| import importlib.metadata | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from typing import Any | |
| EXPECTED_PYTHON = (3, 11) | |
| EXPECTED_PACKAGES = { | |
| "av": "18.1.0", | |
| "decord": "0.6.0", | |
| "ms-swift": "4.5.2", | |
| "numpy": "2.3.5", | |
| "opencv-python-headless": "5.0.0.93", | |
| "Pillow": "10.4.0", | |
| "qwen-vl-utils": "0.0.14", | |
| "torch": "2.11.0+cu130", | |
| "transformers": "5.15.1", | |
| "vllm": "0.26.0", | |
| } | |
| IMPORT_NAMES = { | |
| "av": "av", | |
| "decord": "decord", | |
| "ms-swift": "swift", | |
| "numpy": "numpy", | |
| "opencv-python-headless": "cv2", | |
| "Pillow": "PIL", | |
| "qwen-vl-utils": "qwen_vl_utils", | |
| "torch": "torch", | |
| "transformers": "transformers", | |
| "vllm": "vllm", | |
| } | |
| def _sha256(path: Path) -> str: | |
| digest = hashlib.sha256() | |
| with path.open("rb") as handle: | |
| for block in iter(lambda: handle.read(8 * 1024 * 1024), b""): | |
| digest.update(block) | |
| return digest.hexdigest() | |
| def verify_runtime() -> dict[str, Any]: | |
| """Import every direct runtime dependency and bind native OpenCV bytes.""" | |
| if sys.version_info[:2] != EXPECTED_PYTHON: | |
| raise RuntimeError( | |
| f"Python version changed: {sys.version_info[:2]} != {EXPECTED_PYTHON}" | |
| ) | |
| versions = {name: importlib.metadata.version(name) for name in EXPECTED_PACKAGES} | |
| if versions != EXPECTED_PACKAGES: | |
| raise RuntimeError( | |
| f"direct package versions changed: {versions} != {EXPECTED_PACKAGES}" | |
| ) | |
| modules = { | |
| name: importlib.import_module(module_name) | |
| for name, module_name in IMPORT_NAMES.items() | |
| } | |
| torch = modules["torch"] | |
| if torch.version.cuda != "13.0": | |
| raise RuntimeError(f"Torch CUDA build changed: {torch.version.cuda!r}") | |
| cv2_root = ( | |
| Path(modules["opencv-python-headless"].__file__).resolve(strict=True).parent | |
| ) | |
| native_candidates = sorted(cv2_root.glob("cv2*.so")) | |
| if len(native_candidates) != 1 or not native_candidates[0].is_file(): | |
| raise RuntimeError( | |
| f"expected one OpenCV native extension, found {native_candidates}" | |
| ) | |
| native = native_candidates[0] | |
| return { | |
| "schema_version": "procedure.ep15_merged3225.runtime_verify.v1", | |
| "status": "PASS", | |
| "python": sys.version.split()[0], | |
| "packages": versions, | |
| "torch_cuda": torch.version.cuda, | |
| "opencv": { | |
| "module_root": str(cv2_root), | |
| "native_path": str(native), | |
| "native_bytes": native.stat().st_size, | |
| "native_sha256": _sha256(native), | |
| }, | |
| } | |
| def main() -> int: | |
| print(json.dumps(verify_runtime(), ensure_ascii=False, sort_keys=True)) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |