mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-17 10:22:59 +08:00
fixed: use pyproject.toml if desktop version
- desktop version doesn't contains .git modified: don't cache the sub fetched data of cnr
This commit is contained in:
parent
d649ca47c6
commit
f406d728cc
@ -35,16 +35,21 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
|||||||
page = 1
|
page = 1
|
||||||
|
|
||||||
full_nodes = {}
|
full_nodes = {}
|
||||||
|
|
||||||
# Get ComfyUI version tag
|
|
||||||
comfyui_tag = manager_core.get_comfyui_tag() or 'unknown'
|
|
||||||
|
|
||||||
# Determine form factor based on environment and platform
|
# Determine form factor based on environment and platform
|
||||||
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
|
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
|
||||||
system = platform.system().lower()
|
system = platform.system().lower()
|
||||||
is_windows = system == 'windows'
|
is_windows = system == 'windows'
|
||||||
is_mac = system == 'darwin'
|
is_mac = system == 'darwin'
|
||||||
|
|
||||||
|
# Get ComfyUI version tag
|
||||||
|
if is_desktop:
|
||||||
|
# extract version from pyproject.toml instead of git tag
|
||||||
|
comfyui_ver = manager_core.get_current_comfyui_ver() or 'unknown'
|
||||||
|
else:
|
||||||
|
comfyui_ver = manager_core.get_comfyui_tag() or 'unknown'
|
||||||
|
|
||||||
if is_desktop:
|
if is_desktop:
|
||||||
if is_windows:
|
if is_windows:
|
||||||
form_factor = 'desktop-win'
|
form_factor = 'desktop-win'
|
||||||
@ -62,8 +67,8 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
|||||||
|
|
||||||
while remained:
|
while remained:
|
||||||
# Add comfyui_version and form_factor to the API request
|
# Add comfyui_version and form_factor to the API request
|
||||||
sub_uri = f'{base_url}/nodes?page={page}&limit=30&comfyui_version={comfyui_tag}&form_factor={form_factor}'
|
sub_uri = f'{base_url}/nodes?page={page}&limit=30&comfyui_version={comfyui_ver}&form_factor={form_factor}'
|
||||||
sub_json_obj = await asyncio.wait_for(manager_util.get_data_with_cache(sub_uri, cache_mode=False, silent=True), timeout=30)
|
sub_json_obj = await asyncio.wait_for(manager_util.get_data_with_cache(sub_uri, cache_mode=False, silent=True, dont_cache=True), timeout=30)
|
||||||
remained = page < sub_json_obj['totalPages']
|
remained = page < sub_json_obj['totalPages']
|
||||||
|
|
||||||
for x in sub_json_obj['nodes']:
|
for x in sub_json_obj['nodes']:
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import yaml
|
|||||||
import zipfile
|
import zipfile
|
||||||
import traceback
|
import traceback
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
|
import toml
|
||||||
|
|
||||||
orig_print = print
|
orig_print = print
|
||||||
|
|
||||||
@ -81,6 +82,24 @@ def get_comfyui_tag():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_current_comfyui_ver():
|
||||||
|
"""
|
||||||
|
Extract version from pyproject.toml
|
||||||
|
"""
|
||||||
|
toml_path = os.path.join(comfy_path, 'pyproject.toml')
|
||||||
|
if not os.path.exists(toml_path):
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
with open(toml_path, "r", encoding="utf-8") as f:
|
||||||
|
data = toml.load(f)
|
||||||
|
|
||||||
|
project = data.get('project', {})
|
||||||
|
return project.get('version')
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_script_env():
|
def get_script_env():
|
||||||
new_env = os.environ.copy()
|
new_env = os.environ.copy()
|
||||||
git_exe = get_config().get('git_exe')
|
git_exe = get_config().get('git_exe')
|
||||||
@ -154,7 +173,7 @@ def check_invalid_nodes():
|
|||||||
|
|
||||||
|
|
||||||
# read env vars
|
# read env vars
|
||||||
comfy_path = os.environ.get('COMFYUI_PATH')
|
comfy_path: str = os.environ.get('COMFYUI_PATH')
|
||||||
comfy_base_path = os.environ.get('COMFYUI_FOLDERS_BASE_PATH')
|
comfy_base_path = os.environ.get('COMFYUI_FOLDERS_BASE_PATH')
|
||||||
|
|
||||||
if comfy_path is None:
|
if comfy_path is None:
|
||||||
|
|||||||
@ -180,7 +180,7 @@ def save_to_cache(uri, json_obj, silent=False):
|
|||||||
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
|
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
|
||||||
|
|
||||||
|
|
||||||
async def get_data_with_cache(uri, silent=False, cache_mode=True, dont_wait=False):
|
async def get_data_with_cache(uri, silent=False, cache_mode=True, dont_wait=False, dont_cache=False):
|
||||||
cache_uri = get_cache_path(uri)
|
cache_uri = get_cache_path(uri)
|
||||||
|
|
||||||
if cache_mode and dont_wait:
|
if cache_mode and dont_wait:
|
||||||
@ -199,11 +199,12 @@ async def get_data_with_cache(uri, silent=False, cache_mode=True, dont_wait=Fals
|
|||||||
json_obj = await get_data(cache_uri, silent=silent)
|
json_obj = await get_data(cache_uri, silent=silent)
|
||||||
else:
|
else:
|
||||||
json_obj = await get_data(uri, silent=silent)
|
json_obj = await get_data(uri, silent=silent)
|
||||||
with cache_lock:
|
if not dont_cache:
|
||||||
with open(cache_uri, "w", encoding='utf-8') as file:
|
with cache_lock:
|
||||||
json.dump(json_obj, file, indent=4, sort_keys=True)
|
with open(cache_uri, "w", encoding='utf-8') as file:
|
||||||
if not silent:
|
json.dump(json_obj, file, indent=4, sort_keys=True)
|
||||||
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
|
if not silent:
|
||||||
|
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
|
||||||
|
|
||||||
return json_obj
|
return json_obj
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user