Update ddm_nodes.py
This commit is contained in:
+7
-36
@@ -3,10 +3,8 @@ DDM Bundle - Set/Get Nodes for ComfyUI
|
||||
Clean workflow routing without spaghetti connections
|
||||
"""
|
||||
|
||||
# Global storage for values
|
||||
STORAGE = {}
|
||||
|
||||
# Wildcard type that accepts anything
|
||||
class AnyType(str):
|
||||
def __ne__(self, __value: object) -> bool:
|
||||
return False
|
||||
@@ -15,9 +13,6 @@ any_type = AnyType("*")
|
||||
|
||||
|
||||
class DDM_SetNode:
|
||||
"""
|
||||
Store any value with a unique identifier and pass it through.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -35,14 +30,10 @@ class DDM_SetNode:
|
||||
|
||||
def execute(self, value, id):
|
||||
STORAGE[id] = value
|
||||
print(f"✓ [DDM Set] Stored '{id}' successfully")
|
||||
return (value,)
|
||||
|
||||
|
||||
class DDM_GetNode:
|
||||
"""
|
||||
Retrieve a stored value by identifier.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -50,9 +41,6 @@ class DDM_GetNode:
|
||||
"required": {
|
||||
"id": ("STRING", {"default": "value"}),
|
||||
},
|
||||
"optional": {
|
||||
"default": (any_type,),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = (any_type,)
|
||||
@@ -61,33 +49,16 @@ class DDM_GetNode:
|
||||
CATEGORY = "DDM Bundle"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, id, default=None):
|
||||
def VALIDATE_INPUTS(cls, id):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, id):
|
||||
return float("nan")
|
||||
|
||||
def execute(self, id, default=None):
|
||||
print(f"→ [DDM Get] Attempting to retrieve '{id}'")
|
||||
print(f" Current storage: {list(STORAGE.keys())}")
|
||||
|
||||
def execute(self, id):
|
||||
if id not in STORAGE:
|
||||
if default is not None:
|
||||
print(f"⚠ [DDM Get] '{id}' not found, using default value")
|
||||
return (default,)
|
||||
else:
|
||||
error_msg = (
|
||||
f"\n{'='*60}\n"
|
||||
f"DDM Get Node Error: ID '{id}' not found!\n"
|
||||
f"Current storage: {list(STORAGE.keys())}\n\n"
|
||||
f"Troubleshooting:\n"
|
||||
f"1. Make sure there's a Set Node with id='{id}'\n"
|
||||
f"2. The Set Node OUTPUT must be connected to your workflow\n"
|
||||
f"3. The Set Node must lead to a final output node\n"
|
||||
f"4. Try adding a 'default' input to this Get Node as backup\n"
|
||||
f"{'='*60}\n"
|
||||
)
|
||||
print(error_msg)
|
||||
raise ValueError(error_msg)
|
||||
|
||||
print(f"✓ [DDM Get] Successfully retrieved '{id}'")
|
||||
raise ValueError(f"DDM Get Node Error: ID '{id}' not found in storage!")
|
||||
return (STORAGE[id],)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user