The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Turn the assets system on by default; add --disable-assets (#16884)
Simon Pinfold1d2ea2948d33
diff --git a/app/assets/api/routes.py b/app/assets/api/routes.pyindex c7fc7022b..2d81a5625 100644--- a/app/assets/api/routes.py+++ b/app/assets/api/routes.py@@ -91,7 +91,7 @@ def _require_assets_feature_enabled(handler):return _build_error_response(503,"SERVICE_DISABLED",- "Assets system is disabled. Start the server with --enable-assets to use this feature.",+ "Assets system is disabled because the server was started with --disable-assets.",)return await handler(request)diff --git a/app/assets/manager.py b/app/assets/manager.pyindex 0cf812fcd..ed23ef690 100644--- a/app/assets/manager.py+++ b/app/assets/manager.py@@ -1,7 +1,7 @@"""Selects and implements the enabled and disabled asset managers.-``default_asset_manager`` checks database dependencies before enabling assets-and chooses ``NoAssets`` when the requested mode cannot run.+``default_asset_manager`` chooses ``NoAssets`` only for ``--disable-assets``; main.py+stops startup before that if assets are on and the database packages are missing."""from __future__ import annotations@@ -13,10 +13,9 @@ from aiohttp import webfrom app.assets import modefrom app.assets.lifecycle import record_hash_mode_transition_intent, run_shutdown, run_startup-from app.database.db import dependencies_available, missing_dependencies+from app.database.db import dependencies_availablefrom app.user_manager import UserManagerfrom comfy.cli_args import args-from utils.install_util import get_missing_requirements_message# These need the database packages. Without them only NoAssets is used, and it# does not touch these names.@@ -74,7 +73,7 @@ class AssetManager(Protocol):class _ArgsLike(Protocol):- enable_assets: bool+ disable_assets: boolenable_asset_hashing: bool@@ -233,11 +232,4 @@ class AssetsEnabled:def default_asset_manager() -> AssetManager:- if args.enable_assets and not dependencies_available():- missing = ", ".join(missing_dependencies()) or "see the import error above"- logging.error(- f"--enable-assets requires packages that could not be imported: {missing}. "- f"Assets are disabled.\n{get_missing_requirements_message()}"- )- return NoAssets(args)- return AssetsEnabled(args) if args.enable_assets else NoAssets(args)+ return NoAssets(args) if args.disable_assets else AssetsEnabled(args)diff --git a/app/database/db.py b/app/database/db.pyindex 19e9f4b6a..93c6a1970 100644--- a/app/database/db.py+++ b/app/database/db.py@@ -6,7 +6,6 @@ import sqlite3import timefrom contextlib import closingfrom app.logger import log_startup_warning-from utils.install_util import get_missing_requirements_messagefrom filelock import FileLock, Timeoutfrom comfy.cli_args import args, database_default_path@@ -23,6 +22,7 @@ try:from alembic.runtime.migration import MigrationContextfrom alembic.script import ScriptDirectoryfrom sqlalchemy import create_engine, event+ from sqlalchemy.engine import URL, make_urlfrom sqlalchemy.exc import OperationalErrorfrom sqlalchemy.orm import sessionmakerfrom sqlalchemy.pool import StaticPool@@ -32,16 +32,9 @@ try:import blake3 # noqa: F401 — verify the hard dependency is importable at startup_DB_AVAILABLE = True-except ImportError as e:- log_startup_warning(- f"""--------------------------------------------------------------------------Error importing dependencies: {e}-{get_missing_requirements_message()}-This error is happening because ComfyUI now uses a local sqlite database.--------------------------------------------------------------------------""".strip()- )+except ImportError:+ # Only the assets system needs these; with it on, startup stops and says what to install.+ logging.debug("Database packages failed to import", exc_info=True)def dependencies_available():@@ -76,8 +69,11 @@ def get_alembic_config():scripts_path = os.path.abspath(os.path.join(root_path, "alembic_db"))config = Config(config_path)- config.set_main_option("script_location", scripts_path)- config.set_main_option("sqlalchemy.url", get_database_url())+ # Config values go through ConfigParser interpolation, so a literal % in a path must be doubled,+ # including in the %(here)s default that alembic fills in unescaped.+ config.file_config.set("DEFAULT", "here", os.path.dirname(config_path).replace("%", "%%"))+ config.set_main_option("script_location", scripts_path.replace("%", "%%"))+ config.set_main_option("sqlalchemy.url", get_database_url().replace("%", "%%"))return config@@ -89,7 +85,9 @@ def get_database_url():import folder_pathsdb_path = os.path.join(folder_paths.get_user_directory(), "comfyui.db")- return f"sqlite:///{db_path}"+ # Built by SQLAlchemy so its own parser reads the path back intact: 2.1+ decodes %xx, and every version+ # stops the path at ? (which only 2.1+ quotes).+ return URL.create("sqlite", database=db_path).render_as_string()def get_legacy_default_db_path():@@ -99,7 +97,7 @@ def get_legacy_default_db_path():def get_db_path():url = get_database_url()if url.startswith("sqlite:///"):- return url.split("///", 1)[1]+ return make_url(url).databaseelse:raise ValueError(f"Unsupported database URL '{url}'.")@@ -229,7 +227,6 @@ def _is_memory_db(db_url):def init_db():db_url = get_database_url()- logging.debug(f"Database URL: {db_url}")if _is_memory_db(db_url):_init_memory_db(db_url)@@ -363,7 +360,7 @@ def _migrate_and_bind(db_url, db_path, db_exists):command.upgrade(config, target_rev)logging.info(f"Database upgraded from {current_rev} to {target_rev}")except Exception as e:- logging.exception("Error upgrading database: ")+ logging.debug("Error upgrading database", exc_info=True)if backup_path:# Restore the database from backup if upgrade failstry:diff --git a/comfy/cli_args.py b/comfy/cli_args.pyindex 385084a52..18748fb1e 100644--- a/comfy/cli_args.py+++ b/comfy/cli_args.py@@ -275,8 +275,9 @@ database_default_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "user", "comfyui.db"))parser.add_argument("--database-url", type=str, default=None, help="Specify the database URL, e.g. for an in-memory database you can use 'sqlite:///:memory:'. Defaults to 'comfyui.db' in the effective user directory.")-parser.add_argument("--enable-assets", action="store_true", help="Enable the assets system (API routes, database synchronization, and background scanning).")-parser.add_argument("--enable-asset-hashing", action="store_true", help="Compute blake3 content hashes when scanning assets. Hashing enables future asset-portability features (deduplication, cross-machine model resolution) but adds startup cost and per-output cost on large models directories. Off by default; enable to opt in.")+parser.add_argument("--disable-assets", action="store_true", help="Disable the assets system (API routes, database synchronization, and background scanning).")+parser.add_argument("--enable-assets", action="store_true", help="Deprecated: the assets system is on by default, so this does nothing. Use --disable-assets to turn it off.")+parser.add_argument("--enable-asset-hashing", action="store_true", help="Compute blake3 content hashes when scanning assets. Files uploaded through the API are hashed either way. Hashing enables future asset-portability features (deduplication, cross-machine model resolution) but adds startup cost and per-output cost on large models directories. Off by default; enable to opt in.")parser.add_argument("--feature-flag", type=str, action='append', default=[], metavar="KEY[=VALUE]", help="Set a server feature flag. Use KEY=VALUE to set an explicit value, or bare KEY to set it to true. Can be specified multiple times. Boolean values (true/false) and numbers are auto-converted. Examples: --feature-flag show_signin_button=true or --feature-flag show_signin_button")parser.add_argument("--list-feature-flags", action="store_true", help="Print the registry of known CLI-settable feature flags as JSON and exit.")diff --git a/comfy_api/feature_flags.py b/comfy_api/feature_flags.pyindex d12855fb9..569bbfaa5 100644--- a/comfy_api/feature_flags.py+++ b/comfy_api/feature_flags.py@@ -109,8 +109,8 @@ _CORE_FEATURE_FLAGS: dict[str, Any] = {"max_upload_size": args.max_upload_size * 1024 * 1024, # Convert MB to bytes"extension": {"manager": {"supports_v4": True}},"node_replacements": True,- # main.py replaces this at startup with the selected AssetManager's state, which is off without database dependencies.- "assets": args.enable_assets,+ # main.py replaces this at startup with the selected AssetManager's state.+ "assets": not args.disable_assets,}# CLI-provided flags cannot overwrite core flags. Startup code may: main.py sets "assets".diff --git a/comfy_execution/media_enrichment.py b/comfy_execution/media_enrichment.pyindex 36412a034..707f3fd2c 100644--- a/comfy_execution/media_enrichment.py+++ b/comfy_execution/media_enrichment.py@@ -4,7 +4,7 @@ Attaches a ``metadata`` object (``kind``/``width``/``height``, plus``duration``/``fps``/``frame_count`` for videos) to each file-type outputentry at output-processing time, so consumers of the ``executed`` messageand ``/history`` can read media properties without probing the files-themselves. Unlike asset enrichment this is NOT gated on ``--enable-assets``:+themselves. Unlike asset enrichment this still runs with ``--disable-assets``:the properties serve history/websocket consumers that don't run the assetssystem at all."""diff --git a/execution.py b/execution.pyindex b2ecf25ff..d4a68b32a 100644--- a/execution.py+++ b/execution.py@@ -48,7 +48,7 @@ from comfy_execution.media_enrichment import enrich_output_with_media_metadatafrom comfy_api.internal import _ComfyNodeInternal, _NodeOutputInternal, first_real_override, is_class, make_locked_method_funcfrom comfy_api.latest import io, _iofrom comfy_execution.cache_provider import _has_cache_providers, _get_cache_providers, _logger as _cache_logger-from app.assets.manager import AssetManager, default_asset_manager+from app.assets.manager import AssetManager, NoAssetsif TYPE_CHECKING:from comfy_execution.server_protocol import ExecutionServer@@ -667,7 +667,7 @@ class PromptExecutor:self.cache_args = cache_argsself.cache_type = cache_typeself.server = server- self.asset_manager = asset_manager if asset_manager is not None else default_asset_manager()+ self.asset_manager = asset_manager if asset_manager is not None else NoAssets(args)self.prompt_model_tracker = comfy.model_patcher.PromptModelTracker()self.reset()diff --git a/main.py b/main.pyindex fb5b512a1..9b9b0b4ac 100644--- a/main.py+++ b/main.py@@ -23,7 +23,9 @@ console_log_level = get_console_log_level(args.verbose)file_log_outputs = get_file_log_outputs(args.verbose)setup_logger(log_level=console_log_level, file_outputs=file_log_outputs, use_stdout=args.log_stdout)-from app.database.db import dependencies_available, init_db, lock_holder_db_path+from app.database.db import dependencies_available, get_database_url, get_db_path, init_db, lock_holder_db_path, missing_dependencies+from app.assets.event_log import error_kind+from utils.install_util import get_missing_requirements_messagefrom app.assets.lifecycle import cleanup_temp_filesystemfrom app.assets.manager import AssetManager, default_asset_managerimport itertools@@ -56,6 +58,9 @@ if __name__ == "__main__":if args.disable_api_nodes:logging.warning("--disable-api-nodes is deprecated and will be removed in a future version. It currently behaves like --offline. Use --offline to keep the frontend offline, or --disable-partner-nodes to only disable partner nodes.")+ if args.enable_assets:+ logging.warning("--enable-assets is deprecated and does nothing: the assets system is on unless ComfyUI is started with --disable-assets.")+faulthandler.enable(file=sys.stderr, all_threads=args.debug_hang)if __name__ == "__main__" and args.debug_hang:dumping_traceback = False@@ -490,22 +495,64 @@ def setup_database(asset_manager):init_db()asset_manager.startup()except Exception as e:- if "database is locked" in str(e) or "Could not acquire lock on database" in str(e):- logging.error(- "Database is locked. Another ComfyUI process is already using this database.\n"- "To resolve this, specify a separate database file for this instance:\n"- " --database-url sqlite:///path/to/another.db"- )- sys.exit(1)- logging.error(- f"Failed to initialize database: {e}\n"- "The --enable-assets flag requires a working database connection.\n"- "To resolve this, try one of the following:\n"- " 1. Install the latest requirements: pip install -r requirements.txt\n"- " 2. Specify an alternative database URL: --database-url sqlite:///path/to/your.db\n"- " 3. Use an in-memory database: --database-url sqlite:///:memory:"- )- sys.exit(1)+ failure, message = database_failure_message(e, get_database_url())+ if failure != "unsupported_url": # that error repeats the URL, which can carry a password+ logging.debug("Asset database startup failed", exc_info=True)+ stop_startup(failure, message)+++WITHOUT_ASSETS = "Or start ComfyUI without the assets system: --disable-assets"+++def stop_startup(kind, message):+ """Exit after a line a launcher can match, then the message for the user."""+ logging.error(f"ASSETS_STARTUP_FAILED: {kind}\n{message}")+ sys.exit(1)+++def database_failure_message(error, db_url):+ """The kind of failure that stopped the asset database from opening, and how to fix it."""+ if not (db_url.startswith("sqlite:///") or db_url == "sqlite://"):+ return "unsupported_url", ("--database-url must start with sqlite:///, like sqlite:///path/to/comfyui.db, "+ f"or be left out to use the default database.\n{WITHOUT_ASSETS}")+ location = get_db_path() if db_url.startswith("sqlite:///") else db_url+ kind = error_kind(error)+ detail = getattr(error, "orig", None) or error+ if "Could not acquire lock on database" in str(error):+ failure = "in_use"+ what = f"Another ComfyUI is already using this database: '{location}'."+ fix = "Close the other ComfyUI and start this one again."+ elif kind in ("database_locked", "file_locked"):+ failure = "locked"+ what = f"The asset database '{location}' is locked by another program ({detail})."+ fix = "Close any program that has it open, such as another ComfyUI or a database viewer, and start again."+ elif "Can't locate revision" in str(error):+ failure = "newer_revision"+ what = f"The asset database '{location}' was last used by a newer version of ComfyUI ({detail})."+ fix = "Update ComfyUI, or move that file aside and start again to create a new database."+ elif isinstance(error, (FileExistsError, NotADirectoryError)):+ failure = "path_blocked"+ what = f"A file is in the way of the folder for the asset database '{location}' ({detail})."+ fix = "Move that file, or choose another folder."+ elif kind in ("read_only", "unable_to_open") or isinstance(error, OSError):+ failure = "not_writable"+ what = f"ComfyUI can't create, open or write the asset database '{location}' ({detail})."+ fix = ("Make sure its folder is a writable directory, the database path is a writable file (or doesn't exist yet), "+ "and no other program has it open.")+ elif kind == "database_corrupt":+ failure = "corrupt"+ what = f"The asset database '{location}' is corrupt ({detail})."+ fix = ("Move that file aside, or delete it, and start again: ComfyUI creates a new database "+ "and rebuilds the asset catalog by rescanning your files.")+ else:+ failure = "other"+ what = f"Could not open or upgrade the asset database '{location}': {detail}"+ fix = ("If the database is damaged, move that file aside and start again: ComfyUI creates a new "+ "database and rebuilds the asset catalog by rescanning your files. Run with --verbose DEBUG for the full error.")+ lines = [what, fix]+ if failure in ("in_use", "locked") and args.database_url is None:+ lines.append("Or give this ComfyUI its own database: --database-url sqlite:///path/to/another.db")+ return failure, "\n".join(lines + [WITHOUT_ASSETS])def warn_if_database_in_use():@@ -519,10 +566,7 @@ WARNING WARNING WARNING WARNING WARNINGAnother ComfyUI is already using this install's asset database:{db_path}-This ComfyUI was started without --enable-assets, so it doesn't need that database and will start anyway.-A future version will refuse to start two ComfyUIs on the same asset database.-To run both, give this one its own:- --database-url sqlite:///path/to/another.db+This ComfyUI was started with --disable-assets, so it doesn't use that database and will start anyway.________________________________________________________________________""".strip())@@ -538,6 +582,10 @@ def start_comfyui(asyncio_loop=None):logging.info(f"Setting temp directory to: {temp_dir}")folder_paths.set_temp_directory(temp_dir)+ if not args.disable_assets and not dependencies_available():+ missing = ", ".join(missing_dependencies()) or "run with --verbose DEBUG to see the import error"+ stop_startup("missing_packages", f"The assets system needs packages that could not be imported: {missing}.\n"+ f"{get_missing_requirements_message()}\n{WITHOUT_ASSETS}")asset_manager: AssetManager = default_asset_manager()feature_flags.SERVER_FEATURE_FLAGS["assets"] = asset_manager.enabledif not asset_manager.enabled:diff --git a/tests-unit/app_test/database_path_test.py b/tests-unit/app_test/database_path_test.pyindex 838e1a96c..2ab68066b 100644--- a/tests-unit/app_test/database_path_test.py+++ b/tests-unit/app_test/database_path_test.py@@ -14,7 +14,7 @@ def test_default_database_url_uses_effective_user_directory(monkeypatch, tmp_patmonkeypatch.setattr(db.args, "database_url", None)monkeypatch.setattr("folder_paths.get_user_directory", lambda: str(user_dir))- assert db.get_database_url() == f"sqlite:///{user_dir / 'comfyui.db'}"+ assert db.get_db_path() == str(user_dir / "comfyui.db")def test_default_db_path_matches_legacy_default_without_custom_user_directory(monkeypatch):diff --git a/tests-unit/app_test/test_assets_default_on_processes.py b/tests-unit/app_test/test_assets_default_on_processes.pynew file mode 100644index 000000000..a49e50e13--- /dev/null+++ b/tests-unit/app_test/test_assets_default_on_processes.py@@ -0,0 +1,178 @@+"""Real ComfyUI starts: assets are on unless --disable-assets, and a database that can't be+opened stops startup."""++import contextlib+import socket+import sqlite3+import subprocess+import sys+import time+from pathlib import Path++import pytest+import requests+from alembic.script import ScriptDirectory++REPO_ROOT = Path(__file__).resolve().parents[2]+DEPRECATED = "--enable-assets is deprecated and does nothing"+HEAD = ScriptDirectory(str(REPO_ROOT / "alembic_db")).get_current_head()+++def _comfy_args(base: Path, *flags: str) -> list[str]:+ # Always an explicit database: without one, startup relocates the checkout's own user/comfyui.db.+ return [+ sys.executable,+ str(REPO_ROOT / "main.py"),+ "--cpu",+ "--disable-all-custom-nodes",+ "--disable-partner-nodes",+ f"--base-directory={base}",+ f"--front-end-root={base}",+ f"--database-url=sqlite:///{_db(base)}",+ *flags,+ ]+++def _db(base: Path) -> Path:+ return base / "user" / "comfyui.db"+++def _quick_start(base: Path, *flags: str) -> subprocess.CompletedProcess:+ return subprocess.run(+ _comfy_args(base, "--quick-test-for-ci", *flags),+ cwd=base,+ capture_output=True,+ text=True,+ timeout=120,+ )+++def _revision(db: Path) -> str:+ with sqlite3.connect(db) as conn:+ return conn.execute("SELECT version_num FROM alembic_version").fetchone()[0]++[email protected](("flags", "hashing"), [((), "false"), (("--enable-asset-hashing",), "true")])+def test_assets_are_on_by_default_and_hashing_stays_opt_in(tmp_path, flags, hashing):+ result = _quick_start(tmp_path, *flags)+ output = result.stdout + result.stderr++ assert result.returncode == 0, result.stderr+ assert _revision(_db(tmp_path)) == HEAD+ assert [line.split("assets.enabled ", 1)[1] for line in output.splitlines() if "[assets-event] assets.enabled " in line] == [+ f"hashing_enabled={hashing}"+ ]+ assert DEPRECATED not in result.stderr+++def test_enable_assets_is_accepted_and_says_once_that_it_does_nothing(tmp_path):+ result = _quick_start(tmp_path, "--enable-assets")++ assert result.returncode == 0, result.stderr+ assert result.stderr.count(DEPRECATED) == 1+ assert _revision(_db(tmp_path)) == HEAD+++def test_disable_assets_leaves_the_database_alone(tmp_path):+ result = _quick_start(tmp_path, "--disable-assets")++ assert result.returncode == 0, result.stderr+ assert not _db(tmp_path).exists()+++def test_database_from_a_newer_comfyui_stops_startup_without_a_traceback(tmp_path):+ _db(tmp_path).parent.mkdir()+ with sqlite3.connect(_db(tmp_path)) as conn:+ conn.execute("CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL)")+ conn.execute("INSERT INTO alembic_version VALUES ('0099_from_a_newer_release')")++ result = _quick_start(tmp_path)++ assert result.returncode == 1, result.stderr+ assert "ASSETS_STARTUP_FAILED: newer_revision" in result.stderr+ assert "Traceback" not in result.stderr+++def test_starts_with_a_percent_sign_in_the_database_path(tmp_path):+ # Alembic config values go through ConfigParser interpolation, where % is special.+ base = tmp_path / "50% data"+ base.mkdir()++ result = _quick_start(base)++ assert result.returncode == 0, result.stderr+ assert _revision(_db(base)) == HEAD+++def _free_port() -> int:+ with socket.socket() as s:+ s.bind(("127.0.0.1", 0))+ return s.getsockname()[1]+++def default_server(tmp_path):+ yield from _serve(tmp_path)+++def disabled_server(tmp_path):+ yield from _serve(tmp_path, "--disable-assets")+++def _serve(tmp_path, *flags):+ port = _free_port()+ log_path = tmp_path / "server.log"+ with open(log_path, "w") as log:+ server = subprocess.Popen(+ _comfy_args(tmp_path, *flags, "--listen", "127.0.0.1", "--port", str(port)),+ cwd=tmp_path,+ stdout=log,+ stderr=subprocess.STDOUT,+ )+ base_url = f"http://127.0.0.1:{port}"+ try:+ deadline = time.monotonic() + 120+ while time.monotonic() < deadline:+ assert server.poll() is None, log_path.read_text()[-4000:]+ with contextlib.suppress(requests.RequestException):+ if requests.get(f"{base_url}/system_stats", timeout=1).status_code == 200:+ break+ time.sleep(0.25)+ else:+ raise AssertionError(f"server did not start\n{log_path.read_text()[-4000:]}")+ yield base_url+ finally:+ server.terminate()+ try:+ server.wait(timeout=30)+ except subprocess.TimeoutExpired:+ server.kill()+ server.wait()+++def test_default_server_serves_assets_and_registers_uploads(default_server):+ upload = requests.post(+ f"{default_server}/upload/image",+ files={"image": ("default-on.png", b"default-on-bytes", "image/png")},+ data={"type": "input"},+ timeout=10,+ )+ assert upload.status_code == 200+ assert upload.json()["asset"]["name"] == "default-on.png"+ view = requests.get(f"{default_server}/view", params={"filename": "default-on.png", "type": "input"}, timeout=10)+ assert view.content == b"default-on-bytes"++ listed = requests.get(f"{default_server}/api/assets", timeout=10)++ assert listed.status_code == 200+ assert "default-on.png" in [asset["name"] for asset in listed.json()["assets"]]+ assert requests.get(f"{default_server}/features", timeout=10).json()["assets"] is True+++def test_disabled_server_reports_assets_off(disabled_server):+ disabled = requests.get(f"{disabled_server}/api/assets", timeout=10)++ assert disabled.status_code == 503+ assert "--disable-assets" in disabled.json()["error"]["message"]+ assert requests.get(f"{disabled_server}/features", timeout=10).json()["assets"] is Falsediff --git a/tests-unit/app_test/test_db_assets_off.py b/tests-unit/app_test/test_db_assets_off.pyindex 8a08c8177..210ebaae2 100644--- a/tests-unit/app_test/test_db_assets_off.py+++ b/tests-unit/app_test/test_db_assets_off.py@@ -127,8 +127,8 @@ def test_assets_off_warns_and_continues_when_another_process_holds_the_lock(warning = startup_warnings[0]assert "Another ComfyUI is already using this install's asset database" in warningassert db_path in warning- assert "This ComfyUI was started without --enable-assets, so it doesn't need that database and will start anyway" in warning- assert "A future version will refuse to start two ComfyUIs on the same asset database" in warning+ assert "This ComfyUI was started with --disable-assets, so it doesn't use that database and will start anyway" in warning+ assert "--database-url" not in warningdef test_probe_treats_a_failed_release_as_free(db_path, monkeypatch):diff --git a/tests-unit/app_test/test_db_init_locking.py b/tests-unit/app_test/test_db_init_locking.pyindex b4aa9bca3..e1e5d0cf0 100644--- a/tests-unit/app_test/test_db_init_locking.py+++ b/tests-unit/app_test/test_db_init_locking.py@@ -3,18 +3,11 @@ import osimport sqlite3import pytest-import torchfrom alembic import commandfrom alembic.config import Configfrom filelock import FileLock, Timeoutfrom app.database import db as db_module-from comfy.cli_args import args as cli_args--if not torch.cuda.is_available():- cli_args.cpu = True--import main # noqa: E402_PRE_HEAD = "0006_add_loader_path"@@ -134,64 +127,6 @@ def test_legacy_database_copy_runs_under_file_lock(tmp_path, monkeypatch):assert copied == [(str(legacy_db) + ".bak", str(target_db))]-class _AssetsOn:- enabled = True-- def startup(self):- pass---def test_setup_database_exits_for_file_lock_when_assets_are_enabled(monkeypatch, caplog):- monkeypatch.setattr(main, "dependencies_available", lambda: True)-- def _raise_file_lock():- raise RuntimeError(- "Could not acquire lock on database 'x.db'. "- "Another ComfyUI process may already be using it. "- "Use --database-url to specify a separate database file."- )-- monkeypatch.setattr(main, "init_db", _raise_file_lock)-- with caplog.at_level(logging.ERROR), pytest.raises(SystemExit) as error:- main.setup_database(_AssetsOn())-- assert error.value.code == 1- assert "Database is locked. Another ComfyUI process is already using this database." in caplog.text- assert "The --enable-assets flag requires a working database connection." not in caplog.text---def test_setup_database_exits_for_driver_lock_when_assets_are_enabled(monkeypatch, caplog):- monkeypatch.setattr(main, "dependencies_available", lambda: True)-- def _raise_driver_lock():- raise Exception("sqlite3.OperationalError: database is locked")-- monkeypatch.setattr(main, "init_db", _raise_driver_lock)-- with caplog.at_level(logging.ERROR), pytest.raises(SystemExit) as error:- main.setup_database(_AssetsOn())-- assert error.value.code == 1- assert "Database is locked. Another ComfyUI process is already using this database." in caplog.text---def test_setup_database_exits_for_other_failures_when_assets_are_enabled(monkeypatch, caplog):- monkeypatch.setattr(main, "dependencies_available", lambda: True)-- def _raise_other():- raise RuntimeError("alembic config exploded")-- monkeypatch.setattr(main, "init_db", _raise_other)-- with caplog.at_level(logging.ERROR), pytest.raises(SystemExit) as error:- main.setup_database(_AssetsOn())-- assert error.value.code == 1- assert "The --enable-assets flag requires a working database connection." in caplog.text- assert "Database is locked." not in caplog.text--def test_failed_restore_does_not_mask_the_upgrade_error(stale_db, monkeypatch, caplog):real_backup = db_module._backup_databasediff --git a/tests-unit/app_test/test_db_lock_processes.py b/tests-unit/app_test/test_db_lock_processes.pyindex 41cb0a794..9cbe73ea5 100644--- a/tests-unit/app_test/test_db_lock_processes.py+++ b/tests-unit/app_test/test_db_lock_processes.py@@ -11,7 +11,7 @@ from pathlib import Pathimport pytestREPO_ROOT = Path(__file__).resolve().parents[2]-LOCK_HELD = "Database is locked. Another ComfyUI process is already using this database."+LOCK_HELD = "Another ComfyUI is already using this database"IN_USE = "Another ComfyUI is already using this install's asset database"HOLD_SCRIPT = (@@ -87,14 +87,14 @@ def held_lock(tmp_path):def test_running_assets_off_instance_does_not_block_an_assets_on_start(tmp_path):# A previous assets-on run leaves the database and its lock file behind, as on a real install.- first = _quick_start(tmp_path, "--enable-assets")+ first = _quick_start(tmp_path)assert first.returncode == 0, first.stderrport = _free_port()server_log = tmp_path / "server.log"with open(server_log, "w") as log:server = subprocess.Popen(- _comfy_args(tmp_path, "--listen", "127.0.0.1", "--port", str(port)),+ _comfy_args(tmp_path, "--disable-assets", "--listen", "127.0.0.1", "--port", str(port)),cwd=REPO_ROOT,stdout=log,stderr=subprocess.STDOUT,@@ -105,7 +105,7 @@ def test_running_assets_off_instance_does_not_block_an_assets_on_start(tmp_path)except AssertionError as e:raise AssertionError(f"{e}\n{server_log.read_text()[-4000:]}") from None- second = _quick_start(tmp_path, "--enable-assets")+ second = _quick_start(tmp_path)assert server.poll() is Nonefinally:@@ -117,17 +117,17 @@ def test_running_assets_off_instance_does_not_block_an_assets_on_start(tmp_path)def test_assets_off_start_warns_and_continues_when_the_database_is_held(tmp_path, held_lock):- result = _quick_start(tmp_path)+ result = _quick_start(tmp_path, "--disable-assets")assert result.returncode == 0, result.stderrassert IN_USE in result.stderrassert str(tmp_path / "comfyui.db") in result.stderr- assert "A future version will refuse to start two ComfyUIs on the same asset database" in result.stderr+ assert "doesn't use that database and will start anyway" in result.stderrassert "Traceback" not in result.stderrdef test_assets_on_start_still_fails_when_the_database_is_held(tmp_path, held_lock):- result = _quick_start(tmp_path, "--enable-assets")+ result = _quick_start(tmp_path)assert result.returncode == 1, result.stderrassert LOCK_HELD in result.stderrdiff --git a/tests-unit/app_test/test_db_startup_failures.py b/tests-unit/app_test/test_db_startup_failures.pynew file mode 100644index 000000000..6255fde29--- /dev/null+++ b/tests-unit/app_test/test_db_startup_failures.py@@ -0,0 +1,311 @@+"""Each way the asset database can fail to open stops startup with a message that names+the database and the fix. Every case drives the real init_db against a real file."""++import errno+from contextlib import closing+import logging+import os+import sqlite3+import sys+from pathlib import Path++import pytest+import torch+from alembic import command+from alembic.script import ScriptDirectory+from sqlalchemy.engine import URL, make_url+from filelock import FileLock++import folder_paths+from app.database import db as db_module+from comfy.cli_args import args as cli_args++if not torch.cuda.is_available():+ cli_args.cpu = True++import main # noqa: E402+++class _AssetsOn:+ enabled = True++ def startup(self):+ pass+++def db_path(tmp_path, monkeypatch):+ path = str(tmp_path / "comfyui.db")+ monkeypatch.setattr(db_module.args, "database_url", f"sqlite:///{path}")+ monkeypatch.setattr(db_module, "Session", None)+ monkeypatch.setattr(db_module, "WriteSession", None)+ monkeypatch.setattr(db_module, "_db_lock", None)+ monkeypatch.setattr(db_module, "_LOCK_WAIT_SECONDS", 0.1)+ yield path+ if db_module._db_lock is not None:+ db_module._db_lock.release(force=True)+++def _startup_error(caplog, asset_manager=None, *, kind, level=logging.ERROR):+ with caplog.at_level(level), pytest.raises(SystemExit) as stopped:+ main.setup_database(asset_manager or _AssetsOn())+ assert stopped.value.code == 1+ assert "--disable-assets" in caplog.text+ assert f"ASSETS_STARTUP_FAILED: {kind}\n" in caplog.text+ return caplog.text+++def _stamp(path, revision):+ with sqlite3.connect(path) as conn:+ conn.execute("CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL)")+ conn.execute("INSERT INTO alembic_version VALUES (?)", (revision,))+++def test_lock_held_by_another_comfyui(db_path, caplog):+ holder = FileLock(db_path + ".lock")+ holder.acquire(timeout=0)+ try:+ error = _startup_error(caplog, kind="in_use")+ finally:+ holder.release()++ # Launchers match "already using this database"; keep that phrase.+ assert f"Another ComfyUI is already using this database: '{db_path}'." in error+ assert "Close the other ComfyUI" in error+ assert "Or give this ComfyUI its own database" not in error # it already has --database-url+++def test_database_locked_by_another_program(db_path, caplog):+ sqlite3.connect(db_path).close()+ other = sqlite3.connect(db_path, isolation_level=None)+ other.execute("BEGIN EXCLUSIVE")+ try:+ error = _startup_error(caplog, kind="locked")+ finally:+ other.close()++ assert f"The asset database '{db_path}' is locked by another program (database is locked)." in error+ assert "Close any program that has it open" in error+++def test_corrupt_database(db_path, caplog):+ with open(db_path, "wb") as f:+ f.write(b"not a database" * 1000)++ error = _startup_error(caplog, kind="corrupt")++ assert f"The asset database '{db_path}' is corrupt (file is not a database)." in error+ assert "Move that file aside, or delete it, and start again" in error++[email protected](sys.platform == "win32" or os.geteuid() == 0, reason="needs POSIX permissions enforced")+def test_corrupt_read_only_database_is_reported_as_corrupt(db_path, caplog):+ with open(db_path, "wb") as f:+ f.write(b"not a database" * 1000)+ os.chmod(db_path, 0o444)++ error = _startup_error(caplog, kind="corrupt")++ assert f"The asset database '{db_path}' is corrupt" in error+++def test_database_from_a_newer_comfyui(db_path, caplog):+ _stamp(db_path, "0099_from_a_newer_release")++ error = _startup_error(caplog, kind="newer_revision")++ assert f"The asset database '{db_path}' was last used by a newer version of ComfyUI" in error+ assert "0099_from_a_newer_release" in error+ assert "Update ComfyUI" in error+++def test_failed_upgrade(db_path, caplog):+ _stamp(db_path, "0006_add_loader_path") # but none of 0006's tables, so the next migration fails++ error = _startup_error(caplog, kind="other")++ assert f"Could not open or upgrade the asset database '{db_path}': no such table" in error+ assert "If the database is damaged, move that file aside and start again" in error+ assert "delete it" not in error+ assert "Error upgrading database" not in error # its traceback is at DEBUG+ assert "Run with --verbose DEBUG for the full error." in error++[email protected](sys.platform == "win32" or os.geteuid() == 0, reason="needs POSIX permissions enforced")+def test_folder_not_writable(tmp_path, db_path, caplog):+ os.chmod(tmp_path, 0o555)+ try:+ error = _startup_error(caplog, kind="not_writable")+ finally:+ os.chmod(tmp_path, 0o755)++ assert f"ComfyUI can't create, open or write the asset database '{db_path}' ([Errno 13] Permission denied" in error+ assert "Make sure its folder is a writable directory" in error+++def test_database_path_is_a_directory(db_path, caplog):+ os.mkdir(db_path)++ error = _startup_error(caplog, kind="not_writable")++ assert f"ComfyUI can't create, open or write the asset database '{db_path}'" in error+ assert "the database path is a writable file" in error+ assert "no other program has it open" in error # SQLite says the same for a file another program holds+ assert "delete it" not in error+++ "parts",+ [+ ("taken", "comfyui.db"),+ pytest.param(("taken", "sub", "comfyui.db"), marks=pytest.mark.skipif(sys.platform == "win32", reason="Windows reports this as a missing path")),+ ],+)+def test_folder_path_runs_through_a_file(tmp_path, monkeypatch, db_path, caplog, parts):+ (tmp_path / "taken").write_text("")+ path = str(tmp_path.joinpath(*parts))+ monkeypatch.setattr(db_module.args, "database_url", f"sqlite:///{path}")++ error = _startup_error(caplog, kind="path_blocked")++ assert f"A file is in the way of the folder for the asset database '{path}'" in error+ assert "delete it" not in error++[email protected](sys.platform == "win32" or os.geteuid() == 0, reason="needs POSIX permissions enforced")+def test_read_only_database_file_that_needs_an_upgrade(db_path, caplog):+ config = db_module.get_alembic_config()+ command.upgrade(config, "0006_add_loader_path")+ with closing(sqlite3.connect(db_path)) as conn:+ conn.execute("PRAGMA journal_mode=WAL") # as ComfyUI leaves it+ os.chmod(db_path, 0o444)++ error = _startup_error(caplog, kind="not_writable")++ assert f"ComfyUI can't create, open or write the asset database '{db_path}' (attempt to write a readonly database)" in error+ assert "delete it" not in error+++def test_file_held_open_by_another_process_on_windows(monkeypatch, db_path, caplog):+ def _sharing_violation(path):+ error = PermissionError(errno.EACCES, "The process cannot access the file", path)+ error.winerror = 32 # ERROR_SHARING_VIOLATION+ raise error++ monkeypatch.setattr(db_module, "prepare_file_db_path", _sharing_violation)++ error = _startup_error(caplog, kind="locked")++ assert f"The asset database '{db_path}' is locked by another program" in error+++def test_failure_after_the_database_opened_doesnt_suggest_deleting_it(db_path, caplog):+ class _StartupFails(_AssetsOn):+ def startup(self):+ raise RuntimeError("hash mode state unreadable")++ error = _startup_error(caplog, _StartupFails(), kind="other", level=logging.DEBUG)++ assert "Asset database startup failed" in error # the --verbose DEBUG detail the message points to++ assert f"Could not open or upgrade the asset database '{db_path}': hash mode state unreadable" in error+ assert "delete it" not in error+++ "url", ["postgresql://user:secret@localhost/comfy", "sqlite:relative.db", "sqlite://user:secret@host/x.db"]+)+def test_database_url_that_is_not_sqlite_file_url(monkeypatch, db_path, caplog, url):+ monkeypatch.setattr(db_module.args, "database_url", url)++ error = _startup_error(caplog, kind="unsupported_url", level=logging.DEBUG)++ assert "--database-url must start with sqlite:///, like sqlite:///path/to/comfyui.db" in error+ assert "or be left out to use the default database" in error+ assert url not in error+ assert "secret" not in caplog.text+++def test_default_database_in_use_suggests_its_own_database(tmp_path, monkeypatch, db_path, caplog):+ user_dir = tmp_path / "user"+ user_dir.mkdir()+ monkeypatch.setattr(db_module.args, "database_url", None)+ monkeypatch.setattr(db_module, "get_legacy_default_db_path", lambda: None)+ monkeypatch.setattr(folder_paths, "get_user_directory", lambda: str(user_dir))+ holder = FileLock(str(user_dir / "comfyui.db.lock"))+ holder.acquire(timeout=0)+ try:+ error = _startup_error(caplog, kind="in_use")+ finally:+ holder.release()++ assert "Or give this ComfyUI its own database: --database-url sqlite:///path/to/another.db" in error+++def test_no_second_database_suggested_for_a_broken_one(tmp_path, monkeypatch, db_path, caplog):+ # A fresh file would quietly start a second, empty catalog instead of fixing this one.+ user_dir = tmp_path / "user"+ user_dir.mkdir()+ (user_dir / "comfyui.db").write_bytes(b"not a database" * 1000)+ monkeypatch.setattr(db_module.args, "database_url", None)+ monkeypatch.setattr(db_module, "get_legacy_default_db_path", lambda: None)+ monkeypatch.setattr(folder_paths, "get_user_directory", lambda: str(user_dir))++ error = _startup_error(caplog, kind="corrupt")++ assert "comfyui-2.db" not in error+++def test_opens_from_an_install_folder_with_a_percent_sign(tmp_path, monkeypatch, db_path):+ # Alembic config values go through ConfigParser interpolation, where % is special.+ root = tmp_path / "100% tmp"+ try:+ os.symlink(Path(main.__file__).parent, root, target_is_directory=True)+ except OSError:+ pytest.skip("can't create a directory symlink here")+ monkeypatch.setattr(db_module, "__file__", str(root / "app" / "database" / "db.py"))++ db_module.init_db()++ with sqlite3.connect(db_path) as conn:+ assert conn.execute("SELECT version_num FROM alembic_version").fetchone()[0] == _head()+++def _sqlalchemy_quotes_question_marks():+ return make_url(URL.create("sqlite", database="/a?/b.db").render_as_string()).database == "/a?/b.db"+++ "folder",+ [+ "100%20x",+ pytest.param(+ "what?",+ marks=pytest.mark.skipif(+ sys.platform == "win32" or not _sqlalchemy_quotes_question_marks(),+ reason="? isn't allowed in Windows paths, and SQLAlchemy before 2.1 can't put one in a URL",+ ),+ ),+ ],+)+def test_default_database_path_is_used_literally(tmp_path, monkeypatch, db_path, folder):+ # SQLAlchemy 2.1 decodes %xx in a URL and ends the path at ?, so the path must be quoted.+ user_dir = tmp_path / folder+ monkeypatch.setattr(db_module.args, "database_url", None)+ monkeypatch.setattr(db_module, "get_legacy_default_db_path", lambda: None)+ monkeypatch.setattr(folder_paths, "get_user_directory", lambda: str(user_dir))++ db_module.init_db()++ assert db_module.get_db_path() == str(user_dir / "comfyui.db")+ with sqlite3.connect(user_dir / "comfyui.db") as conn:+ assert conn.execute("SELECT version_num FROM alembic_version").fetchone()[0] == _head()+++def _revision(path):+ with sqlite3.connect(path) as conn:+ return conn.execute("SELECT version_num FROM alembic_version").fetchone()[0]+++def _head():+ return ScriptDirectory(str(Path(main.__file__).parent / "alembic_db")).get_current_head()diff --git a/tests-unit/assets_test/services/test_noassets_parity.py b/tests-unit/assets_test/services/test_noassets_parity.pyindex e1ff69ac4..7458b534b 100644--- a/tests-unit/assets_test/services/test_noassets_parity.py+++ b/tests-unit/assets_test/services/test_noassets_parity.py@@ -1,6 +1,5 @@from collections.abc import Callablefrom contextlib import AbstractContextManager-import loggingfrom pathlib import Pathfrom unittest.mock import Mock, patch@@ -19,10 +18,11 @@ from app.assets.manager import AssetsEnabled, NoAssetsfrom app.assets.mode import hashing_enabledfrom app.assets.seeder import asset_seederfrom app.assets.services.hash_mode_state import read_stored_mode+from comfy.cli_args import parserclass _Args:- enable_assets = False+ disable_assets = Truedef __init__(self, hashing: bool) -> None:self.enable_asset_hashing = hashing@@ -45,7 +45,9 @@ async def test_noassets_register_routes_returns_service_disabled_and_disables_seresponse = await client.get("/api/assets")assert response.status == 503- assert (await response.json())["error"]["code"] == "SERVICE_DISABLED"+ error = (await response.json())["error"]+ assert error["code"] == "SERVICE_DISABLED"+ assert "--disable-assets" in error["message"]assert asset_seeder.is_disabled()@@ -179,25 +181,18 @@ def test_noassets_is_disabled() -> None:assert _no_assets().enabled is False-def test_default_asset_manager_disables_assets_when_dependencies_are_unavailable(- monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture+ ("flags", "expected"),+ [+ ([], AssetsEnabled),+ (["--enable-assets"], AssetsEnabled),+ (["--disable-assets"], NoAssets),+ (["--enable-assets", "--disable-assets"], NoAssets),+ ],+)+def test_assets_are_on_unless_disabled(+ flags: list[str], expected: type, monkeypatch: pytest.MonkeyPatch) -> None:- monkeypatch.setattr(manager.args, "enable_assets", True)- monkeypatch.setattr(manager, "dependencies_available", lambda: False)+ monkeypatch.setattr(manager, "args", parser.parse_args(flags))- with caplog.at_level(logging.WARNING):- asset_manager = manager.default_asset_manager()-- assert isinstance(asset_manager, NoAssets)- assert "--enable-assets requires packages that could not be imported" in caplog.text- assert "Assets are disabled." in caplog.text- assert "requirements.txt" in caplog.text---def test_default_asset_manager_enables_assets_when_dependencies_are_available(- monkeypatch: pytest.MonkeyPatch,-) -> None:- monkeypatch.setattr(manager.args, "enable_assets", True)- monkeypatch.setattr(manager, "dependencies_available", lambda: True)-- assert isinstance(manager.default_asset_manager(), AssetsEnabled)+ assert isinstance(manager.default_asset_manager(), expected)diff --git a/tests-unit/assets_test/services/test_transition_drain.py b/tests-unit/assets_test/services/test_transition_drain.pyindex b6c9ff4dd..e355663cc 100644--- a/tests-unit/assets_test/services/test_transition_drain.py+++ b/tests-unit/assets_test/services/test_transition_drain.py@@ -305,7 +305,7 @@ def test_transition_drain_skips_out_of_root_path(session, temp_dir, monkeypatch,except ValueError as error:pytest.fail(f"an out-of-root path escaped the drain as {error!r}; setup_database turns that "- f"into sys.exit(1) when --enable-assets is set"+ f"into sys.exit(1) when assets are on")session.commit()diff --git a/tests-unit/assets_test/test_event_log_sites.py b/tests-unit/assets_test/test_event_log_sites.pyindex 0880ca306..33f722962 100644--- a/tests-unit/assets_test/test_event_log_sites.py+++ b/tests-unit/assets_test/test_event_log_sites.py@@ -63,6 +63,6 @@ def test_enabled_assets_emits_once_with_the_hashing_flag(def test_noassets_emits_no_enabled_event(tmp_path: Path) -> None:- output = run_quick_startup(tmp_path)+ output = run_quick_startup(tmp_path, "--disable-assets")assert f"{TAG} assets.enabled " not in outputdiff --git a/tests-unit/assets_test/test_no_assets_regression.py b/tests-unit/assets_test/test_no_assets_regression.pyindex d75fc31c9..e44f9ae95 100644--- a/tests-unit/assets_test/test_no_assets_regression.py+++ b/tests-unit/assets_test/test_no_assets_regression.py@@ -30,6 +30,7 @@ def no_assets_server(tmp_path: Path):"--port",str(port),"--cpu",+ "--disable-assets",],cwd=Path(__file__).resolve().parents[2],stdout=subprocess.DEVNULL,@@ -54,7 +55,9 @@ def no_assets_server(tmp_path: Path):def test_no_assets_keeps_legacy_upload_and_view(no_assets_server: str):- assert requests.get(f"{no_assets_server}/api/assets", timeout=10).status_code == 503+ disabled = requests.get(f"{no_assets_server}/api/assets", timeout=10)+ assert disabled.status_code == 503+ assert "--disable-assets" in disabled.json()["error"]["message"]upload = requests.post(f"{no_assets_server}/upload/image",diff --git a/tests-unit/assets_test/test_startup_without_asset_dependencies.py b/tests-unit/assets_test/test_startup_without_asset_dependencies.pyindex db783d0c9..4fe75203b 100644--- a/tests-unit/assets_test/test_startup_without_asset_dependencies.py+++ b/tests-unit/assets_test/test_startup_without_asset_dependencies.py@@ -46,23 +46,22 @@ def test_starts_without_asset_dependencies_when_assets_disabled(tmp_path: Path)stale_temp_file.parent.mkdir()stale_temp_file.write_bytes(b"")- result = run_quick_startup(tmp_path)+ result = run_quick_startup(tmp_path, "--disable-assets")assert result.returncode == 0, result.stdout + result.stderrassert "Traceback" not in result.stderr+ assert "Error importing dependencies" not in result.stdout + result.stderrassert not stale_temp_file.exists()-def test_enable_assets_without_dependencies_names_them_and_starts_with_assets_disabled(- tmp_path: Path,-) -> None:- result = run_quick_startup(tmp_path, "--enable-assets")[email protected]("flags", [(), ("--enable-assets",)])+def test_missing_dependencies_stop_startup_and_name_the_fix(tmp_path: Path, flags: tuple[str, ...]) -> None:+ result = run_quick_startup(tmp_path, *flags)output = result.stdout + result.stderr- assert result.returncode == 0, output- assert (- "--enable-assets requires packages that could not be imported: "- "sqlalchemy, alembic, blake3. Assets are disabled." in output- )+ assert result.returncode == 1, output+ assert "ASSETS_STARTUP_FAILED: missing_packages" in output+ assert "The assets system needs packages that could not be imported: sqlalchemy, alembic, blake3." in outputassert "-m pip install -r" in output+ assert "--disable-assets" in outputassert "Traceback" not in outputdiff --git a/tests-unit/execution_test/test_executor_asset_manager.py b/tests-unit/execution_test/test_executor_asset_manager.pynew file mode 100644index 000000000..074bcae67--- /dev/null+++ b/tests-unit/execution_test/test_executor_asset_manager.py@@ -0,0 +1,8 @@+from execution import PromptExecutor+++def test_executor_built_without_a_manager_leaves_assets_off():+ # Only startup initialises the asset database, so a manager it didn't pass can't be enabled.+ executor = PromptExecutor(object(), cache_type=False, cache_args={"ram": 0, "ram_inactive": 0})++ assert executor.asset_manager.enabled is Falsediff --git a/tests-unit/governance_test/test_initialize.py b/tests-unit/governance_test/test_initialize.pyindex 9748c3fe1..aaf26acb2 100644--- a/tests-unit/governance_test/test_initialize.py+++ b/tests-unit/governance_test/test_initialize.py@@ -66,7 +66,7 @@ def _run_governed("stub('comfy_execution.progress', get_progress_state=noop)","stub('comfy_execution.utils', get_executing_context=noop)","stub('comfy_api', feature_flags=types.SimpleNamespace())",- "stub('app.database.db', init_db=noop, dependencies_available=lambda: False, lock_holder_db_path=lambda: None)",+ "stub('app.database.db', init_db=noop, dependencies_available=lambda: False, lock_holder_db_path=lambda: None, get_database_url=noop, get_db_path=noop, missing_dependencies=list)","control = stub('comfy_aimdo.control', init=noop)","stub('comfy_aimdo', control=control)","stub('cuda_malloc', get_torch_version_noimport=lambda: '')",diff --git a/tests-unit/governance_test/test_pack_gate.py b/tests-unit/governance_test/test_pack_gate.pyindex d225e363b..a9da27ef7 100644--- a/tests-unit/governance_test/test_pack_gate.py+++ b/tests-unit/governance_test/test_pack_gate.py@@ -385,7 +385,7 @@ def test_real_main_rejects_unknown_pack_without_manager(tmp_path: Path) -> None:"import runpy, sys\n""from app import governance\n""governance.initialize = lambda: governance.set_custom_node_policy('allowlist', frozenset(), {})\n"- f"sys.argv = [{str(MAIN_PATH)!r}, '--base-directory', {str(tmp_path)!r}, '--cpu', '--disable-api-nodes', '--quick-test-for-ci']\n"+ f"sys.argv = [{str(MAIN_PATH)!r}, '--base-directory', {str(tmp_path)!r}, '--cpu', '--disable-api-nodes', '--disable-assets', '--quick-test-for-ci']\n"f"runpy.run_path({str(MAIN_PATH)!r}, run_name='__main__')\n")diff --git a/tests/execution/test_async_nodes.py b/tests/execution/test_async_nodes.pyindex 54660c112..cfe27314a 100644--- a/tests/execution/test_async_nodes.py+++ b/tests/execution/test_async_nodes.py@@ -24,6 +24,7 @@ class TestAsyncNodes:'--port', str(args_pytest["port"]),'--extra-model-paths-config', 'tests/execution/extra_model_paths.yaml','--cpu',+ '--disable-assets',]use_lru, lru_size = request.paramif use_lru:diff --git a/tests/execution/test_disabled_nodes.py b/tests/execution/test_disabled_nodes.pyindex 8bfe53220..f1b308b78 100644--- a/tests/execution/test_disabled_nodes.py+++ b/tests/execution/test_disabled_nodes.py@@ -77,6 +77,7 @@ def _running_server(tmp_path: Path, disabled_node: str, testing_nodes: bool = Fa"--port",str(port),"--cpu",+ "--disable-assets","--cache-none","--disable-api-nodes","--output-directory",diff --git a/tests/execution/test_execution.py b/tests/execution/test_execution.pyindex b8b3e856f..0709c5449 100644--- a/tests/execution/test_execution.py+++ b/tests/execution/test_execution.py@@ -482,8 +482,7 @@ class TestExecution:{ "extra_args" : ["--cache-classic"], "should_cache_results" : True },{ "extra_args" : ["--cache-lru", 100], "should_cache_results" : True },{ "extra_args" : ["--cache-none"], "should_cache_results" : False },- # TODO: re-enable once the --enable-assets execution runs stop flaking.- # {"extra_args": ["--enable-assets"], "should_cache_results": True, "assets": True},+ {"extra_args": [], "should_cache_results": True, "assets": True},])def server(self, args_pytest, request, tmp_path_factory):# Start server@@ -497,7 +496,9 @@ class TestExecution:'--cpu',]pargs += [ str(param) for param in request.param["extra_args"] ]- if assets_enabled:+ if not assets_enabled:+ pargs.append('--disable-assets')+ else:assets_tmp_dir = tmp_path_factory.mktemp("execution-assets")database_path = assets_tmp_dir / "assets.db"capture_path = assets_tmp_dir / "server.log"diff --git a/tests/execution/test_progress_isolation.py b/tests/execution/test_progress_isolation.pyindex 93dc0d41b..5ec2dfc18 100644--- a/tests/execution/test_progress_isolation.py+++ b/tests/execution/test_progress_isolation.py@@ -94,6 +94,7 @@ class TestProgressIsolation:'--port', str(args_pytest["port"]),'--extra-model-paths-config', 'tests/execution/extra_model_paths.yaml','--cpu',+ '--disable-assets',]p = subprocess.Popen(pargs)yielddiff --git a/tests/execution/test_public_api.py b/tests/execution/test_public_api.pyindex 52bc2fcd8..66a1ae214 100644--- a/tests/execution/test_public_api.py+++ b/tests/execution/test_public_api.py@@ -29,6 +29,7 @@ class TestPublicAPI:'--port', str(args_pytest["port"]),'--extra-model-paths-config', 'tests/execution/extra_model_paths.yaml','--cpu',+ '--disable-assets',]p = subprocess.Popen(pargs)yielddiff --git a/tests/inference/test_inference.py b/tests/inference/test_inference.pyindex 7e4a206c4..8021bd3a7 100644--- a/tests/inference/test_inference.py+++ b/tests/inference/test_inference.py@@ -156,6 +156,7 @@ class TestInference:'--output-directory', args_pytest["output_dir"],'--listen', args_pytest["listen"],'--port', str(args_pytest["port"]),+ '--disable-assets',])yieldp.kill()