Skip to content

Commit

Permalink
refactor: print -> logging
Browse files Browse the repository at this point in the history
fixed: log message - manager-core -> ComfyUI-Manager
  • Loading branch information
ltdrdata committed Jan 15, 2025
1 parent f63205f commit 34151b0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion glob/manager_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from node_package import InstalledNodePackage


version_code = [3, 7, 4]
version_code = [3, 7, 5]
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')


Expand Down
40 changes: 21 additions & 19 deletions glob/manager_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def get_data(uri, silent=False):
json_obj = json.loads(json_text)

if not silent:
print(" [DONE]")
logging.info(" [DONE]")

return json_obj

Expand Down Expand Up @@ -154,7 +154,7 @@ async def get_data_with_cache(uri, silent=False, cache_mode=True, dont_wait=Fals
with open(cache_uri, "w", encoding='utf-8') as file:
json.dump(json_obj, file, indent=4, sort_keys=True)
if not silent:
print(f"[ComfyUI-Manager] default cache updated: {uri}")
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")

return json_obj

Expand All @@ -169,10 +169,10 @@ def extract_package_as_zip(file_path, extract_path):
with zipfile.ZipFile(file_path, "r") as zip_ref:
zip_ref.extractall(extract_path)
extracted_files = zip_ref.namelist()
print(f"Extracted zip file to {extract_path}")
logging.info(f"Extracted zip file to {extract_path}")
return extracted_files
except zipfile.BadZipFile:
print(f"File '{file_path}' is not a zip or is corrupted.")
logging.error(f"File '{file_path}' is not a zip or is corrupted.")
return None


Expand All @@ -196,7 +196,7 @@ def get_installed_packages(renew=False):

pip_map[y[0]] = y[1]
except subprocess.CalledProcessError:
print("[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
logging.error("[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
return set()

return pip_map
Expand Down Expand Up @@ -236,7 +236,7 @@ def torch_rollback(self):
else:
cmd = [sys.executable, '-m', 'pip', 'install', '--force', 'torch', 'torchvision', 'torchaudio']
subprocess.check_output(cmd, universal_newlines=True)
print(cmd)
logging.error(cmd)
return

torch_ver = StrictVersion(spec[0])
Expand All @@ -247,12 +247,12 @@ def torch_rollback(self):
cmd = [sys.executable, '-m', 'pip', 'install', '--pre',
'torch', 'torchvision', 'torchaudio',
'--index-url', f"https://download.pytorch.org/whl/nightly/{platform}"]
print("[manager-core] restore PyTorch to nightly version")
logging.info("[ComfyUI-Manager] restore PyTorch to nightly version")
else:
cmd = [sys.executable, '-m', 'pip', 'install',
f'torch=={torch_ver}', f'torchvision=={torchvision_ver}', f"torchaudio=={torch_ver}",
'--index-url', f"https://download.pytorch.org/whl/{platform}"]
print(f"[manager-core] restore PyTorch to {torch_ver}+{platform}")
logging.info(f"[ComfyUI-Manager] restore PyTorch to {torch_ver}+{platform}")

subprocess.check_output(cmd, universal_newlines=True)

Expand All @@ -265,20 +265,22 @@ def fix_broken(self):
cmd = [sys.executable, '-m', 'pip', 'uninstall', 'comfy']
subprocess.check_output(cmd, universal_newlines=True)

print("[manager-core] 'comfy' python package is uninstalled.\nWARN: The 'comfy' package is completely unrelated to ComfyUI and should never be installed as it causes conflicts with ComfyUI.")
logging.warning("[ComfyUI-Manager] 'comfy' python package is uninstalled.\nWARN: The 'comfy' package is completely unrelated to ComfyUI and should never be installed as it causes conflicts with ComfyUI.")
except Exception as e:
print("[manager-core] Failed to uninstall `comfy` python package")
print(e)
logging.error("[ComfyUI-Manager] Failed to uninstall `comfy` python package")
logging.error(e)

# fix torch - reinstall torch packages if version is changed
try:
if self.prev_pip_versions['torch'] != new_pip_versions['torch'] \
if 'torch' not in self.prev_pip_versions or 'torchvision' not in self.prev_pip_versions or 'torchaudio' not in self.prev_pip_versions:
logging.error(f"[ComfyUI-Manager] PyTorch is not installed")
elif self.prev_pip_versions['torch'] != new_pip_versions['torch'] \
or self.prev_pip_versions['torchvision'] != new_pip_versions['torchvision'] \
or self.prev_pip_versions['torchaudio'] != new_pip_versions['torchaudio']:
self.torch_rollback()
except Exception as e:
print("[manager-core] Failed to restore PyTorch")
print(e)
logging.error("[ComfyUI-Manager] Failed to restore PyTorch")
logging.error(e)

# fix opencv
try:
Expand Down Expand Up @@ -309,10 +311,10 @@ def fix_broken(self):
cmd = [sys.executable, '-m', 'pip', 'install', f"{x}=={versions[0].version_string}"]
subprocess.check_output(cmd, universal_newlines=True)

print(f"[manager-core] 'opencv' dependencies were fixed: {targets}")
logging.info(f"[ComfyUI-Manager] 'opencv' dependencies were fixed: {targets}")
except Exception as e:
print("[manager-core] Failed to restore opencv")
print(e)
logging.error("[ComfyUI-Manager] Failed to restore opencv")
logging.error(e)

# fix numpy
try:
Expand All @@ -321,8 +323,8 @@ def fix_broken(self):
if StrictVersion(np) >= StrictVersion('2'):
subprocess.check_output([sys.executable, '-m', 'pip', 'install', "numpy<2"], universal_newlines=True)
except Exception as e:
print("[manager-core] Failed to restore numpy")
print(e)
logging.error("[ComfyUI-Manager] Failed to restore numpy")
logging.error(e)


def sanitize(data):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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.7.4"
version = "3.7.5"
license = { file = "LICENSE.txt" }
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]

Expand Down

0 comments on commit 34151b0

Please sign in to comment.