Skip to content

Commit 34151b0

Browse files
committed
refactor: print -> logging
fixed: log message - manager-core -> ComfyUI-Manager
1 parent f63205f commit 34151b0

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

glob/manager_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from node_package import InstalledNodePackage
4242

4343

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

4747

glob/manager_util.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async def get_data(uri, silent=False):
125125
json_obj = json.loads(json_text)
126126

127127
if not silent:
128-
print(" [DONE]")
128+
logging.info(" [DONE]")
129129

130130
return json_obj
131131

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

159159
return json_obj
160160

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

178178

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

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

202202
return pip_map
@@ -236,7 +236,7 @@ def torch_rollback(self):
236236
else:
237237
cmd = [sys.executable, '-m', 'pip', 'install', '--force', 'torch', 'torchvision', 'torchaudio']
238238
subprocess.check_output(cmd, universal_newlines=True)
239-
print(cmd)
239+
logging.error(cmd)
240240
return
241241

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

257257
subprocess.check_output(cmd, universal_newlines=True)
258258

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

268-
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.")
268+
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.")
269269
except Exception as e:
270-
print("[manager-core] Failed to uninstall `comfy` python package")
271-
print(e)
270+
logging.error("[ComfyUI-Manager] Failed to uninstall `comfy` python package")
271+
logging.error(e)
272272

273273
# fix torch - reinstall torch packages if version is changed
274274
try:
275-
if self.prev_pip_versions['torch'] != new_pip_versions['torch'] \
275+
if 'torch' not in self.prev_pip_versions or 'torchvision' not in self.prev_pip_versions or 'torchaudio' not in self.prev_pip_versions:
276+
logging.error(f"[ComfyUI-Manager] PyTorch is not installed")
277+
elif self.prev_pip_versions['torch'] != new_pip_versions['torch'] \
276278
or self.prev_pip_versions['torchvision'] != new_pip_versions['torchvision'] \
277279
or self.prev_pip_versions['torchaudio'] != new_pip_versions['torchaudio']:
278280
self.torch_rollback()
279281
except Exception as e:
280-
print("[manager-core] Failed to restore PyTorch")
281-
print(e)
282+
logging.error("[ComfyUI-Manager] Failed to restore PyTorch")
283+
logging.error(e)
282284

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

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

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

327329

328330
def sanitize(data):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-manager"
33
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
4-
version = "3.7.4"
4+
version = "3.7.5"
55
license = { file = "LICENSE.txt" }
66
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
77

0 commit comments

Comments
 (0)