The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
feat: Support ComfyUI-Manager for pip version (#7555)
Dr.Lt.Datab4a20acc54b0
diff --git a/comfy/cli_args.py b/comfy/cli_args.pyindex 5f0dfaa10..209fc185b 100644--- a/comfy/cli_args.py+++ b/comfy/cli_args.py@@ -121,6 +121,12 @@ upcast.add_argument("--force-upcast-attention", action="store_true", help="Forceupcast.add_argument("--dont-upcast-attention", action="store_true", help="Disable all upcasting of attention. Should be unnecessary except for debugging.")+parser.add_argument("--enable-manager", action="store_true", help="Enable the ComfyUI-Manager feature.")+manager_group = parser.add_mutually_exclusive_group()+manager_group.add_argument("--disable-manager-ui", action="store_true", help="Disables only the ComfyUI-Manager UI and endpoints. Scheduled installations and similar background tasks will still operate.")+manager_group.add_argument("--enable-manager-legacy-ui", action="store_true", help="Enables the legacy UI of ComfyUI-Manager")++vram_group = parser.add_mutually_exclusive_group()vram_group.add_argument("--gpu-only", action="store_true", help="Store and run everything (text encoders/CLIP models, etc... on the GPU).")vram_group.add_argument("--highvram", action="store_true", help="By default models will be unloaded to CPU memory after being used. This option keeps them in GPU memory.")@@ -168,6 +174,7 @@ parser.add_argument("--multi-user", action="store_true", help="Enables per-userparser.add_argument("--verbose", default='INFO', const='DEBUG', nargs="?", choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Set the logging level')parser.add_argument("--log-stdout", action="store_true", help="Send normal process output to stdout instead of stderr (default).")+# The default built-in provider hosted under web/DEFAULT_VERSION_STRING = "comfyanonymous/ComfyUI@latest"diff --git a/comfy_api/feature_flags.py b/comfy_api/feature_flags.pyindex 0d4389a6e..bfb77eb5f 100644--- a/comfy_api/feature_flags.py+++ b/comfy_api/feature_flags.py@@ -13,6 +13,7 @@ from comfy.cli_args import argsSERVER_FEATURE_FLAGS: Dict[str, Any] = {"supports_preview_metadata": True,"max_upload_size": args.max_upload_size * 1024 * 1024, # Convert MB to bytes+ "extension": {"manager": {"supports_v4": True}},}diff --git a/main.py b/main.pyindex e1b0f1620..0cd815d9e 100644--- a/main.py+++ b/main.py@@ -15,6 +15,7 @@ from comfy_execution.progress import get_progress_statefrom comfy_execution.utils import get_executing_contextfrom comfy_api import feature_flags+if __name__ == "__main__":#NOTE: These do not do anything on core ComfyUI, they are for custom nodes.os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1'@@ -22,6 +23,23 @@ if __name__ == "__main__":setup_logger(log_level=args.verbose, use_stdout=args.log_stdout)++def handle_comfyui_manager_unavailable():+ if not args.windows_standalone_build:+ logging.warning(f"\n\nYou appear to be running comfyui-manager from source, this is not recommended. Please install comfyui-manager using the following command:\ncommand:\n\t{sys.executable} -m pip install --pre comfyui_manager\n")+ args.enable_manager = False+++if args.enable_manager:+ if importlib.util.find_spec("comfyui_manager"):+ import comfyui_manager++ if not comfyui_manager.__file__ or not comfyui_manager.__file__.endswith('__init__.py'):+ handle_comfyui_manager_unavailable()+ else:+ handle_comfyui_manager_unavailable()++def apply_custom_paths():# extra model pathsextra_model_paths_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "extra_model_paths.yaml")@@ -79,6 +97,11 @@ def execute_prestartup_script():for possible_module in possible_modules:module_path = os.path.join(custom_node_path, possible_module)++ if args.enable_manager:+ if comfyui_manager.should_be_disabled(module_path):+ continue+if os.path.isfile(module_path) or module_path.endswith(".disabled") or module_path == "__pycache__":continue@@ -101,6 +124,10 @@ def execute_prestartup_script():logging.info("")apply_custom_paths()++if args.enable_manager:+ comfyui_manager.prestartup()+execute_prestartup_script()@@ -323,6 +350,9 @@ def start_comfyui(asyncio_loop=None):asyncio.set_event_loop(asyncio_loop)prompt_server = server.PromptServer(asyncio_loop)+ if args.enable_manager and not args.disable_manager_ui:+ comfyui_manager.start()+hook_breaker_ac10a0.save_functions()asyncio_loop.run_until_complete(nodes.init_extra_nodes(init_custom_nodes=(not args.disable_all_custom_nodes) or len(args.whitelist_custom_nodes) > 0,diff --git a/manager_requirements.txt b/manager_requirements.txtnew file mode 100644index 000000000..52cc5389c--- /dev/null+++ b/manager_requirements.txt@@ -0,0 +1 @@+comfyui_manager==4.0.3b3diff --git a/nodes.py b/nodes.pyindex d5e5dc228..4c910a34b 100644--- a/nodes.py+++ b/nodes.py@@ -43,6 +43,9 @@ import folder_pathsimport latent_previewimport node_helpers+if args.enable_manager:+ import comfyui_manager+def before_node_execution():comfy.model_management.throw_exception_if_processing_interrupted()@@ -2243,6 +2246,12 @@ async def init_external_custom_nodes():if args.disable_all_custom_nodes and possible_module not in args.whitelist_custom_nodes:logging.info(f"Skipping {possible_module} due to disable_all_custom_nodes and whitelist_custom_nodes")continue++ if args.enable_manager:+ if comfyui_manager.should_be_disabled(module_path):+ logging.info(f"Blocked by policy: {module_path}")+ continue+time_before = time.perf_counter()success = await load_custom_node(module_path, base_node_names, module_parent="custom_nodes")node_import_times.append((time.perf_counter() - time_before, module_path, success))diff --git a/server.py b/server.pyindex fca5050bd..e3bd056d9 100644--- a/server.py+++ b/server.py@@ -44,6 +44,9 @@ from protocol import BinaryEventTypes# Import cache control middlewarefrom middleware.cache_middleware import cache_control+if args.enable_manager:+ import comfyui_manager+async def send_socket_catch_exception(function, message):try:await function(message)@@ -212,6 +215,9 @@ class PromptServer():if args.disable_api_nodes:middlewares.append(create_block_external_middleware())+ if args.enable_manager:+ middlewares.append(comfyui_manager.create_middleware())+max_upload_size = round(args.max_upload_size * 1024 * 1024)self.app = web.Application(client_max_size=max_upload_size, middlewares=middlewares)self.sockets = dict()@@ -599,7 +605,7 @@ class PromptServer():system_stats = {"system": {- "os": os.name,+ "os": sys.platform,"ram_total": ram_total,"ram_free": ram_free,"comfyui_version": __version__,