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
fix(execution): resolve CI scheduler regressions
JPPhotob27c9c44023b
diff --git a/invokeai/app/services/shared/execution_engine/primitives.py b/invokeai/app/services/shared/execution_engine/primitives.pyindex e9134b4f63..9a979651f1 100644--- a/invokeai/app/services/shared/execution_engine/primitives.py+++ b/invokeai/app/services/shared/execution_engine/primitives.py@@ -265,7 +265,7 @@ class StreamBuffer(_InternalModel, Generic[T]):description="Node or runtime owner of this stream.",)frame: ExecutionFrame- events: tuple[StreamData[T] | StreamEnd, ...] = Field(default_factory=tuple)+ events: list[StreamData[T] | StreamEnd] = Field(default_factory=list)next_sequence: int = Field(default=0, ge=0)closed: bool = Falseend_sequence: int | None = Field(default=None, ge=0)@@ -368,7 +368,7 @@ class StreamBuffer(_InternalModel, Generic[T]):with self._lock:candidate = self._coerce_event(event, value=value, sequence=sequence)- existing = next((item for item in self.events if item.sequence == candidate.sequence), None)+ existing = self.events[candidate.sequence] if candidate.sequence < len(self.events) else Noneif existing is not None:if existing == candidate:return False@@ -379,12 +379,10 @@ class StreamBuffer(_InternalModel, Generic[T]):if candidate.sequence != self.next_sequence:raise ValueError("stream event is out of order")- new_events = (*self.events, candidate)+ self.events.append(candidate)if isinstance(candidate, StreamData):- object.__setattr__(self, "events", new_events)object.__setattr__(self, "next_sequence", self.next_sequence + 1)else:- object.__setattr__(self, "events", new_events)object.__setattr__(self, "closed", True)object.__setattr__(self, "end_sequence", candidate.sequence)return True@@ -399,6 +397,14 @@ class StreamBuffer(_InternalModel, Generic[T]):stream_end = close+ def _restore(self, event_count: int, next_sequence: int, closed: bool, end_sequence: int | None) -> None:+ """Restore the mutable stream fields after a failed execution-state transaction."""++ del self.events[event_count:]+ object.__setattr__(self, "next_sequence", next_sequence)+ object.__setattr__(self, "closed", closed)+ object.__setattr__(self, "end_sequence", end_sequence)+def __eq__(self, other: object) -> bool:if not isinstance(other, StreamBuffer):return NotImplementeddiff --git a/invokeai/app/services/shared/execution_engine/scheduler.py b/invokeai/app/services/shared/execution_engine/scheduler.pyindex 74d51c227c..e556eccfb2 100644--- a/invokeai/app/services/shared/execution_engine/scheduler.py+++ b/invokeai/app/services/shared/execution_engine/scheduler.py@@ -6,6 +6,7 @@ frame values. Graph and invocation semantics belong to adapters above it.from __future__ import annotations+import heapqfrom dataclasses import dataclassfrom typing import Any, Callable, Iterable, Mapping@@ -227,6 +228,8 @@ class ExecutionScheduler:self._claimed: set[NodeId] = set()self.indegree: dict[NodeId, int] = {}self._enqueued: set[NodeId] = set()+ self._enqueued_by_class: dict[str, int] = {}+ self._ready_heaps: dict[str, list[tuple[Any, int, NodeId]]] = {}self._arrival_order: dict[NodeId, int] = {}self._next_arrival = 0self._active_class: str | None = None@@ -261,6 +264,13 @@ class ExecutionScheduler:self._enqueued.add(node_id)self._arrival_order[node_id] = self._next_arrivalself._next_arrival += 1+ class_name = self.plan.nodes[node_id].class_name+ self._enqueued_by_class[class_name] = self._enqueued_by_class.get(class_name, 0) + 1+ heap = self._ready_heaps.setdefault(class_name, [])+ heapq.heappush(+ heap,+ (_frame_key(self.plan.nodes[node_id].frame), self._arrival_order[node_id], node_id),+ )return Truedef enqueue(self, node_id: NodeId) -> None:@@ -269,31 +279,32 @@ class ExecutionScheduler:self._enqueue_if_ready(node_id)def _next_class(self) -> str | None:- classes = {self.plan.nodes[node_id].class_name for node_id in self._enqueued}+ classes = {class_name for class_name, count in self._enqueued_by_class.items() if count}for class_name in self.ready_order:if class_name in classes:return class_namereturn min(classes) if classes else Nonedef _next_id_for_class(self, class_name: str) -> NodeId:- return min(- (node_id for node_id in self._enqueued if self.plan.nodes[node_id].class_name == class_name),- key=lambda node_id: (- _frame_key(self.plan.nodes[node_id].frame),- self._arrival_order[node_id],- ),- )+ heap = self._ready_heaps[class_name]+ while heap and heap[0][2] not in self._enqueued:+ heapq.heappop(heap)+ if not heap:+ raise RuntimeError(f"ready queue for class {class_name!r} is empty")+ return heap[0][2]def pop_next(self) -> NodeId | None:"""Remove and return the next ready node ID, or ``None`` when empty."""if not self._enqueued:return None- if self._active_class not in {self.plan.nodes[node_id].class_name for node_id in self._enqueued}:+ if self._enqueued_by_class.get(self._active_class or "", 0) == 0:self._active_class = self._next_class()assert self._active_class is not Nonenode_id = self._next_id_for_class(self._active_class)self._enqueued.remove(node_id)+ self._enqueued_by_class[self._active_class] -= 1+ heapq.heappop(self._ready_heaps[self._active_class])self._claimed.add(node_id)return node_id@@ -319,6 +330,11 @@ class ExecutionScheduler:))+ def is_ready(self, node_id: NodeId) -> bool:+ """Return whether a node is currently queued without sorting the ready set."""++ return node_id in self._enqueued+def add_node(self, node: PlanNode) -> None:"""Add a plan node without disturbing already-claimed work."""@@ -359,7 +375,10 @@ class ExecutionScheduler:if self.indegree[dependent] <= 0:raise ValueError(f"dependency underflow for node: {dependent}")- self._enqueued.discard(node_id)+ if node_id in self._enqueued:+ self._enqueued.discard(node_id)+ class_name = self.plan.nodes[node_id].class_name+ self._enqueued_by_class[class_name] -= 1self._claimed.discard(node_id)self._arrival_order.pop(node_id, None)self.discarded.add(node_id)@@ -401,7 +420,10 @@ class ExecutionScheduler:if self.indegree[dependent] <= 0:raise ValueError(f"dependency underflow for node: {dependent}")self.executed.add(node_id)- self._enqueued.discard(node_id)+ if node_id in self._enqueued:+ self._enqueued.discard(node_id)+ class_name = self.plan.nodes[node_id].class_name+ self._enqueued_by_class[class_name] -= 1self._claimed.discard(node_id)self._arrival_order.pop(node_id, None)newly_ready: list[NodeId] = []@@ -439,6 +461,8 @@ class ExecutionScheduler:}previous_arrival = self._arrival_orderself._enqueued = set()+ self._enqueued_by_class = {}+ self._ready_heaps = {}self._arrival_order = {}self._next_arrival = max(previous_arrival.values(), default=-1) + 1for node_id in self.plan.nodes:@@ -455,6 +479,10 @@ class ExecutionScheduler:arrival = self._next_arrivalself._next_arrival += 1self._arrival_order[node_id] = arrival+ class_name = self.plan.nodes[node_id].class_name+ self._enqueued_by_class[class_name] = self._enqueued_by_class.get(class_name, 0) + 1+ heap = self._ready_heaps.setdefault(class_name, [])+ heapq.heappush(heap, (_frame_key(self.plan.nodes[node_id].frame), arrival, node_id))__all__ = ["ActivationDependency", "ExecutionPlan", "ExecutionScheduler", "PlanNode", "ReadyPredicate"]diff --git a/invokeai/app/services/shared/graph.py b/invokeai/app/services/shared/graph.pyindex 34af012938..2116d6710e 100644--- a/invokeai/app/services/shared/graph.py+++ b/invokeai/app/services/shared/graph.py@@ -68,7 +68,6 @@ from invokeai.app.services.shared.execution_engine.child import (from invokeai.app.services.shared.execution_engine.primitives import (ActivationGate,ContinuationRecord,- StreamBuffer,StreamData,)from invokeai.app.services.shared.execution_engine.primitives import (@@ -290,17 +289,14 @@ class GraphExecutionState(BaseModel):execution_refs: dict[str, ExecutionReference] = Field(default_factory=dict,description="Stable frame-aware references for prepared execution nodes",- exclude=True,)execution_tokens: dict[str, ExecutionToken] = Field(default_factory=dict,description="Data tokens produced by prepared execution output ports",- exclude=True,)execution_effects: dict[str, list[Any]] = Field(default_factory=dict,description="Effects accepted for each execution reference",- exclude=True,)# Ready queues grouped by node class name (internal only)_ready_queues: dict[str, Deque[str]] = PrivateAttr(default_factory=dict)@@ -525,6 +521,7 @@ class GraphExecutionState(BaseModel):def _mark_source_executed(self, source_node_id: str) -> None:self._tx_add_set(self.executed, source_node_id)+ self._completed_source_ids_cache = Noneself._tx_add_set(self._get_completed_source_ids_cache(), source_node_id)if source_node_id not in self.executed_history:self._tx_append_list(self.executed_history, source_node_id)@@ -1378,8 +1375,13 @@ class GraphExecutionState(BaseModel):self._tx_record(lambda: runtime.remove_stream(stream_id))stream = runtime.get_or_create_stream(stream_id, source_node_id, self._engine_frame(parent_path))elif self._apply_transaction is not None:- previous = StreamBuffer[Any].model_validate(stream.model_dump(mode="python"))- self._tx_record_once(("stream", stream_id), lambda: runtime.replace_stream(previous))+ transaction_key = ("stream", stream_id)+ if not self._apply_transaction.is_recorded(transaction_key):+ snapshot = (len(stream.events), stream.next_sequence, stream.closed, stream.end_sequence)+ self._tx_record_once(+ transaction_key,+ lambda stream=stream, snapshot=snapshot: stream._restore(*snapshot),+ )skip_data = Falseif prefer_existing:existing = next((event for event in stream.events if event.sequence == output.index), None)@@ -1410,8 +1412,13 @@ class GraphExecutionState(BaseModel):elif stream.closed:returnelif self._apply_transaction is not None:- previous = StreamBuffer[Any].model_validate(stream.model_dump(mode="python"))- self._tx_record_once(("stream", stream_id), lambda: runtime.replace_stream(previous))+ transaction_key = ("stream", stream_id)+ if not self._apply_transaction.is_recorded(transaction_key):+ snapshot = (len(stream.events), stream.next_sequence, stream.closed, stream.end_sequence)+ self._tx_record_once(+ transaction_key,+ lambda stream=stream, snapshot=snapshot: stream._restore(*snapshot),+ )stream.close(sequence=stream.next_sequence)def _record_effect_streams(self, execution_ref: ExecutionReference, effects: Iterable[Any]) -> None:@@ -1449,11 +1456,13 @@ class GraphExecutionState(BaseModel):self._tx_record(lambda runtime=runtime, stream_id=stream_id: runtime.remove_stream(stream_id))stream = runtime.get_or_create_stream(stream_id, stream_owner_id, stream_frame)elif self._apply_transaction is not None:- previous = StreamBuffer[Any].model_validate(stream.model_dump(mode="python"))- self._tx_record_once(- ("stream", stream_id),- lambda runtime=runtime, previous=previous: runtime.replace_stream(previous),- )+ transaction_key = ("stream", stream_id)+ if not self._apply_transaction.is_recorded(transaction_key):+ snapshot = (len(stream.events), stream.next_sequence, stream.closed, stream.end_sequence)+ self._tx_record_once(+ transaction_key,+ lambda stream=stream, snapshot=snapshot: stream._restore(*snapshot),+ )sequence = self._value_from_object(token, "sequence")if sequence is None:@@ -2818,8 +2827,10 @@ class GraphExecutionState(BaseModel):def _attach_direct_execution_edges(self, exec_node_id: str, edges: Iterable[Edge]) -> list[Edge]:return _attach_direct_execution_edges(self, exec_node_id, edges)- def _initialize_direct_execution_node(self, exec_node_id: str, input_edges: Iterable[Edge]) -> None:- _initialize_direct_execution_node(self, exec_node_id, input_edges)+ def _initialize_direct_execution_node(+ self, exec_node_id: str, input_edges: Iterable[Edge], *, project: bool = True+ ) -> None:+ _initialize_direct_execution_node(self, exec_node_id, input_edges, project=project)def _mark_direct_source_empty(self, source_node_id: str) -> None:_mark_direct_source_empty(self, source_node_id)@@ -3408,7 +3419,7 @@ class GraphExecutionState(BaseModel):return self._materializer().create_execution_node(node_id, iteration_node_map, enforce_admission=False)def _iterator_graph(self, base: Optional["nx.DiGraph"] = None) -> "nx.DiGraph":- if isinstance(self._scheduler(), _GenericGraphSchedulerAdapter) and self._can_use_generic_for_scheduler():+ if self._can_use_generic_for_scheduler():return self._for_planner().iterator_graph(base)return self._materializer().iterator_graph(base)diff --git a/invokeai/app/services/shared/graph_for_planner.py b/invokeai/app/services/shared/graph_for_planner.pyindex ed6f0a9ad5..b4268c9875 100644--- a/invokeai/app/services/shared/graph_for_planner.py+++ b/invokeai/app/services/shared/graph_for_planner.py@@ -7,12 +7,12 @@ construction mechanics with the compatibility planner.from typing import TYPE_CHECKING, Any, Optional-import networkx as nx-from invokeai.app.invocations.loops import LoopStatefrom invokeai.app.services.shared.graph_materializer import _ExecutionNodeBuilderif TYPE_CHECKING:+ import networkx as nx+from invokeai.app.services.shared.graph import GraphExecutionState@@ -28,7 +28,7 @@ class _GenericForPlanner:return self._builder.prepare(base_graph)- def iterator_graph(self, base: Optional[nx.DiGraph] = None) -> nx.DiGraph:+ def iterator_graph(self, base: Optional["nx.DiGraph"] = None) -> "nx.DiGraph":return self._builder.iterator_graph(base)def create_for_iteration(diff --git a/invokeai/app/services/shared/graph_if_runtime.py b/invokeai/app/services/shared/graph_if_runtime.pyindex 40785edec7..a90018611d 100644--- a/invokeai/app/services/shared/graph_if_runtime.py+++ b/invokeai/app/services/shared/graph_if_runtime.py@@ -6,6 +6,7 @@ from invokeai.app.invocations.logic import IfInvocationfrom invokeai.app.services.shared.execution_engine.primitives import ActivationGatefrom invokeai.app.services.shared.execution_engine.scheduler import ActivationDependencyfrom invokeai.app.services.shared.graph_models import ExecutionToken+from invokeai.app.services.shared.graph_validation import IterateInvocationif TYPE_CHECKING:from invokeai.app.services.shared.graph import GraphExecutionState@@ -53,7 +54,7 @@ def _is_source_inactive(for exec_node_id in state._prepared_registry().get_prepared_ids(dependency.owner_id)}if not frames:- return False+ return all(_is_empty_if_condition(state, dependency) for dependency in dependencies)return all(state._get_source_activation_dependencies(source_node_id, frame)and any(@@ -64,6 +65,23 @@ def _is_source_inactive()+def _is_empty_if_condition(state: "GraphExecutionState", dependency: ActivationDependency) -> bool:+ """Recognize a branch whose If never materialized because its Iterate was empty."""++ owner = state.graph.nodes.get(dependency.owner_id)+ if not isinstance(owner, IfInvocation):+ return False+ condition_edges = state.graph._get_input_edges(dependency.owner_id, "condition")+ if len(condition_edges) != 1:+ return False+ condition_source_id = condition_edges[0].source.node_id+ return (+ isinstance(state.graph.get_node(condition_source_id), IterateInvocation)+ and condition_source_id in state.executed+ and not state.source_prepared_mapping.get(condition_source_id)+ )++def _activation_gate(state: "GraphExecutionState", exec_node_id: str) -> ActivationGate:return state._generic_runtime().register_gate(gate_id=exec_node_id,diff --git a/invokeai/app/services/shared/graph_iterate_planner.py b/invokeai/app/services/shared/graph_iterate_planner.pyindex 857273ce7d..2bfe4804f5 100644--- a/invokeai/app/services/shared/graph_iterate_planner.py+++ b/invokeai/app/services/shared/graph_iterate_planner.py@@ -301,7 +301,7 @@ def _attach_direct_execution_edges(def _initialize_direct_execution_node(- state: "GraphExecutionState", exec_node_id: str, input_edges: Iterable[Edge]+ state: "GraphExecutionState", exec_node_id: str, input_edges: Iterable[Edge], *, project: bool = True) -> None:input_edges = list(input_edges)state._tx_set_mapping(@@ -311,8 +311,12 @@ def _initialize_direct_execution_node()scheduler = state._scheduler()assert state._is_generic_graph_scheduler(scheduler)- scheduler.register_node(exec_node_id)- state._enqueue_if_ready(exec_node_id)+ scheduler.register_node(exec_node_id, project=project)+ if state.indegree[exec_node_id] == 0 and exec_node_id not in state.executed:+ if project:+ state._enqueue_if_ready(exec_node_id)+ else:+ scheduler._scheduler.enqueue(exec_node_id)def _mark_direct_source_empty(state: "GraphExecutionState", source_node_id: str) -> None:@@ -548,7 +552,7 @@ def _prepare_direct_iterate_collect_unchecked(state: "GraphExecutionState") -> N)]attached_iterator_edges = state._attach_direct_execution_edges(iterator_node.id, iterator_edges)- state._initialize_direct_execution_node(iterator_node.id, attached_iterator_edges)+ state._initialize_direct_execution_node(iterator_node.id, attached_iterator_edges, project=False)iterator_exec_ids.append(iterator_node.id)body_node = state._create_direct_execution_node_copy(body_id, iteration_path=(index,))@@ -559,7 +563,7 @@ def _prepare_direct_iterate_collect_unchecked(state: "GraphExecutionState") -> N)]attached_body_edges = state._attach_direct_execution_edges(body_node.id, body_edges)- state._initialize_direct_execution_node(body_node.id, attached_body_edges)+ state._initialize_direct_execution_node(body_node.id, attached_body_edges, project=False)body_exec_ids.append(body_node.id)if not iterator_exec_ids:@@ -575,7 +579,7 @@ def _prepare_direct_iterate_collect_unchecked(state: "GraphExecutionState") -> Nfor body_exec_id in body_exec_ids]attached_collector_edges = state._attach_direct_execution_edges(collector_node.id, collector_edges)- state._initialize_direct_execution_node(collector_node.id, attached_collector_edges)+ state._initialize_direct_execution_node(collector_node.id, attached_collector_edges, project=False)for downstream_id in downstream_ids:downstream_node = state._create_direct_execution_node_copy(downstream_id)@@ -589,4 +593,6 @@ def _prepare_direct_iterate_collect_unchecked(state: "GraphExecutionState") -> N)],)- state._initialize_direct_execution_node(downstream_node.id, attached_downstream_edges)+ state._initialize_direct_execution_node(downstream_node.id, attached_downstream_edges, project=False)++ state._scheduler()._project_ready_nodes()diff --git a/invokeai/app/services/shared/graph_runtime_records.py b/invokeai/app/services/shared/graph_runtime_records.pyindex e7bd075d5f..db5f19b044 100644--- a/invokeai/app/services/shared/graph_runtime_records.py+++ b/invokeai/app/services/shared/graph_runtime_records.py@@ -21,6 +21,9 @@ class _ApplyTransaction:self._recorded.add(key)self._undo.append(undo)+ def is_recorded(self, key: tuple[Any, ...]) -> bool:+ return key in self._recorded+def record(self, undo: Callable[[], None]) -> None:self._undo.append(undo)diff --git a/invokeai/app/services/shared/graph_scheduler.py b/invokeai/app/services/shared/graph_scheduler.pyindex 172ff7b1d7..39cdd0a95e 100644--- a/invokeai/app/services/shared/graph_scheduler.py+++ b/invokeai/app/services/shared/graph_scheduler.py@@ -476,7 +476,7 @@ class _GenericGraphSchedulerAdapter:for exec_node_id in nx.topological_sort(execution_graph):self.register_node(exec_node_id)- def register_node(self, exec_node_id: str) -> None:+ def register_node(self, exec_node_id: str, *, project: bool = True) -> None:if exec_node_id in self._scheduler.plan.nodes:returnnode = self._state.execution_graph.nodes.get(exec_node_id)@@ -502,7 +502,7 @@ class _GenericGraphSchedulerAdapter:)self._state._tx_set_mapping(self._state.indegree, exec_node_id, self._scheduler.indegree[exec_node_id])self._discard_rejected_node(exec_node_id)- if not self._initializing:+ if not self._initializing and project:self._project_ready_node(exec_node_id)def _sync_indegree(self) -> None:@@ -510,7 +510,7 @@ class _GenericGraphSchedulerAdapter:self._state._tx_set_mapping(self._state.indegree, exec_node_id, degree)def _project_ready_node(self, exec_node_id: str) -> None:- if exec_node_id not in self._scheduler.ready_ids or exec_node_id in self._state._ready_node_ids:+ if not self._scheduler.is_ready(exec_node_id) or exec_node_id in self._state._ready_node_ids:returnnode = self._state.execution_graph.nodes[exec_node_id]cls_name = self._state._type_key(node)@@ -519,17 +519,14 @@ class _GenericGraphSchedulerAdapter:queue = deque()self._state._tx_set_mapping(self._state._ready_queues, cls_name, queue)iteration_path = self._state._get_iteration_path(exec_node_id)- insert_at = next(- (+ if not queue or self._state._get_iteration_path(queue[-1]) <= iteration_path:+ self._state._tx_queue_append(queue, exec_node_id)+ else:+ insert_at = next(indexfor index, queued_id in enumerate(queue)if self._state._get_iteration_path(queued_id) > iteration_path- ),- len(queue),- )- if insert_at == len(queue):- self._state._tx_queue_append(queue, exec_node_id)- else:+ )self._state._tx_queue_insert(queue, insert_at, exec_node_id)self._state._set_prepared_exec_state(exec_node_id, "ready")self._state._tx_add_set(self._state._ready_node_ids, exec_node_id)diff --git a/tests/app/services/session_processor/test_for_loop_processor.py b/tests/app/services/session_processor/test_for_loop_processor.pyindex 9a389ebba7..9db343c1ae 100644--- a/tests/app/services/session_processor/test_for_loop_processor.py+++ b/tests/app/services/session_processor/test_for_loop_processor.py@@ -10,6 +10,7 @@ from invokeai.app.invocations.baseinvocation import BaseInvocation, BaseInvocatifrom invokeai.app.invocations.fields import InputField, OutputFieldfrom invokeai.app.invocations.loops import ForInvocation, ForReturnInvocationfrom invokeai.app.services.events.events_common import QueueItemStatusChangedEvent+from invokeai.app.services.invocation_cache.invocation_cache_memory import MemoryInvocationCachefrom invokeai.app.services.progress_previews.progress_previews_default import MemoryProgressPreviewsfrom invokeai.app.services.session_processor.session_processor_default import (DefaultSessionProcessor,@@ -21,6 +22,7 @@ from invokeai.app.services.session_queue.session_queue_common import (SessionQueueItemNotFoundError,SessionQueueStatus,)+from invokeai.app.services.shared.execution_effects import ExecutionEffectsRecorder, ExecutionInterfacefrom invokeai.app.services.shared.graph import Graph, GraphExecutionStatefrom invokeai.app.services.shared.invocation_context import InvocationContextfrom tests.test_nodes import create_edge, create_loop_linkage@@ -238,7 +240,16 @@ def _build_processor() -> DefaultSessionProcessor:monkeypatch.setattr("invokeai.app.services.session_processor.session_processor_default.build_invocation_context",- lambda data, services, is_canceled: None,+ lambda data, services, is_canceled: (+ effects := ExecutionEffectsRecorder(+ source_node_id=data.invocation.id,+ frame_path=data.execution_frame,+ state_id=data.execution_state_id,+ frame_id=data.execution_frame_id,+ workflow_call_depth=data.execution_workflow_call_depth,+ )+ )+ and SimpleNamespace(execution_effects=effects, execution=ExecutionInterface(effects)),)config = SimpleNamespace(generation_devices=[],@@ -254,6 +265,7 @@ def _build_processor(performance_statistics=_Stats(),progress_previews=MemoryProgressPreviews(),session_queue=queue,+ invocation_cache=MemoryInvocationCache(max_cache_size=0),image_moves=None,)runner = DefaultSessionRunner(diff --git a/tests/app/services/shared/test_execution_engine_primitives.py b/tests/app/services/shared/test_execution_engine_primitives.pyindex ed7977a917..223278f2c2 100644--- a/tests/app/services/shared/test_execution_engine_primitives.py+++ b/tests/app/services/shared/test_execution_engine_primitives.py@@ -113,7 +113,7 @@ def test_stream_buffer_rejects_data_after_close_without_mutation() -> None:with pytest.raises(ValueError, match="closed"):buffer.append_data(1)assert buffer.values == ()- assert buffer.events == (StreamEnd(sequence=0),)+ assert buffer.events == [StreamEnd(sequence=0)]def test_stream_buffer_validates_event_json_and_round_trips() -> None:diff --git a/tests/app/services/test_for_loop_session_runner.py b/tests/app/services/test_for_loop_session_runner.pyindex 85a0334fd4..8f839777f8 100644--- a/tests/app/services/test_for_loop_session_runner.py+++ b/tests/app/services/test_for_loop_session_runner.py@@ -8,8 +8,10 @@ from invokeai.app.invocations.baseinvocation import BaseInvocation, BaseInvocatifrom invokeai.app.invocations.fields import InputField, OutputFieldfrom invokeai.app.invocations.loops import ForInvocation, ForInvocationOutput, ForReturnInvocation, LoopStatefrom invokeai.app.invocations.primitives import BooleanOutput+from invokeai.app.services.invocation_cache.invocation_cache_memory import MemoryInvocationCachefrom invokeai.app.services.progress_previews.progress_previews_default import MemoryProgressPreviewsfrom invokeai.app.services.session_processor.session_processor_default import DefaultSessionRunner+from invokeai.app.services.shared.execution_effects import ExecutionEffectsRecorder, ExecutionInterfacefrom invokeai.app.services.shared.graph import CollectInvocation, Graph, GraphExecutionState, IterateInvocationfrom invokeai.app.services.shared.invocation_context import InvocationContextfrom tests.app.services.workflow_call_test_utils import (@@ -158,7 +160,16 @@ def _build_runner() -> tuple[DefaultSessionRunner, Event, _DummySessionQueue, _DummyEvents]:monkeypatch.setattr("invokeai.app.services.session_processor.session_processor_default.build_invocation_context",- lambda data, services, is_canceled: None,+ lambda data, services, is_canceled: (+ effects := ExecutionEffectsRecorder(+ source_node_id=data.invocation.id,+ frame_path=data.execution_frame,+ state_id=data.execution_state_id,+ frame_id=data.execution_frame_id,+ workflow_call_depth=data.execution_workflow_call_depth,+ )+ )+ and SimpleNamespace(execution_effects=effects, execution=ExecutionInterface(effects)),)cancel_event = Event()@@ -173,6 +184,7 @@ def _build_runner(logger=_DummyLogger(),configuration=_DummyConfig(),session_queue=session_queue,+ invocation_cache=MemoryInvocationCache(max_cache_size=0),),cancel_event=cancel_event,)diff --git a/tests/app/services/test_session_processor_callbacks.py b/tests/app/services/test_session_processor_callbacks.pyindex e5f0fd0465..22e90ab6b5 100644--- a/tests/app/services/test_session_processor_callbacks.py+++ b/tests/app/services/test_session_processor_callbacks.py@@ -5,6 +5,7 @@ from unittest.mock import Mockimport pytest+from invokeai.app.services.invocation_cache.invocation_cache_memory import MemoryInvocationCachefrom invokeai.app.services.progress_previews.progress_previews_default import MemoryProgressPreviewsfrom invokeai.app.services.session_processor.session_processor_default import DefaultSessionRunnerfrom invokeai.app.services.shared.execution_effects import ExecutionEffectsRecorder@@ -29,6 +30,7 @@ def test_after_run_node_callback_receives_control_node_inputs(monkeypatch: pytesevents=Mock(),logger=Mock(),performance_statistics=Mock(),+ invocation_cache=MemoryInvocationCache(max_cache_size=0),)services.performance_statistics.collect_stats.return_value = nullcontext()monkeypatch.setattr(diff --git a/tests/app/services/workflow_call_test_utils.py b/tests/app/services/workflow_call_test_utils.pyindex aee545ba66..f78a6d52b2 100644--- a/tests/app/services/workflow_call_test_utils.py+++ b/tests/app/services/workflow_call_test_utils.py@@ -33,6 +33,22 @@ from tests.dangerously_run_function_in_subprocess import dangerously_run_functiofrom tests.test_nodes import create_edge+def _test_execution_ref(node_id: str, effect_count: int | None = None) -> SimpleNamespace:+ return SimpleNamespace(+ reference_id=f"session-id:{node_id}",+ state_id="session-id",+ exec_node_id=node_id,+ source_node_id=node_id,+ frame=SimpleNamespace(+ frame_id="session-id:0:",+ state_id="session-id",+ iteration_path=(),+ workflow_call_depth=0,+ ),+ effect_count=effect_count,+ )++@invocation_output("test_interrupt_output")class InterruptTestOutput(BaseInvocationOutput):pass@@ -881,7 +897,7 @@ def _build_queue_item(invocation: BaseInvocation):@staticmethoddef get_execution_ref(node_id: str, *, effect_count: int | None = None):- return SimpleNamespace(frame=SimpleNamespace(iteration_path=()))+ return _test_execution_ref(node_id, effect_count)@staticmethoddef apply(execution_ref, output, effects=None, *, effect_count: int | None = None):@@ -1162,7 +1178,7 @@ class _WorkflowCallBoundarySession:self.completed.append((node_id, output))def get_execution_ref(self, node_id: str, *, effect_count: int | None = None):- return SimpleNamespace(frame=SimpleNamespace(iteration_path=()))+ return _test_execution_ref(node_id, effect_count)def is_waiting_on_workflow_call(self) -> bool:return self.waiting is not None@@ -1188,7 +1204,6 @@ def test_run_node_does_not_swallow_sigint_in_subprocess() -> None:import timefrom contextlib import contextmanagerfrom threading import Event- from types import SimpleNamespaceimport invokeai.app.services.session_processor.session_processor_default as session_processor_defaultfrom invokeai.app.invocations.baseinvocation import (@@ -1262,7 +1277,7 @@ def test_run_node_does_not_swallow_sigint_in_subprocess() -> None:@staticmethoddef get_execution_ref(node_id: str, *, effect_count: int | None = None):- return SimpleNamespace(frame=SimpleNamespace(iteration_path=()))+ return _test_execution_ref(node_id, effect_count)@staticmethoddef apply(execution_ref, output, effects=None, *, effect_count: int | None = None):