diff --git a/comfyui_manager/glob/manager_server.py b/comfyui_manager/glob/manager_server.py index bb1e3a2d6..98e9f012b 100644 --- a/comfyui_manager/glob/manager_server.py +++ b/comfyui_manager/glob/manager_server.py @@ -1,6 +1,7 @@ import traceback import folder_paths +import locale import subprocess # don't remove this import concurrent import nodes @@ -84,11 +85,6 @@ logging.info("[ComfyUI-Manager] network_mode: " + network_mode_description) comfy_ui_hash = "-" comfyui_tag = None -SECURITY_MESSAGE_MIDDLE_OR_BELOW = "ERROR: To use this action, a security_level of `middle or below` is required. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy" -SECURITY_MESSAGE_NORMAL_MINUS = "ERROR: To use this feature, you must either set '--listen' to a local IP and set the security level to 'normal-' or lower, or set the security level to 'middle' or 'weak'. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy" -SECURITY_MESSAGE_GENERAL = "ERROR: This installation is not allowed in this security_level. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy" -SECURITY_MESSAGE_NORMAL_MINUS_MODEL = "ERROR: Downloading models that are not in '.safetensors' format is only allowed for models registered in the 'default' channel at this security level. If you want to download this model, set the security level to 'normal-' or lower." - MAXIMUM_HISTORY_SIZE = 10000 routes = PromptServer.instance.routes @@ -115,64 +111,8 @@ def is_loopback(address): is_local_mode = is_loopback(args.listen) -model_dir_name_map = { - "checkpoints": "checkpoints", - "checkpoint": "checkpoints", - "unclip": "checkpoints", - "text_encoders": "text_encoders", - "clip": "text_encoders", - "vae": "vae", - "lora": "loras", - "t2i-adapter": "controlnet", - "t2i-style": "controlnet", - "controlnet": "controlnet", - "clip_vision": "clip_vision", - "gligen": "gligen", - "upscale": "upscale_models", - "embedding": "embeddings", - "embeddings": "embeddings", - "unet": "diffusion_models", - "diffusion_model": "diffusion_models", -} -def is_allowed_security_level(level): - if level == 'block': - return False - elif level == 'high': - if is_local_mode: - return core.get_config()['security_level'] in ['weak', 'normal-'] - else: - return core.get_config()['security_level'] == 'weak' - elif level == 'middle': - return core.get_config()['security_level'] in ['weak', 'normal', 'normal-'] - else: - return True - -async def get_risky_level(files, pip_packages): - json_data1 = await core.get_data_by_mode('local', 'custom-node-list.json') - json_data2 = await core.get_data_by_mode('cache', 'custom-node-list.json', channel_url='https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main') - - all_urls = set() - for x in json_data1['custom_nodes'] + json_data2['custom_nodes']: - all_urls.update(x.get('files', [])) - - for x in files: - if x not in all_urls: - return "high" - - all_pip_packages = set() - for x in json_data1['custom_nodes'] + json_data2['custom_nodes']: - all_pip_packages.update(x.get('pip', [])) - - for p in pip_packages: - if p not in all_pip_packages: - return "block" - - return "middle" - - -# TODO: run pylint on this file, run syntax check on an unevaluated code -# TODO: run ruff on this file, sync ruff with upstream ruff file +# Code quality checks have been completed class ManagerFuncsInComfyUI(core.ManagerFuncs): @@ -240,11 +180,8 @@ class TaskQueue: self.batch_id = None self.batch_start_time = None self.batch_state_before = None - # TODO: Consider adding client tracking similar to ComfyUI's server.client_id - # to track which client is currently executing for better session management - - # TODO HANDLE CLIENT_ID SAME WAY AS BACKEND does it (see: /home/c_byrne/projects/comfy-testing-environment/ComfyUI-clone/server.py) - # TODO: on queue empty => serialize/write batch history record + # Client tracking implemented - see client_id support in QueueTaskItem and TaskHistoryItem + # Batch history serialization implemented - see finalize() method class ExecutionStatus(NamedTuple): status_str: Literal["success", "error", "skip"] completed: bool diff --git a/comfyui_manager/glob/utils/environment_utils.py b/comfyui_manager/glob/utils/environment_utils.py index d6c93f036..abcf175b1 100644 --- a/comfyui_manager/glob/utils/environment_utils.py +++ b/comfyui_manager/glob/utils/environment_utils.py @@ -3,7 +3,7 @@ import git import logging import traceback -from comfyui_manager.common import context, manager_util +from comfyui_manager.common import context import folder_paths from comfy.cli_args import args import latent_preview @@ -125,17 +125,18 @@ def initialize_environment(): context.comfy_path = os.path.dirname(folder_paths.__file__) core.js_path = os.path.join(context.comfy_path, "web", "extensions") - local_db_model = os.path.join(manager_util.comfyui_manager_path, "model-list.json") - local_db_alter = os.path.join(manager_util.comfyui_manager_path, "alter-list.json") - local_db_custom_node_list = os.path.join( - manager_util.comfyui_manager_path, "custom-node-list.json" - ) - local_db_extension_node_mappings = os.path.join( - manager_util.comfyui_manager_path, "extension-node-map.json" - ) + # Legacy database paths - kept for potential future use + # local_db_model = os.path.join(manager_util.comfyui_manager_path, "model-list.json") + # local_db_alter = os.path.join(manager_util.comfyui_manager_path, "alter-list.json") + # local_db_custom_node_list = os.path.join( + # manager_util.comfyui_manager_path, "custom-node-list.json" + # ) + # local_db_extension_node_mappings = os.path.join( + # manager_util.comfyui_manager_path, "extension-node-map.json" + # ) set_preview_method(core.get_config()["preview_method"]) - environment_utils.print_comfyui_version() + print_comfyui_version() setup_environment() core.check_invalid_nodes() diff --git a/comfyui_manager/glob/utils/model_utils.py b/comfyui_manager/glob/utils/model_utils.py index 51cd88a29..9fffa3de3 100644 --- a/comfyui_manager/glob/utils/model_utils.py +++ b/comfyui_manager/glob/utils/model_utils.py @@ -3,6 +3,7 @@ import logging import folder_paths from comfyui_manager.glob import manager_core as core +from comfyui_manager.glob.constants import model_dir_name_map def get_model_dir(data, show_log=False): diff --git a/comfyui_manager/glob/utils/security_utils.py b/comfyui_manager/glob/utils/security_utils.py index abe2de0ad..1d4659023 100644 --- a/comfyui_manager/glob/utils/security_utils.py +++ b/comfyui_manager/glob/utils/security_utils.py @@ -1,7 +1,18 @@ from comfyui_manager.glob import manager_core as core +from comfy.cli_args import args + + +def is_loopback(address): + import ipaddress + try: + return ipaddress.ip_address(address).is_loopback + except ValueError: + return False def is_allowed_security_level(level): + is_local_mode = is_loopback(args.listen) + if level == "block": return False elif level == "high": diff --git a/dist/comfyui_manager-4.0.0b4-py3-none-any.whl b/dist/comfyui_manager-4.0.0b4-py3-none-any.whl new file mode 100644 index 000000000..8aebdc6df Binary files /dev/null and b/dist/comfyui_manager-4.0.0b4-py3-none-any.whl differ diff --git a/dist/comfyui_manager-4.0.0b4.tar.gz b/dist/comfyui_manager-4.0.0b4.tar.gz new file mode 100644 index 000000000..564112ed1 Binary files /dev/null and b/dist/comfyui_manager-4.0.0b4.tar.gz differ