Added DinkLink scaffolding

This commit is contained in:
Jedrzej Kosinski
2024-11-12 18:13:17 -06:00
parent 048e090146
commit c7aa168691
2 changed files with 38 additions and 0 deletions
+3
View File
@@ -1,6 +1,9 @@
from .adv_control.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
from .adv_control import documentation
from .adv_control.dinklink import init_dinklink
WEB_DIRECTORY = "./web"
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', "WEB_DIRECTORY"]
documentation.format_descriptions(NODE_CLASS_MAPPINGS)
init_dinklink()
+35
View File
@@ -0,0 +1,35 @@
####################################################################################################
# DinkLink is my method of sharing classes/functions between my nodes.
#
# My DinkLink-compatible nodes will inject comfy.hooks with a __DINKLINK attr
# that stores a dictionary, where any of my node packs can store their stuff.
#
# It is not intended to be accessed by node packs that I don't develop, so things may change
# at any time.
#
# DinkLink also serves as a proof-of-concept for a future ComfyUI implementation of
# purposely exposing node pack classes/functions with other node packs.
####################################################################################################
from __future__ import annotations
import comfy.hooks
from .sampling import acn_sampler_sample_wrapper
DINKLINK = "__DINKLINK"
def init_dinklink():
if not hasattr(comfy.hooks, DINKLINK):
setattr(comfy.hooks, DINKLINK, {})
prepare_dinklink()
def get_dinklink() -> dict[str, dict[str]]:
return getattr(comfy.hooks, DINKLINK)
class Consts:
ACN = "ACN"
CREATE_SAMPLER_SAMPLE_WRAPPER = "create_sampler_sample_wrapper"
def prepare_dinklink():
# expose acn_sampler_sample_wrapper
d = get_dinklink()
d.setdefault(Consts.ACN, {})[Consts.CREATE_SAMPLER_SAMPLE_WRAPPER] = None