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(execution): cover frame identity and callback context
JPPhotodd8e3bb8cd11
diff --git a/tests/app/services/test_session_processor_callbacks.py b/tests/app/services/test_session_processor_callbacks.pyindex 2d7f9fd225..c402493af3 100644--- a/tests/app/services/test_session_processor_callbacks.py+++ b/tests/app/services/test_session_processor_callbacks.py@@ -18,7 +18,9 @@ def test_after_run_node_callback_receives_control_node_inputs(monkeypatch: pytessession = GraphExecutionState(graph=Graph())session.execution_graph.add_node(invocation)session._register_prepared_exec_node(invocation.id, "source")+ session._prepared_registry().set_iteration_path(invocation.id, (2,))session.indegree[invocation.id] = 0+ context_data = []services = SimpleNamespace(configuration=SimpleNamespace(node_cache_size=0),@@ -30,7 +32,7 @@ def test_after_run_node_callback_receives_control_node_inputs(monkeypatch: pytesservices.performance_statistics.collect_stats.return_value = nullcontext()monkeypatch.setattr("invokeai.app.services.session_processor.session_processor_default.build_invocation_context",- lambda data, services, is_canceled: None,+ lambda data, services, is_canceled: context_data.append(data) or None,)def on_after_run_node(invocation, queue_item, output):@@ -47,3 +49,4 @@ def test_after_run_node_callback_receives_control_node_inputs(monkeypatch: pytesassert callback_invocations == [invocation]assert callback_invocations[0] is invocationassert invocation.collection == []+ assert context_data[0].execution_frame == (2,)diff --git a/tests/test_graph_execution_state.py b/tests/test_graph_execution_state.pyindex b418000706..01722b6180 100644--- a/tests/test_graph_execution_state.py+++ b/tests/test_graph_execution_state.py@@ -519,6 +519,46 @@ def test_graph_state_apply_rejects_decomposed_frame_mismatch():assert not state.execution_tokens+ "frame_component, replacement, error_message",+ [+ ("frame_id", "other-frame", "another execution frame"),+ ("state_id", "other-state", "another graph execution state"),+ ("workflow_call_depth", 1, "another workflow-call depth"),+ ],+)+def test_graph_state_apply_rejects_effect_frame_identity_mismatch(+ frame_component: str, replacement: Any, error_message: str+):+ graph = Graph()+ graph.add_node(AddInvocation(id="add", a=1, b=2))+ state = GraphExecutionState(graph=graph)+ node = state.next()+ assert node is not None+ output = node.invoke(Mock(InvocationContext))+ ref = state.get_execution_ref(node.id, effect_count=1)+ frame = ref.frame.model_dump(mode="python")+ frame[frame_component] = replacement++ with pytest.raises(ValueError, match=error_message):+ state.apply(+ ref,+ output,+ effects=[+ {+ "kind": "emit",+ "frame": frame,+ "token": {"node_id": node.id, "field": "value", "value": 3},+ }+ ],+ )++ assert not state.executed+ assert not state.results+ assert not state.execution_tokens+ assert not state.execution_effects++def test_graph_state_apply_rejects_effect_from_another_state_before_mutation():graph = Graph()graph.add_node(AddInvocation(id="add", a=1, b=2))