Closed whmc76 closed 8 months ago
MathExpression used extra_pnginfo at evaluate method, it's a hidden prpperty, but comfyflowapp executing context doesn't include the extra_pnginfo (in order to keep workflow data safty)
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"expression": ("STRING", {"multiline": True, "dynamicPrompts": False, "pysssss.autocomplete": {
"words": autocompleteWords,
"separator": ""
}}),
},
"optional": {
"a": ("INT,FLOAT,IMAGE,LATENT", ),
"b": ("INT,FLOAT,IMAGE,LATENT",),
"c": ("INT,FLOAT,IMAGE,LATENT", ),
},
"hidden": {"extra_pnginfo": "EXTRA_PNGINFO",
"prompt": "PROMPT"},
}
def evaluate(self, expression, extra_pnginfo, prompt, a=None, b=None, c=None):
expression = expression.replace('\n', ' ').replace('\r', '')
node = ast.parse(expression, mode='eval').body
lookup = {"a": a, "b": b, "c": c}
def eval_expr(node):
....
elif isinstance(node, ast.Attribute):
if node.value.id in lookup:
if node.attr == "width" or node.attr == "height":
return self.get_size(lookup[node.value.id], node.attr)
return self.get_widget_value(extra_pnginfo, prompt, node.value.id, node.attr)
....
maybe you could use was Number Operations instead
i have add an issue to ComfyUI-Custom-Scripts https://github.com/pythongosssss/ComfyUI-Custom-Scripts/issues/141
MathExpression used extra_pnginfo at evaluate method, it's a hidden prpperty, but comfyflowapp executing context doesn't include the extra_pnginfo (in order to keep workflow data safty)
@classmethod def INPUT_TYPES(cls): return { "required": { "expression": ("STRING", {"multiline": True, "dynamicPrompts": False, "pysssss.autocomplete": { "words": autocompleteWords, "separator": "" }}), }, "optional": { "a": ("INT,FLOAT,IMAGE,LATENT", ), "b": ("INT,FLOAT,IMAGE,LATENT",), "c": ("INT,FLOAT,IMAGE,LATENT", ), }, "hidden": {"extra_pnginfo": "EXTRA_PNGINFO", "prompt": "PROMPT"}, } def evaluate(self, expression, extra_pnginfo, prompt, a=None, b=None, c=None): expression = expression.replace('\n', ' ').replace('\r', '') node = ast.parse(expression, mode='eval').body lookup = {"a": a, "b": b, "c": c} def eval_expr(node): .... elif isinstance(node, ast.Attribute): if node.value.id in lookup: if node.attr == "width" or node.attr == "height": return self.get_size(lookup[node.value.id], node.attr) return self.get_widget_value(extra_pnginfo, prompt, node.value.id, node.attr) ....
that is reasonable, but using other nodes will make the process ugly. Of course, their amount of computation should be the same in the background
ERROR:root:Traceback (most recent call last): File "E:\IMAGE\ComfyUI_windows_portable\ComfyUI\execution.py", line 153, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\IMAGE\ComfyUI_windows_portable\ComfyUI\execution.py", line 83, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\IMAGE\ComfyUI_windows_portable\ComfyUI\execution.py", line 76, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: MathExpression.evaluate() missing 1 required positional argument: 'extra_pnginfo'