feat: config.ini - network_mode is added.

- public | private | offline

https://github.com/ltdrdata/ComfyUI-Manager/issues/1537
This commit is contained in:
Dr.Lt.Data 2025-02-13 08:24:54 +09:00
parent cc746e59a1
commit 5b2e2fcf9d
4 changed files with 74 additions and 38 deletions

View File

@ -262,10 +262,17 @@ The following settings are applied based on the section marked as `is_default`.
windows_selector_event_loop_policy = <If an event loop error occurs on Windows, set this to True.>
model_download_by_agent = <When downloading models, use an agent instead of torchvision_download_url.>
downgrade_blacklist = <Set a list of packages to prevent downgrades. List them separated by commas.>
security_level = <Set the security level.>
security_level = <Set the security level => strong|normal|normal-|weak>
always_lazy_install = <Whether to perform dependency installation on restart even in environments other than Windows.>
network_mode = <Set the network mode => public|private|offline>
```
* network_mode:
- public: An environment that uses a typical public network.
- private: An environment that uses a closed network, where a private node DB is configured via `channel_url`. (Uses cache if available)
- offline: An environment that does not use any external connections when using an offline network. (Uses cache if available)
## Additional Feature
* Logging to file feature
* This feature is enabled by default and can be disabled by setting `file_logging = False` in the `config.ini`.

View File

@ -42,7 +42,7 @@ import manager_downloader
from node_package import InstalledNodePackage
version_code = [3, 18, 1]
version_code = [3, 19]
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
@ -695,6 +695,9 @@ class UnifiedManager:
self.unknown_active_nodes = {} # node_id -> repo url * fullpath
self.active_nodes = {} # node_id -> node_version * fullpath
if get_config()['network_mode'] != 'public':
dont_wait = True
# reload 'cnr_map' and 'repo_cnr_map'
cnrs = await cnr_utils.get_cnr_data(cache_mode=cache_mode=='cache', dont_wait=dont_wait)
@ -1548,6 +1551,7 @@ manager_funcs = ManagerFuncs()
def write_config():
config = configparser.ConfigParser()
config['default'] = {
'preview_method': manager_funcs.get_current_preview_method(),
'git_exe': get_config()['git_exe'],
@ -1562,7 +1566,8 @@ def write_config():
'downgrade_blacklist': get_config()['downgrade_blacklist'],
'security_level': get_config()['security_level'],
'skip_migration_check': get_config()['skip_migration_check'],
'always_lazy_install': get_config()['always_lazy_install']
'always_lazy_install': get_config()['always_lazy_install'],
'network_mode': get_config()['network_mode']
}
directory = os.path.dirname(manager_config_path)
@ -1590,26 +1595,31 @@ def read_config():
manager_util.use_uv = default_conf['use_uv'].lower() == 'true' if 'use_uv' in default_conf else False
def get_bool(key, default_value):
return default_conf[key].lower() == 'true' if key in default_conf else False
return {
'http_channel_enabled': default_conf['http_channel_enabled'].lower() == 'true' if 'http_channel_enabled' in default_conf else False,
'preview_method': default_conf['preview_method'] if 'preview_method' in default_conf else manager_funcs.get_current_preview_method(),
'git_exe': default_conf['git_exe'] if 'git_exe' in default_conf else '',
'use_uv': default_conf['use_uv'].lower() == 'true' if 'use_uv' in default_conf else False,
'channel_url': default_conf['channel_url'] if 'channel_url' in default_conf else DEFAULT_CHANNEL,
'default_cache_as_channel_url': default_conf['default_cache_as_channel_url'].lower() == 'true' if 'default_cache_as_channel_url' in default_conf else False,
'share_option': default_conf['share_option'] if 'share_option' in default_conf else 'all',
'bypass_ssl': default_conf['bypass_ssl'].lower() == 'true' if 'bypass_ssl' in default_conf else False,
'file_logging': default_conf['file_logging'].lower() == 'true' if 'file_logging' in default_conf else True,
'component_policy': default_conf['component_policy'] if 'component_policy' in default_conf else 'workflow',
'windows_selector_event_loop_policy': default_conf['windows_selector_event_loop_policy'].lower() == 'true' if 'windows_selector_event_loop_policy' in default_conf else False,
'model_download_by_agent': default_conf['model_download_by_agent'].lower() == 'true' if 'model_download_by_agent' in default_conf else False,
'downgrade_blacklist': default_conf['downgrade_blacklist'] if 'downgrade_blacklist' in default_conf else '',
'skip_migration_check': default_conf['skip_migration_check'].lower() == 'true' if 'skip_migration_check' in default_conf else False,
'always_lazy_install': default_conf['always_lazy_install'].lower() == 'true' if 'always_lazy_install' in default_conf else False,
'http_channel_enabled': get_bool('http_channel_enabled', False),
'preview_method': default_conf.get('preview_method', manager_funcs.get_current_preview_method()),
'git_exe': default_conf.get('git_exe', ''),
'use_uv': get_bool('use_uv', False),
'channel_url': default_conf.get('channel_url', DEFAULT_CHANNEL),
'default_cache_as_channel_url': get_bool('default_cache_as_channel_url', False),
'share_option': default_conf.get('share_option', 'all'),
'bypass_ssl': get_bool('bypass_ssl', False),
'file_logging': get_bool('file_logging', True),
'component_policy': default_conf.get('component_policy', 'workflow'),
'windows_selector_event_loop_policy': get_bool('windows_selector_event_loop_policy', False),
'model_download_by_agent': get_bool('model_download_by_agent', False),
'downgrade_blacklist': default_conf.get('downgrade_blacklist', ''),
'skip_migration_check': get_bool('skip_migration_check', False),
'always_lazy_install': get_bool('always_lazy_install', False),
'network_mode': default_conf.get('network_mode', 'public'),
'security_level': security_level,
}
except Exception:
traceback.print_exc()
manager_util.use_uv = False
return {
'http_channel_enabled': False,
@ -1627,7 +1637,8 @@ def read_config():
'downgrade_blacklist': '',
'skip_migration_check': False,
'always_lazy_install': False,
'security_level': 'normal',
'network_mode': 'public', # public | private | offline
'security_level': 'normal', # strong | normal | normal- | weak
}
@ -2085,9 +2096,10 @@ async def get_data_by_mode(mode, filename, channel_url=None):
channel_url = get_channel_dict()[channel_url]
try:
local_uri = os.path.join(manager_util.comfyui_manager_path, filename)
if mode == "local":
uri = os.path.join(manager_util.comfyui_manager_path, filename)
json_obj = await manager_util.get_data(uri)
json_obj = await manager_util.get_data(local_uri)
else:
if channel_url is None:
uri = get_config()['channel_url'] + '/' + filename
@ -2097,6 +2109,18 @@ async def get_data_by_mode(mode, filename, channel_url=None):
cache_uri = str(manager_util.simple_hash(uri))+'_'+filename
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
if get_config()['network_mode'] == 'offline':
# offline network mode
if os.path.exists(cache_uri):
json_obj = await manager_util.get_data(cache_uri)
else:
local_uri = os.path.join(manager_util.comfyui_manager_path, filename)
if os.path.exists(local_uri):
json_obj = await manager_util.get_data(local_uri)
else:
json_obj = {} # fallback
else:
# public network mode
if mode == "cache" and manager_util.is_file_created_within_one_day(cache_uri):
json_obj = await manager_util.get_data(cache_uri)
else:

View File

@ -25,6 +25,7 @@ import manager_downloader
logging.info(f"### Loading: ComfyUI-Manager ({core.version_str})")
logging.info("[ComfyUI-Manager] network_mode: " + core.get_config()['network_mode'])
comfy_ui_hash = "-"
comfyui_tag = None
@ -171,7 +172,7 @@ def set_preview_method(method):
else:
args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews
core.get_config()['preview_method'] = args.preview_method
core.get_config()['preview_method'] = method
set_preview_method(core.get_config()['preview_method'])
@ -1619,6 +1620,7 @@ async def default_cache_update():
json.dump(json_obj, file, indent=4, sort_keys=True)
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
if core.get_config()['network_mode'] != 'offline':
a = get_cache("custom-node-list.json")
b = get_cache("extension-node-map.json")
c = get_cache("model-list.json")
@ -1627,6 +1629,9 @@ async def default_cache_update():
await asyncio.gather(a, b, c, d, e)
if core.get_config()['network_mode'] == 'private':
logging.info("[ComfyUI-Manager] The private comfyregistry is not yet supported in `network_mode=private`.")
else:
# load at least once
await core.unified_manager.reload('remote', dont_wait=False)
await core.unified_manager.get_custom_nodes(channel_url, 'remote')

View File

@ -1,7 +1,7 @@
[project]
name = "comfyui-manager"
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
version = "3.18.1"
version = "3.19"
license = { file = "LICENSE.txt" }
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]