Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b93836c527 | ||
|
|
6177db9272 | ||
|
|
9c069c13c5 |
@@ -44,6 +44,9 @@ and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/spec/
|
||||
|
||||
### Fixed
|
||||
|
||||
- Report the `desktop-linux` form factor to the registry for Desktop installs
|
||||
on Linux, which previously reported `other`.
|
||||
|
||||
- aria2 does not download a file that is already there. With aria2 as the
|
||||
downloader, an install of a model whose file was already in its folder
|
||||
downloaded the model once more. aria2 saved the download next to the file
|
||||
|
||||
@@ -20,6 +20,29 @@ lock = asyncio.Lock()
|
||||
|
||||
is_cache_loading = False
|
||||
|
||||
def get_form_factor():
|
||||
"""Form factor reported to the registry, based on environment and platform."""
|
||||
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
|
||||
system = platform.system().lower()
|
||||
|
||||
if is_desktop:
|
||||
if system == 'windows':
|
||||
return 'desktop-win'
|
||||
if system == 'darwin':
|
||||
return 'desktop-mac'
|
||||
if system == 'linux':
|
||||
return 'desktop-linux'
|
||||
return 'other'
|
||||
|
||||
if system == 'windows':
|
||||
return 'git-windows'
|
||||
if system == 'darwin':
|
||||
return 'git-mac'
|
||||
if system == 'linux':
|
||||
return 'git-linux'
|
||||
return 'other'
|
||||
|
||||
|
||||
async def get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
try:
|
||||
return await _get_cnr_data(cache_mode, dont_wait)
|
||||
@@ -39,12 +62,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
full_nodes = {}
|
||||
|
||||
|
||||
# Determine form factor based on environment and platform
|
||||
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
|
||||
system = platform.system().lower()
|
||||
is_windows = system == 'windows'
|
||||
is_mac = system == 'darwin'
|
||||
is_linux = system == 'linux'
|
||||
|
||||
# Get ComfyUI version tag
|
||||
if is_desktop:
|
||||
@@ -53,22 +71,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
else:
|
||||
comfyui_ver = context.get_comfyui_tag() or 'unknown'
|
||||
|
||||
if is_desktop:
|
||||
if is_windows:
|
||||
form_factor = 'desktop-win'
|
||||
elif is_mac:
|
||||
form_factor = 'desktop-mac'
|
||||
else:
|
||||
form_factor = 'other'
|
||||
else:
|
||||
if is_windows:
|
||||
form_factor = 'git-windows'
|
||||
elif is_mac:
|
||||
form_factor = 'git-mac'
|
||||
elif is_linux:
|
||||
form_factor = 'git-linux'
|
||||
else:
|
||||
form_factor = 'other'
|
||||
form_factor = get_form_factor()
|
||||
|
||||
from comfyui_manager.glob import manager_core
|
||||
verbose = manager_core.get_config().get('verbose', False)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Form factor the CNR client reports to the registry."""
|
||||
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from _install_flags_testutil import import_context
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cnr_utils():
|
||||
import_context()
|
||||
from comfyui_manager.common import cnr_utils
|
||||
|
||||
return cnr_utils
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('system', 'desktop', 'expected'),
|
||||
[
|
||||
('Windows', True, 'desktop-win'),
|
||||
('Darwin', True, 'desktop-mac'),
|
||||
('Linux', True, 'desktop-linux'),
|
||||
('FreeBSD', True, 'other'),
|
||||
('Windows', False, 'git-windows'),
|
||||
('Darwin', False, 'git-mac'),
|
||||
('Linux', False, 'git-linux'),
|
||||
('FreeBSD', False, 'other'),
|
||||
],
|
||||
)
|
||||
def test_form_factor(cnr_utils, monkeypatch, system, desktop, expected):
|
||||
monkeypatch.setattr(cnr_utils.platform, 'system', lambda: system)
|
||||
if desktop:
|
||||
monkeypatch.setenv('__COMFYUI_DESKTOP_VERSION__', '1.0.0')
|
||||
else:
|
||||
monkeypatch.delenv('__COMFYUI_DESKTOP_VERSION__', raising=False)
|
||||
|
||||
assert cnr_utils.get_form_factor() == expected
|
||||
|
||||
|
||||
def test_the_registry_request_carries_the_form_factor(cnr_utils, monkeypatch):
|
||||
from comfyui_manager.glob import manager_core
|
||||
asked = []
|
||||
|
||||
async def get_data_with_cache(uri, **kwargs):
|
||||
asked.append(uri)
|
||||
return {'nodes': [], 'totalPages': 1}
|
||||
|
||||
monkeypatch.setattr(cnr_utils.manager_util, 'get_data_with_cache', get_data_with_cache)
|
||||
monkeypatch.setattr(cnr_utils.manager_util, 'save_to_cache', lambda uri, data: None)
|
||||
monkeypatch.setattr(manager_core, 'get_config', lambda: {})
|
||||
monkeypatch.setattr(cnr_utils.time, 'sleep', lambda seconds: None)
|
||||
monkeypatch.setattr(cnr_utils.platform, 'system', lambda: 'Linux')
|
||||
monkeypatch.setenv('__COMFYUI_DESKTOP_VERSION__', '1.0.0')
|
||||
|
||||
asyncio.run(cnr_utils._get_cnr_data(cache_mode=False))
|
||||
|
||||
assert [uri.partition('&form_factor=')[2] for uri in asked] == ['desktop-linux']
|
||||
Reference in New Issue
Block a user