The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Make comfyui handle missing workflow media properly. (#16079)
comfyanonymousd9726bb09880
diff --git a/app/frontend_management.py b/app/frontend_management.pyindex 8e84e8dd9..2671759dd 100644--- a/app/frontend_management.py+++ b/app/frontend_management.py@@ -277,15 +277,17 @@ comfyui-workflow-templates is not installed.return Noneasset_map: Dict[str, str] = {}- try:- for entry in template_entries:- for asset in entry.assets:+ for entry in template_entries:+ for asset in entry.assets:+ try:asset_map[asset.filename] = get_asset_path(entry.template_id, asset.filename)- except Exception as exc:- logging.error(f"Failed to resolve template asset paths: {exc}")- return None+ except FileNotFoundError:+ continue+ except Exception as exc:+ logging.error(f"Failed to resolve template asset paths: {exc}")+ return Noneif not asset_map:logging.error("No workflow template assets found. Did the packages install correctly?")diff --git a/tests-unit/app_test/frontend_manager_test.py b/tests-unit/app_test/frontend_manager_test.pyindex 8c8a2eb48..45f065488 100644--- a/tests-unit/app_test/frontend_manager_test.py+++ b/tests-unit/app_test/frontend_manager_test.py@@ -1,7 +1,9 @@import argparse+from types import SimpleNamespace+from unittest.mock import patch, mock_open+import pytestfrom requests.exceptions import HTTPError-from unittest.mock import patch, mock_openfrom app.frontend_management import (FrontendManager,@@ -287,3 +289,34 @@ def test_get_installed_templates_version_not_installed():# Assertassert version is None+++def test_template_asset_map_skips_missing_assets():+ template_entries = [+ SimpleNamespace(+ template_id="example",+ assets=[+ SimpleNamespace(filename="example.json"),+ SimpleNamespace(filename="preview.webp"),+ ],+ )+ ]++ def get_asset_path(template_id, filename):+ if filename == "preview.webp":+ raise FileNotFoundError+ return f"/templates/{filename}"++ with (+ patch(+ "comfyui_workflow_templates.iter_templates",+ return_value=template_entries,+ ),+ patch(+ "comfyui_workflow_templates.get_asset_path",+ side_effect=get_asset_path,+ ),+ ):+ asset_map = FrontendManager.template_asset_map()++ assert asset_map == {"example.json": "/templates/example.json"}