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(nodes): stop default_factory warning on startup (#10160)
Alexander Eichhorn40671cec8f31
diff --git a/invokeai/app/invocations/loops.py b/invokeai/app/invocations/loops.pyindex 18c67a85fb..1c36ee4946 100644--- a/invokeai/app/invocations/loops.py+++ b/invokeai/app/invocations/loops.py@@ -86,7 +86,7 @@ class StateMergeInvocation(BaseInvocation):state: Optional[LoopState] = InputField(default=None, description="The loop state to update")values: dict[str, Any] = InputField(- default_factory=dict,+ default={},description="The values to merge into the loop state. Connect an output to this input.",ui_type=UIType.Any,)diff --git a/tests/app/invocations/test_node_discovery.py b/tests/app/invocations/test_node_discovery.pyindex a5bd007954..fd7ee05a4b 100644--- a/tests/app/invocations/test_node_discovery.py+++ b/tests/app/invocations/test_node_discovery.py@@ -1,4 +1,4 @@-"""Every node module on disk must actually have been imported, and importing them all must stay cheap.+"""Every node module on disk must actually have been imported, and importing them all must stay cheap and quiet.The walker itself is exercised against a synthetic tree in`tests/backend/util/test_module_discovery.py`. What is left to check here is that this package's@@ -32,8 +32,24 @@ def test_every_node_module_on_disk_was_imported() -> None:assert on_disk - set(LEGACY_MODULE_MAP) == set(load_all_modules()), "walker and filesystem disagree"[email protected](scope="module")+def fresh_load() -> subprocess.CompletedProcess[str]:+ """Load every node module in a fresh interpreter, once for all tests here: a cold start costs about ten seconds."""+ program = (+ "import sys\n"+ "from invokeai.app.invocations import load_all_modules\n"+ "load_all_modules()\n"+ "loaded = sorted(m for m in sys.modules if m.startswith('transformers.models.qwen3_5'))\n"+ "assert not loaded, loaded\n"+ "print('OK')\n"+ )+ return subprocess.run([sys.executable, "-c", program], capture_output=True, text=True, timeout=300)++@pytest.mark.platform_independent-def test_loading_every_node_module_leaves_transformers_qwen3_5_unloaded() -> None:+def test_loading_every_node_module_leaves_transformers_qwen3_5_unloaded(+ fresh_load: subprocess.CompletedProcess[str],+) -> None:"""Every app start loads every node module, so their module-level imports run at boot.transformers' Qwen3.5 modeling costs about 0.25 s there, and it imports the `causal_conv1d` and `fla` kernels@@ -42,14 +58,16 @@ def test_loading_every_node_module_leaves_transformers_qwen3_5_unloaded() -> Nondiffusers' FLUX.3 prompt-upsampler module loads it, which is why FLUX.3's layout code ports the box helpers itneeds. A fresh interpreter, because this one has imported far more."""- program = (- "import sys\n"- "from invokeai.app.invocations import load_all_modules\n"- "load_all_modules()\n"- "loaded = sorted(m for m in sys.modules if m.startswith('transformers.models.qwen3_5'))\n"- "assert not loaded, loaded\n"- "print('OK')\n"- )- result = subprocess.run([sys.executable, "-c", program], capture_output=True, text=True, timeout=300)- assert result.returncode == 0, f"stderr:\n{result.stderr[-3000:]}"- assert "OK" in result.stdout+ assert fresh_load.returncode == 0, f"stderr:\n{fresh_load.stderr[-3000:]}"+ assert "OK" in fresh_load.stdout++[email protected]_independent+def test_loading_every_node_module_logs_no_default_factory_warning(+ fresh_load: subprocess.CompletedProcess[str],+) -> None:+ """`InputField` warns about `default_factory` while the class body runs, so a core node passing one warns at every+ app start. Only the log shows it: `InputField` turns the factory into a plain default, so the node's field and+ schema come out the same. A fresh interpreter, because this one has imported the node modules already.+ """+ assert '"default_factory" is not supported' not in fresh_load.stderrdiff --git a/tests/app/services/session_processor/test_for_loop_processor.py b/tests/app/services/session_processor/test_for_loop_processor.pyindex f64a0f0579..3496300e23 100644--- a/tests/app/services/session_processor/test_for_loop_processor.py+++ b/tests/app/services/session_processor/test_for_loop_processor.py@@ -51,7 +51,7 @@ class ForProcessorAfterOutput(BaseInvocationOutput):@invocation("test_for_processor_after", version="1.0.0")class ForProcessorAfterInvocation(BaseInvocation):- values: list[Any] = InputField(default_factory=list, description="The completed loop values")+ values: list[Any] = InputField(default=[], description="The completed loop values")def invoke(self, context: InvocationContext) -> ForProcessorAfterOutput:return ForProcessorAfterOutput(values=self.values)diff --git a/tests/app/services/session_processor/test_for_loop_processor_sqlite.py b/tests/app/services/session_processor/test_for_loop_processor_sqlite.pyindex 5fcbf3c9fb..09d91120e5 100644--- a/tests/app/services/session_processor/test_for_loop_processor_sqlite.py+++ b/tests/app/services/session_processor/test_for_loop_processor_sqlite.py@@ -77,7 +77,7 @@ class ForSqliteAfterOutput(BaseInvocationOutput):@invocation("test_for_sqlite_after", version="1.0.0")class ForSqliteAfterInvocation(BaseInvocation):- collection: list[Any] = InputField(default_factory=list, description="The completed loop collection")+ collection: list[Any] = InputField(default=[], description="The completed loop collection")def invoke(self, context: InvocationContext) -> ForSqliteAfterOutput:return ForSqliteAfterOutput(collection=self.collection)diff --git a/tests/app/services/test_for_loop_session_runner.py b/tests/app/services/test_for_loop_session_runner.pyindex fb88ee27f8..06bd61ef3f 100644--- a/tests/app/services/test_for_loop_session_runner.py+++ b/tests/app/services/test_for_loop_session_runner.py@@ -60,7 +60,7 @@ class ForRunnerCollectionOutput(BaseInvocationOutput):@invocation("test_for_runner_collection", version="1.0.0")class ForRunnerCollectionInvocation(BaseInvocation):- collection: list[Any] = InputField(default_factory=list, description="The completed loop collection")+ collection: list[Any] = InputField(default=[], description="The completed loop collection")def invoke(self, context: InvocationContext) -> ForRunnerCollectionOutput:return ForRunnerCollectionOutput(collection=self.collection)