Skip to content

Commit

Permalink
Handle old ComfyUI versions
Browse files Browse the repository at this point in the history
  • Loading branch information
asagi4 committed Dec 5, 2024
1 parent acf38ad commit e425482
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PCPromptFromSchedule,
)
from .prompt_control.node_aio import PromptControlSimple
from .prompt_control.node_hooks import PCLoraHooksFromSchedule, PCEncodeSchedule


log = logging.getLogger("comfyui-prompt-control")
log.propagate = False
Expand All @@ -27,6 +27,21 @@
else:
log.setLevel(logging.INFO)

import importlib

if importlib.util.find_spec("comfy.hooks"):
from .prompt_control.node_hooks import PCLoraHooksFromSchedule, PCEncodeSchedule

maps = {
"PCLoraHooksFromSchedule": PCLoraHooksFromSchedule,
"PCEncodeSchedule": PCEncodeSchedule,
}
else:
log.warning(
"Your ComfyUI version is too old, can't import comfy.hooks for PCEncodeSchedule and PCLoraHooksFromSchedule. Update your installation."
)
maps = {}

sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))


Expand All @@ -44,6 +59,6 @@
"ScheduleToModel": ScheduleToModel,
"EditableCLIPEncode": EditableCLIPEncode,
"LoRAScheduler": LoRAScheduler,
"PCLoraHooksFromSchedule": PCLoraHooksFromSchedule,
"PCEncodeSchedule": PCEncodeSchedule,
}

NODE_CLASS_MAPPINGS.update(maps)

0 comments on commit e425482

Please sign in to comment.