Update __init__.py

This commit is contained in:
WAS
2023-10-08 07:52:25 -07:00
committed by GitHub
parent 867fd34483
commit a11fbd190a
+25 -9
View File
@@ -1,39 +1,55 @@
import importlib
import traceback
import time
from cstr import cstr
#! MESSAGE TEMPLATES
cstr.color.add_code("msg", f"{cstr.color.LIGHTBLUE}WAS Extras: {cstr.color.END}")
cstr.color.add_code("warning", f"{cstr.color.LIGHTBLUE}WAS Extras {cstr.color.LIGHTYELLOW}Warning: {cstr.color.END}")
cstr.color.add_code("error", f"{cstr.color.LIGHTRED}WAS Extras {cstr.color.END}Error: {cstr.color.END}")
extras = [
".ConditioningBlend",
".DebugThis",
".VAEEncodeForInpaint",
".VividSharpen",
".ksampler_sequence"
]
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
module_timings = {}
print("[\033[94m\033[1mWAS Extras\033[0m] Loading extra custom nodes...")
cstr("Loading extra custom nodes...").msg.print()
for module_name in extras:
start_time = time.time()
success = True
error = None
try:
module = importlib.import_module(module_name, package=__name__)
except Exception:
except Exception as e:
error = e
success = False
pass
traceback.print_exc()
end_time = time.time()
timing = end_time - start_time
module_timings[module.__file__] = (timing, success)
if success:
module_timings[module.__file__] = (timing, success, error)
NODE_CLASS_MAPPINGS.update(getattr(module, 'NODE_CLASS_MAPPINGS', {}))
NODE_DISPLAY_NAME_MAPPINGS.update(getattr(module, 'NODE_DISPLAY_NAME_MAPPINGS', {}))
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
print("[\033[94m\033[1mWAS Extras\033[0m] Import times for extras:")
for module, (timing, success) in module_timings.items():
cstr("Import times for extras:").msg.print()
for module, (timing, success, error) in module_timings.items():
print(f" {timing:.1f} seconds{('' if success else ' (IMPORT FAILED)')}: {module}")
if error:
print("Error:", error)