NOEON / scripts /attach_sources.py
Frankenstein-Labs's picture
NOEON: official identity (Frankenstein-Labs) + premium model card; proprietary-weights structure
67aa1dc verified
Raw History Blame Contribute Delete
2.21 kB
#!/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())