Newer ComfyUI builds lock registered v3 node classes after registration (comfy_api internal __setattr__ guard), so _apply_lora writing cls._loaded_lora raised: Cannot modify class attribute '_loaded_lora' on locked class 'MoxieMultimediaLoaderClone'. The (path, sd, metadata) cache now lives at module level, which the locking mechanism does not touch. Test monkeypatch updated to match.
598 lines
20 KiB
Python
598 lines
20 KiB
Python
"""Regression tests for the consolidated Moxie node contracts.
|
|
|
|
These tests follow the self-contained stubbing pattern of
|
|
test_common_nodes.py so they run without a full ComfyUI installation.
|
|
|
|
Verified contracts:
|
|
- MoxieMultimediaLoader: outputs exactly (model, clip, video_vae, audio_vae);
|
|
no legacy FAST_MODEL_LOADER bundle output; no clip_type choice (the CLIP
|
|
recipe is locked to CLIPType.MINIMAX); the model output has the attention
|
|
backend and LoRA applied.
|
|
- MoxieProject: takes model/clip/video_vae/audio_vae as required direct
|
|
inputs instead of a bundled model_loader, and packs them into the loader
|
|
dict consumed internally by EasyMultiTrackProject.
|
|
- MoxiePreviewOverride (ModelPreviewOverrideKJ): patches the model input
|
|
directly; no model_loader pass-through slots.
|
|
"""
|
|
|
|
import enum
|
|
import importlib.util
|
|
import sys
|
|
import types
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class _Port:
|
|
def __init__(self, name=None, **kwargs):
|
|
self.name = name
|
|
self.kwargs = kwargs
|
|
|
|
|
|
class _PortType:
|
|
@staticmethod
|
|
def Input(name, **kwargs):
|
|
return _Port(name, **kwargs)
|
|
|
|
@staticmethod
|
|
def Output(name=None, **kwargs):
|
|
return _Port(name, **kwargs)
|
|
|
|
|
|
class _NodeOutput:
|
|
def __init__(self, *values):
|
|
self.values = values
|
|
|
|
|
|
class _Schema:
|
|
def __init__(self, **kwargs):
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
def _build_io():
|
|
io = types.SimpleNamespace()
|
|
io.AnyType = _PortType
|
|
io.Audio = _PortType
|
|
io.Boolean = _PortType
|
|
io.Clip = _PortType
|
|
io.Combo = _PortType
|
|
io.Float = _PortType
|
|
io.Image = _PortType
|
|
io.Int = _PortType
|
|
io.Model = _PortType
|
|
io.Sampler = _PortType
|
|
io.Sigmas = _PortType
|
|
io.String = _PortType
|
|
io.Vae = _PortType
|
|
io.Video = _PortType
|
|
io.Custom = lambda **kwargs: _PortType
|
|
io.NodeOutput = _NodeOutput
|
|
io.Schema = _Schema
|
|
io.Hidden = types.SimpleNamespace(prompt="prompt", unique_id="unique_id")
|
|
io.ControlAfterGenerate = types.SimpleNamespace(randomize="randomize")
|
|
io.InputImpl = type("InputImpl", (), {})
|
|
|
|
class _ComfyNode:
|
|
hidden = types.SimpleNamespace(unique_id="0", prompt={})
|
|
|
|
io.ComfyNode = _ComfyNode
|
|
return io
|
|
|
|
|
|
class _FakeModel:
|
|
"""Minimal model stand-in recording attention/clone/wrapper calls."""
|
|
|
|
def __init__(self, label="model"):
|
|
self.label = label
|
|
self.attention_fn = None
|
|
self.wrappers = []
|
|
|
|
def clone(self):
|
|
clone = _FakeModel(self.label + ".clone")
|
|
clone.attention_fn = self.attention_fn
|
|
return clone
|
|
|
|
def set_model_optimized_attention(self, attention_fn):
|
|
self.attention_fn = attention_fn
|
|
|
|
def add_wrapper_with_key(self, key, *args):
|
|
self.wrappers.append((key,) + tuple(args))
|
|
|
|
def get_model_object(self, name):
|
|
return name
|
|
|
|
|
|
class _FakeVAE:
|
|
def __init__(self, sd=None, metadata=None):
|
|
self.sd = sd
|
|
self.metadata = metadata
|
|
|
|
def throw_exception_if_invalid(self):
|
|
pass
|
|
|
|
|
|
class _StubState:
|
|
"""Shared recorders/sentinels for the comfy.* stubs."""
|
|
|
|
def __init__(self):
|
|
self.calls = []
|
|
self.attention_fn = lambda pixels, *a, **k: pixels
|
|
self.clip = object()
|
|
self.lora_model = None
|
|
self.lora_clip = None
|
|
|
|
|
|
def _register(state, io, monkeypatch=None):
|
|
"""Build the ComfyUI stub modules and return {name: module} to install."""
|
|
modules = {}
|
|
|
|
comfy_api = types.ModuleType("comfy_api")
|
|
comfy_api_latest = types.ModuleType("comfy_api.latest")
|
|
comfy_api_latest.io = io
|
|
comfy_api_latest.InputImpl = io.InputImpl
|
|
comfy_api.latest = comfy_api_latest
|
|
modules["comfy_api"] = comfy_api
|
|
modules["comfy_api.latest"] = comfy_api_latest
|
|
|
|
comfy = types.ModuleType("comfy")
|
|
comfy_sd = types.ModuleType("comfy.sd")
|
|
|
|
class CLIPType(enum.Enum):
|
|
STABLE_DIFFUSION = "stable_diffusion"
|
|
WAN = "wan"
|
|
LTXV = "ltxv"
|
|
MINIMAX = "minimax"
|
|
|
|
state.CLIPType = CLIPType
|
|
|
|
def load_diffusion_model(path, model_options=None):
|
|
state.calls.append(("load_diffusion_model", path))
|
|
return _FakeModel("diffusion")
|
|
|
|
def load_clip(ckpt_paths, embedding_directory=None, clip_type=None, model_options=None):
|
|
state.calls.append(("load_clip", clip_type))
|
|
return state.clip
|
|
|
|
def load_lora_for_models(model, clip, lora_sd, strength_model, strength_clip, lora_metadata=None):
|
|
state.calls.append(("load_lora_for_models", strength_model, strength_clip))
|
|
state.lora_model = model
|
|
state.lora_clip = clip
|
|
return model, clip
|
|
|
|
comfy_sd.CLIPType = CLIPType
|
|
comfy_sd.load_diffusion_model = load_diffusion_model
|
|
comfy_sd.load_clip = load_clip
|
|
comfy_sd.load_lora_for_models = load_lora_for_models
|
|
comfy_sd.VAE = _FakeVAE
|
|
modules["comfy.sd"] = comfy_sd
|
|
|
|
comfy_utils = types.ModuleType("comfy.utils")
|
|
|
|
def load_torch_file(path, safe_load=False, return_metadata=False, device=None):
|
|
state.calls.append(("load_torch_file", str(path)))
|
|
if return_metadata:
|
|
return {}, {"source": str(path)}
|
|
return {}
|
|
|
|
comfy_utils.load_torch_file = load_torch_file
|
|
comfy_utils.state_dict_prefix_replace = lambda sd, mapping, filter_keys=False: sd
|
|
comfy_utils.ProgressBar = type("ProgressBar", (), {"update_absolute": lambda *a, **k: None})
|
|
modules["comfy.utils"] = comfy_utils
|
|
|
|
comfy_ldm = types.ModuleType("comfy.ldm")
|
|
comfy_ldm_modules = types.ModuleType("comfy.ldm.modules")
|
|
comfy_attention = types.ModuleType("comfy.ldm.modules.attention")
|
|
|
|
def get_attention_function(attention_name, extra_options=None):
|
|
state.calls.append(("get_attention_function", attention_name))
|
|
return state.attention_fn
|
|
|
|
comfy_attention.get_attention_function = get_attention_function
|
|
modules["comfy.ldm"] = comfy_ldm
|
|
modules["comfy.ldm.modules"] = comfy_ldm_modules
|
|
modules["comfy.ldm.modules.attention"] = comfy_attention
|
|
|
|
comfy_samplers = types.ModuleType("comfy.samplers")
|
|
|
|
def calculate_sigmas(model_sampling, scheduler, steps):
|
|
import torch
|
|
|
|
state.calls.append(("calculate_sigmas", scheduler, steps))
|
|
return torch.linspace(1.0, 0.0, steps + 1)
|
|
|
|
comfy_samplers.calculate_sigmas = calculate_sigmas
|
|
comfy_samplers.sampler_object = lambda name: ("sampler", name)
|
|
modules["comfy.samplers"] = comfy_samplers
|
|
|
|
comfy_patcher = types.ModuleType("comfy.patcher_extension")
|
|
comfy_patcher.WrappersMP = types.SimpleNamespace(OUTER_SAMPLE="OUTER_SAMPLE")
|
|
modules["comfy.patcher_extension"] = comfy_patcher
|
|
|
|
modules["comfy.model_base"] = types.ModuleType("comfy.model_base")
|
|
modules["comfy.model_management"] = types.ModuleType("comfy.model_management")
|
|
|
|
comfy_execution = types.ModuleType("comfy_execution")
|
|
graph_utils = types.ModuleType("comfy_execution.graph_utils")
|
|
graph_utils.GraphBuilder = type("GraphBuilder", (), {})
|
|
graph_utils.ExecutionBlocker = type("ExecutionBlocker", (), {})
|
|
graph_utils.is_link = lambda value: False
|
|
modules["comfy_execution"] = comfy_execution
|
|
modules["comfy_execution.graph_utils"] = graph_utils
|
|
|
|
modules["latent_preview"] = types.ModuleType("latent_preview")
|
|
|
|
folder_paths = types.ModuleType("folder_paths")
|
|
folder_paths.models_dir = ""
|
|
folder_paths.get_folder_paths = lambda *a, **k: []
|
|
folder_paths.get_filename_list = lambda *a, **k: []
|
|
modules["folder_paths"] = folder_paths
|
|
|
|
nodes_stub = types.ModuleType("nodes")
|
|
nodes_stub.EXTENSION_WEB_DIRS = {}
|
|
modules["nodes"] = nodes_stub
|
|
|
|
# Wire the comfy package attribute chain for `import comfy.x.y` statements.
|
|
comfy.sd = comfy_sd
|
|
comfy.utils = comfy_utils
|
|
comfy.samplers = comfy_samplers
|
|
comfy.patcher_extension = comfy_patcher
|
|
comfy.model_base = modules["comfy.model_base"]
|
|
comfy.model_management = modules["comfy.model_management"]
|
|
comfy_ldm.modules = comfy_ldm_modules
|
|
comfy_ldm_modules.attention = comfy_attention
|
|
comfy.ldm = comfy_ldm
|
|
modules["comfy"] = comfy
|
|
return modules
|
|
|
|
|
|
def _load(spec_name, path):
|
|
spec = importlib.util.spec_from_file_location(spec_name, path)
|
|
assert spec is not None and spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
sys.modules[spec_name] = module
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def _build_moxie():
|
|
"""Load the real Moxie modules against the stubbed ComfyUI runtime.
|
|
|
|
Written as a plain generator (setup / yield / teardown) so it can back
|
|
the pytest fixture below and also be driven by a standalone runner in
|
|
environments where pytest's package-aware collection cannot be used.
|
|
"""
|
|
state = _StubState()
|
|
io = _build_io()
|
|
stubs = _register(state, io)
|
|
|
|
added = {}
|
|
for name, module in stubs.items():
|
|
added[name] = sys.modules.get(name)
|
|
sys.modules[name] = module
|
|
|
|
mm_pkg = types.ModuleType("MMnode")
|
|
mm_pkg.__path__ = [str(REPO)]
|
|
added["MMnode"] = sys.modules.get("MMnode")
|
|
sys.modules["MMnode"] = mm_pkg
|
|
|
|
try:
|
|
# Real utils package (torch/folder_paths only externals).
|
|
utils_spec = importlib.util.spec_from_file_location(
|
|
"MMnode.utils",
|
|
REPO / "utils" / "__init__.py",
|
|
submodule_search_locations=[str(REPO / "utils")],
|
|
)
|
|
utils_pkg = importlib.util.module_from_spec(utils_spec)
|
|
added["MMnode.utils"] = sys.modules.get("MMnode.utils")
|
|
sys.modules["MMnode.utils"] = utils_pkg
|
|
utils_spec.loader.exec_module(utils_pkg)
|
|
|
|
# nodes package without executing the full nodes/__init__ chain.
|
|
nodes_pkg = types.ModuleType("MMnode.nodes")
|
|
nodes_pkg.__path__ = [str(REPO / "nodes")]
|
|
added["MMnode.nodes"] = sys.modules.get("MMnode.nodes")
|
|
sys.modules["MMnode.nodes"] = nodes_pkg
|
|
common = _load("MMnode.nodes.common", REPO / "nodes" / "common.py")
|
|
nodes_pkg.common = common
|
|
project = _load("MMnode.nodes.project", REPO / "nodes" / "project.py")
|
|
nodes_pkg.project = project
|
|
|
|
tiny_vae = types.ModuleType("MMnode.tiny_vae")
|
|
tiny_vae.load_tiny_vae_decoder = lambda *a, **k: None
|
|
added["MMnode.tiny_vae"] = sys.modules.get("MMnode.tiny_vae")
|
|
sys.modules["MMnode.tiny_vae"] = tiny_vae
|
|
|
|
loader = _load("MMnode.moxie_loader", REPO / "moxie_loader.py")
|
|
preview = _load("MMnode.moxie_preview", REPO / "moxie_preview.py")
|
|
project_node = _load("MMnode.moxie_project", REPO / "moxie_project.py")
|
|
|
|
yield types.SimpleNamespace(
|
|
state=state,
|
|
loader=loader,
|
|
preview=preview,
|
|
project_node=project_node,
|
|
base_project=project.EasyMultiTrackProject,
|
|
)
|
|
finally:
|
|
for name, previous in added.items():
|
|
if previous is None:
|
|
sys.modules.pop(name, None)
|
|
else:
|
|
sys.modules[name] = previous
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def moxie():
|
|
yield from _build_moxie()
|
|
|
|
|
|
def _input_names(schema):
|
|
return [port.name for port in schema.inputs]
|
|
|
|
|
|
def _output_names(schema):
|
|
# V3 outputs may pass the label positionally or via display_name=.
|
|
return [port.name or port.kwargs.get("display_name") for port in schema.outputs]
|
|
|
|
|
|
def test_loader_schema_outputs_are_direct(moxie):
|
|
schema = moxie.loader.MoxieMultimediaLoader.define_schema()
|
|
|
|
assert _output_names(schema) == ["model", "clip", "video_vae", "audio_vae"]
|
|
assert "model_loader" not in _output_names(schema)
|
|
assert "model_loader" not in _input_names(schema)
|
|
|
|
|
|
def test_loader_schema_locks_h3_clip_recipe(moxie):
|
|
schema = moxie.loader.MoxieMultimediaLoader.define_schema()
|
|
inputs = _input_names(schema)
|
|
|
|
# The model set is MiniMax H3-only: no CLIP recipe choices are exposed.
|
|
assert "clip_type" not in inputs
|
|
assert "clip_device" in inputs
|
|
assert inputs.index("clip") == len(inputs) - 2 # clip, then clip_device
|
|
|
|
|
|
def test_loader_execute_applies_attention_then_lora(moxie, monkeypatch, tmp_path):
|
|
state = moxie.state
|
|
models = tmp_path / "models"
|
|
for subdir in ("diffusion", "vae", "audio_vae", "clip", "loras"):
|
|
(models / subdir).mkdir(parents=True, exist_ok=True)
|
|
for name in ("h3.safetensors", "video.safetensors", "audio.safetensors", "qwen.safetensors", "turbo.safetensors"):
|
|
subdir = {
|
|
"h3.safetensors": "diffusion",
|
|
"video.safetensors": "vae",
|
|
"audio.safetensors": "audio_vae",
|
|
"qwen.safetensors": "clip",
|
|
"turbo.safetensors": "loras",
|
|
}[name]
|
|
(models / subdir / name).write_bytes(b"stub")
|
|
monkeypatch.setattr(moxie.loader, "MODELS_DIR", models)
|
|
# LoRA cache lives at module level: node classes are locked by newer
|
|
# ComfyUI builds and class attributes can no longer be written at runtime.
|
|
monkeypatch.setattr(moxie.loader, "_loaded_lora", None)
|
|
state.calls.clear()
|
|
|
|
result = moxie.loader.MoxieMultimediaLoader.execute(
|
|
diffusion_model="h3.safetensors",
|
|
weight_dtype="default",
|
|
attention_backend="comfy_kitchen_attention",
|
|
lora_name="turbo.safetensors",
|
|
lora_strength_model=1.0,
|
|
lora_strength_clip=1.0,
|
|
video_vae="video.safetensors",
|
|
audio_vae="audio.safetensors",
|
|
clip="qwen.safetensors",
|
|
clip_device="default",
|
|
)
|
|
|
|
sequence = [call[0] for call in state.calls]
|
|
assert sequence == [
|
|
"load_diffusion_model",
|
|
"get_attention_function",
|
|
"load_clip",
|
|
"load_torch_file",
|
|
"load_lora_for_models",
|
|
"load_torch_file",
|
|
"load_torch_file",
|
|
]
|
|
|
|
# CLIP recipe is locked to MiniMax.
|
|
clip_calls = [call for call in state.calls if call[0] == "load_clip"]
|
|
assert clip_calls == [("load_clip", state.CLIPType.MINIMAX)]
|
|
|
|
# LoRA applied on top of the attention-patched model, after the CLIP load.
|
|
assert state.calls.index(("get_attention_function", "comfy_kitchen_int8")) < state.calls.index(
|
|
("load_clip", state.CLIPType.MINIMAX)
|
|
) < state.calls.index(("load_lora_for_models", 1.0, 1.0))
|
|
|
|
# Exactly four direct outputs, model carrying attention + LoRA.
|
|
assert isinstance(result, _NodeOutput)
|
|
assert len(result.values) == 4
|
|
model_out, clip_out, video_vae_out, audio_vae_out = result.values
|
|
assert model_out is state.lora_model
|
|
assert model_out.attention_fn is state.attention_fn
|
|
assert clip_out is state.clip
|
|
assert isinstance(video_vae_out, _FakeVAE)
|
|
assert isinstance(audio_vae_out, _FakeVAE)
|
|
|
|
|
|
def test_loader_execute_without_lora_skips_lora_loading(moxie, monkeypatch, tmp_path):
|
|
state = moxie.state
|
|
models = tmp_path / "models"
|
|
for subdir in ("diffusion", "vae", "audio_vae", "clip", "loras"):
|
|
(models / subdir).mkdir(parents=True, exist_ok=True)
|
|
for name in ("h3.safetensors", "video.safetensors", "audio.safetensors", "qwen.safetensors"):
|
|
subdir = {
|
|
"h3.safetensors": "diffusion",
|
|
"video.safetensors": "vae",
|
|
"audio.safetensors": "audio_vae",
|
|
"qwen.safetensors": "clip",
|
|
}[name]
|
|
(models / subdir / name).write_bytes(b"stub")
|
|
monkeypatch.setattr(moxie.loader, "MODELS_DIR", models)
|
|
state.calls.clear()
|
|
|
|
result = moxie.loader.MoxieMultimediaLoader.execute(
|
|
diffusion_model="h3.safetensors",
|
|
weight_dtype="default",
|
|
attention_backend="pytorch_attention",
|
|
lora_name="<no files found in models/loras>",
|
|
lora_strength_model=1.0,
|
|
lora_strength_clip=1.0,
|
|
video_vae="video.safetensors",
|
|
audio_vae="audio.safetensors",
|
|
clip="qwen.safetensors",
|
|
clip_device="default",
|
|
)
|
|
|
|
assert "load_lora_for_models" not in [call[0] for call in state.calls]
|
|
assert result.values[0] is not state.clip # model output remains a model
|
|
assert result.values[0].attention_fn is state.attention_fn
|
|
assert result.values[1] is state.clip
|
|
|
|
|
|
def test_loader_requires_minimax_cliptype(moxie, monkeypatch, tmp_path):
|
|
state = moxie.state
|
|
models = tmp_path / "models"
|
|
for subdir in ("diffusion", "clip"):
|
|
(models / subdir).mkdir(parents=True, exist_ok=True)
|
|
(models / "diffusion" / "h3.safetensors").write_bytes(b"stub")
|
|
(models / "clip" / "qwen.safetensors").write_bytes(b"stub")
|
|
monkeypatch.setattr(moxie.loader, "MODELS_DIR", models)
|
|
|
|
class CLIPTypeNoMinimax(enum.Enum):
|
|
STABLE_DIFFUSION = "stable_diffusion"
|
|
|
|
monkeypatch.setattr(moxie.loader.comfy.sd, "CLIPType", CLIPTypeNoMinimax)
|
|
|
|
with pytest.raises(RuntimeError, match="CLIPType.MINIMAX"):
|
|
moxie.loader.MoxieMultimediaLoader.execute(
|
|
diffusion_model="h3.safetensors",
|
|
weight_dtype="default",
|
|
attention_backend="pytorch_attention",
|
|
lora_name="<no files found in models/loras>",
|
|
lora_strength_model=1.0,
|
|
lora_strength_clip=1.0,
|
|
video_vae="video.safetensors",
|
|
audio_vae="audio.safetensors",
|
|
clip="qwen.safetensors",
|
|
clip_device="default",
|
|
)
|
|
|
|
|
|
def test_project_schema_takes_direct_model_inputs(moxie):
|
|
schema = moxie.project_node.MoxieProject.define_schema()
|
|
inputs = {port.name: port for port in schema.inputs}
|
|
|
|
assert list(inputs) == [
|
|
"tracks_info",
|
|
"model",
|
|
"clip",
|
|
"video_vae",
|
|
"audio_vae",
|
|
"project_name",
|
|
"steps",
|
|
"seed",
|
|
]
|
|
assert "model_loader" not in inputs
|
|
|
|
# The four model components are required direct connections.
|
|
for name in ("model", "clip", "video_vae", "audio_vae"):
|
|
assert inputs[name].kwargs.get("optional") is not True
|
|
|
|
|
|
def test_project_execute_builds_loader_bundle_for_base_node(moxie, monkeypatch):
|
|
captured = {}
|
|
|
|
def fake_base_execute(cls, **kwargs):
|
|
captured.update(kwargs)
|
|
return _NodeOutput("PROJECT", None)
|
|
|
|
monkeypatch.setattr(
|
|
moxie.base_project,
|
|
"execute",
|
|
classmethod(fake_base_execute),
|
|
)
|
|
|
|
model = _FakeModel("h3")
|
|
clip = object()
|
|
video_vae = object()
|
|
audio_vae = object()
|
|
|
|
moxie.project_node.MoxieProject.execute(
|
|
tracks_info=[{"width": 960, "height": 544, "frame_rate": 24, "tracks": []}],
|
|
model=[model],
|
|
clip=[clip],
|
|
video_vae=[video_vae],
|
|
audio_vae=[audio_vae],
|
|
project_name=["girl1-test"],
|
|
steps=[3],
|
|
seed=[42],
|
|
)
|
|
|
|
assert captured["model_loader"] == {
|
|
"model": model,
|
|
"clip": clip,
|
|
"vae": video_vae,
|
|
"audio_vae": audio_vae,
|
|
}
|
|
# Baked single-pass sampling settings survive the delegation.
|
|
assert captured["sampling_mode"] == "single"
|
|
assert captured["project_save"] == "override"
|
|
assert captured["sampler"] == ("sampler", "euler")
|
|
import torch
|
|
|
|
assert captured["sigmas"].shape == (4,) # steps + 1
|
|
assert captured["sigmas"].dtype == torch.float32
|
|
|
|
|
|
def test_project_execute_missing_component_raises(moxie, monkeypatch):
|
|
def fake_base_execute(cls, **kwargs): # pragma: no cover - must not be reached
|
|
raise AssertionError("base execute must not run with missing components")
|
|
|
|
monkeypatch.setattr(moxie.base_project, "execute", classmethod(fake_base_execute))
|
|
|
|
with pytest.raises(ValueError, match="MoxieProject: Missing required model components: clip"):
|
|
moxie.project_node.MoxieProject.execute(
|
|
tracks_info=[{}],
|
|
model=[_FakeModel("h3")],
|
|
clip=[None],
|
|
video_vae=[object()],
|
|
audio_vae=[object()],
|
|
project_name=["girl1-test"],
|
|
steps=[3],
|
|
seed=[42],
|
|
)
|
|
|
|
|
|
def test_preview_override_has_no_model_loader_slots(moxie):
|
|
schema = moxie.preview.ModelPreviewOverrideKJ.define_schema()
|
|
|
|
assert "model_loader" not in _input_names(schema)
|
|
assert _output_names(schema) == ["model"]
|
|
|
|
|
|
def test_preview_override_patches_model_directly(moxie):
|
|
model = _FakeModel("h3")
|
|
|
|
result = moxie.preview.ModelPreviewOverrideKJ.execute(model=model)
|
|
|
|
assert isinstance(result, _NodeOutput)
|
|
assert len(result.values) == 1
|
|
patched = result.values[0]
|
|
assert patched is not model
|
|
assert any(
|
|
wrapper[0] == "OUTER_SAMPLE" and wrapper[1] == "moxie_preview_override"
|
|
for wrapper in patched.wrappers
|
|
)
|
|
|
|
|
|
def test_preview_override_requires_model(moxie):
|
|
with pytest.raises(TypeError, match="'model' input is required"):
|
|
moxie.preview.ModelPreviewOverrideKJ.execute(model=None)
|