From 0b9a66f1cbdf4d981ac2c3eebbcfe83d3e59ac65 Mon Sep 17 00:00:00 2001 From: BlackVortexAI Date: Sat, 22 Aug 2026 15:02:34 +0200 Subject: [PATCH] Stub Comfy execution APIs in standalone detailer tests --- tests/fixtures/fake_comfy_execution.py | 75 ++++++++++++++++++++++++++ tests/test_detailer_loop.py | 8 ++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/fake_comfy_execution.py diff --git a/tests/fixtures/fake_comfy_execution.py b/tests/fixtures/fake_comfy_execution.py new file mode 100644 index 0000000..9072fb0 --- /dev/null +++ b/tests/fixtures/fake_comfy_execution.py @@ -0,0 +1,75 @@ +import sys +from types import ModuleType + + +class DynamicPrompt: + def __init__(self, prompt): + self.prompt = prompt + + def get_node(self, node_id): + return self.prompt[str(node_id)] + + +class ExecutionBlocker: + def __init__(self, value): + self.value = value + + +def is_link(value): + return isinstance(value, (tuple, list)) and len(value) == 2 and isinstance(value[0], str) + + +class _GraphNode: + def __init__(self, graph, node_id, class_type, inputs): + self.graph = graph + self.node_id = node_id + self.class_type = class_type + self.inputs = dict(inputs) + + def out(self, index): + return [self.node_id, index] + + def set_input(self, key, value): + self.inputs[key] = value + + def set_override_display_id(self, _node_id): + return None + + +class GraphBuilder: + def __init__(self): + self.nodes = {} + self.next_id = 1 + + def node(self, class_type, node_id=None, **inputs): + node_id = str(node_id or self.next_id) + self.next_id += 1 + node = _GraphNode(self, node_id, class_type, inputs) + self.nodes[node_id] = node + return node + + def lookup_node(self, node_id): + return self.nodes[str(node_id)] + + def finalize(self): + return { + node_id: {"class_type": node.class_type, "inputs": node.inputs} + for node_id, node in self.nodes.items() + } + + +def install(): + package = ModuleType("comfy_execution") + package.__path__ = [] + graph = ModuleType("comfy_execution.graph") + graph.DynamicPrompt = DynamicPrompt + graph_utils = ModuleType("comfy_execution.graph_utils") + graph_utils.DynamicPrompt = DynamicPrompt + graph_utils.ExecutionBlocker = ExecutionBlocker + graph_utils.GraphBuilder = GraphBuilder + graph_utils.is_link = is_link + package.graph = graph + package.graph_utils = graph_utils + sys.modules["comfy_execution"] = package + sys.modules["comfy_execution.graph"] = graph + sys.modules["comfy_execution.graph_utils"] = graph_utils diff --git a/tests/test_detailer_loop.py b/tests/test_detailer_loop.py index c4ae63e..bea2856 100644 --- a/tests/test_detailer_loop.py +++ b/tests/test_detailer_loop.py @@ -14,7 +14,13 @@ sys.path.insert(0, str(ROOT.parent)) import numpy as np # noqa: E402 import torch # noqa: E402 -from comfy_execution.graph import DynamicPrompt # noqa: E402 +try: # noqa: E402 + from comfy_execution.graph import DynamicPrompt +except ModuleNotFoundError: # CI validates the node pack without a full ComfyUI checkout. + from fixtures.fake_comfy_execution import install as install_fake_comfy_execution + + install_fake_comfy_execution() + from comfy_execution.graph import DynamicPrompt from bv_nodepack.py.nodes.bv_regional_detailer import ( # noqa: E402 BVDetectorBindingNode, BVDetectorRegistryNode,