# 第三轮探针：在 GPU 机上对「修复后副本」复验
import importlib.util, os, sys, traceback

ROOT = "/tmp/aicg3d-probe2"
COMFY = "/home/zyw/ComfyUI"
sys.path.insert(0, COMFY)
sys.path.insert(0, ROOT)
os.chdir(COMFY)

try:
    import h3easy.nodes as hn

    print(f"[C3] SAMPLING_PLAN_TYPE = {hn.SAMPLING_PLAN_TYPE} | SELFLIFT_KIND = {hn.SELFLIFT_KIND}", flush=True)
    print(f"     sample_with_sampling_plan 来自 = {hn.sample_with_sampling_plan.__module__}", flush=True)
    plan = hn.MiniMaxH3SamplingPlan(
        kind=hn.SELFLIFT_KIND, cfg=1.0, transition_step=5, lowres_scale=0.8,
        correction_ratio=0.0, correction_min=0.5, correction_max=1.0, upscaler_model="none",
    )
    print(f"     真实 plan 字段 = {list(vars(plan).keys())[:8]}", flush=True)
except Exception:
    traceback.print_exc()

try:
    spec = importlib.util.spec_from_file_location(
        "comfyui_AICG3D_v3", os.path.join(ROOT, "__init__.py"), submodule_search_locations=[ROOT]
    )
    m = importlib.util.module_from_spec(spec)
    sys.modules["comfyui_AICG3D_v3"] = m
    spec.loader.exec_module(m)
    ids = sorted(m.NODE_CLASS_MAPPINGS)
    print(f"[E3] 修复后注册节点数 = {len(ids)}", flush=True)
    print(f"     GH 节点 = {[i for i in ids if i.endswith('GH')] or '仍然没有'}", flush=True)
except Exception:
    traceback.print_exc()
print("第三轮探针结束", flush=True)
