Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
test: bound shared If branch validation work
JPPhoto567164021b6d
diff --git a/tests/test_node_graph.py b/tests/test_node_graph.pyindex 7735ffcdf8..e4793eed8e 100644--- a/tests/test_node_graph.py+++ b/tests/test_node_graph.py@@ -1188,7 +1188,7 @@ def test_graph_rejects_mixed_if_branch_types_for_collector_items():graph.add_edge(create_edge(if_node.id, "value", collector.id, "item"))-def test_graph_validation_does_not_repeat_shared_if_branch_compatibility_checks(monkeypatch: pytest.MonkeyPatch):+def test_graph_validation_bounds_shared_if_branch_validation_work(monkeypatch: pytest.MonkeyPatch):from invokeai.app.services.shared import graph as graph_facadetrue_value = StringInvocation(id="true", value="true")@@ -1218,16 +1218,27 @@ def test_graph_validation_does_not_repeat_shared_if_branch_compatibility_checks(graph = Graph(nodes=nodes, edges=edges)compatibility_calls = 0+ branch_input_lookups = 0original_are_connections_compatible = graph_facade.are_connections_compatible+ original_get_input_edges = Graph._get_input_edgesdef count_compatibility_calls(*args, **kwargs):nonlocal compatibility_callscompatibility_calls += 1return original_are_connections_compatible(*args, **kwargs)+ def count_branch_input_lookups(graph: Graph, node_id: str, field: str | None = None, **kwargs: Any):+ nonlocal branch_input_lookups+ if field in ("true_input", "false_input"):+ branch_input_lookups += 1+ return original_get_input_edges(graph, node_id, field, **kwargs)+monkeypatch.setattr(graph_facade, "are_connections_compatible", count_compatibility_calls)+ monkeypatch.setattr(Graph, "_get_input_edges", count_branch_input_lookups)graph.validate_self()+ if_node_count = sum(isinstance(node, IfInvocation) for node in nodes.values())+ assert branch_input_lookups <= len(edges) * if_node_count * 2assert compatibility_calls <= len(edges) * 2