File size: 2,211 Bytes
419f250 67aa1dc 419f250 b871251 419f250 b871251 419f250 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #!/usr/bin/env python3
"""Check whether the real frozen sources can be attached in this environment.
Performs the resource and dependency checks *before* any large download and
prints a precise verdict. This is the gate for Phase 3: it refuses to start a
multi-gigabyte download on hardware that cannot hold it.
Usage:
python scripts/attach_sources.py # check only
python scripts/attach_sources.py --try-load # attempt to load the vision slot
"""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from noeon.core.resources import detect, report
from noeon.core.registry import SOURCE_MODELS
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("--try-load", action="store_true")
args = ap.parse_args()
env = detect()
print("environment:", json.dumps(env, indent=2))
r = report(env)
print("\nfeasibility:")
for name, v in r["requirements"].items():
mark = "OK " if v["ok"] else "NO "
print(f" [{mark}] {name}: {v['notes']}")
for reason in v["reasons"]:
print(f" - {reason}")
# dependency check
try:
import transformers # noqa: F401
print("\ntransformers: available")
except ImportError:
print("\ntransformers: MISSING (pip install transformers)")
token = __import__("os").environ.get("HF_TOKEN")
print(f"HF_TOKEN: {'present' if token else 'absent'}")
ok, reasons = None, None
from noeon.core.resources import can_run
ok, reasons = can_run("inference_fp16", env)
if not ok:
print("\nVERDICT: cannot attach the real sources here:")
for reason in reasons:
print(f" - {reason}")
print("Prepare everything; run this on a GPU host (e.g. Colab) instead.")
return 1
print("\nVERDICT: hardware looks sufficient.")
if args.try_load:
from noeon.encoders.hf_source import HFSourceEncoder
enc = HFSourceEncoder("vision", device="cuda")
enc.load()
print("loaded vision OK")
return 0
if __name__ == "__main__":
raise SystemExit(main())
|