diff --git a/comfy/cli_args.py b/comfy/cli_args.py index cc1f12482e9..9cc6b712fee 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -120,6 +120,12 @@ class LatentPreviewMethod(enum.Enum): upcast.add_argument("--dont-upcast-attention", action="store_true", help="Disable all upcasting of attention. Should be unnecessary except for debugging.") +manager_group = parser.add_mutually_exclusive_group() +manager_group.add_argument("--disable-manager", action="store_true", help="Completely disable the ComfyUI-Manager feature.") +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.") @@ -164,6 +170,7 @@ class PerformanceFeature(enum.Enum): parser.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.py index 0d4389a6e9e..bfb77eb5fa1 100644 --- a/comfy_api/feature_flags.py +++ b/comfy_api/feature_flags.py @@ -13,6 +13,7 @@ SERVER_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.py index c33f0e17bf3..341b267173f 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,22 @@ from comfy_execution.utils import get_executing_context from comfy_api import feature_flags + +def handle_comfyui_manager_unavailable(): + 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.disable_manager = True + + +if not args.disable_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() + + if __name__ == "__main__": #NOTE: These do not do anything on core ComfyUI, they are for custom nodes. os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1' @@ -79,6 +95,11 @@ def execute_script(script_path): for possible_module in possible_modules: module_path = os.path.join(custom_node_path, possible_module) + + if not args.disable_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 +122,10 @@ def execute_script(script_path): logging.info("") apply_custom_paths() + +if not args.disable_manager: + comfyui_manager.prestartup() + execute_prestartup_script() @@ -312,6 +337,9 @@ def start_comfyui(asyncio_loop=None): asyncio.set_event_loop(asyncio_loop) prompt_server = server.PromptServer(asyncio_loop) + if not args.disable_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/nodes.py b/nodes.py index 5a5fdcb8ee4..9bd3b4dcffd 100644 --- a/nodes.py +++ b/nodes.py @@ -43,6 +43,9 @@ import latent_preview import node_helpers +if not args.disable_manager: + import comfyui_manager + def before_node_execution(): comfy.model_management.throw_exception_if_processing_interrupted() @@ -2230,6 +2233,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 not args.disable_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/requirements.txt b/requirements.txt index de5af5facc1..d25fcebe2c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ comfyui-frontend-package==1.26.11 comfyui-workflow-templates==0.1.81 comfyui-embedded-docs==0.2.6 +comfyui_manager==4.0.1 torch torchsde torchvision diff --git a/server.py b/server.py index 43816a8cd8b..df6138639a4 100644 --- a/server.py +++ b/server.py @@ -42,6 +42,9 @@ # Import cache control middleware from middleware.cache_middleware import cache_control +if not args.disable_manager: + import comfyui_manager + async def send_socket_catch_exception(function, message): try: await function(message) @@ -168,6 +171,9 @@ def __init__(self, loop): else: middlewares.append(create_origin_only_middleware()) + if not args.disable_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() @@ -553,7 +559,7 @@ async def system_stats(request): system_stats = { "system": { - "os": os.name, + "os": sys.platform, "ram_total": ram_total, "ram_free": ram_free, "comfyui_version": __version__,