modelbeast/server/registry.py
2026-07-12 21:05:22 +10:00

19 lines
625 B
Python

"""Operator registry: each subfolder of server/operators with a manifest.json is an operator."""
import json
from pathlib import Path
OPERATORS_DIR = Path(__file__).resolve().parent / "operators"
def load_operators() -> dict[str, dict]:
ops = {}
for manifest_path in sorted(OPERATORS_DIR.glob("*/manifest.json")):
try:
manifest = json.loads(manifest_path.read_text())
except ValueError as e:
print(f"[registry] bad manifest {manifest_path}: {e}")
continue
manifest["dir"] = str(manifest_path.parent)
ops[manifest["id"]] = manifest
return ops