mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-21 03:50:50 +08:00
Start of fixing combo type + allowing plugging into combo, need to finish validation code
This commit is contained in:
parent
55a2821f2e
commit
218b0fbd94
@ -6,6 +6,7 @@ import asyncio
|
|||||||
import inspect
|
import inspect
|
||||||
from comfy_execution.graph_utils import is_link, ExecutionBlocker
|
from comfy_execution.graph_utils import is_link, ExecutionBlocker
|
||||||
from comfy.comfy_types.node_typing import ComfyNodeABC, InputTypeDict, InputTypeOptions
|
from comfy.comfy_types.node_typing import ComfyNodeABC, InputTypeDict, InputTypeOptions
|
||||||
|
from comfy_api.latest import IO
|
||||||
|
|
||||||
# NOTE: ExecutionBlocker code got moved to graph_utils.py to prevent torch being imported too soon during unit tests
|
# NOTE: ExecutionBlocker code got moved to graph_utils.py to prevent torch being imported too soon during unit tests
|
||||||
ExecutionBlocker = ExecutionBlocker
|
ExecutionBlocker = ExecutionBlocker
|
||||||
@ -97,6 +98,10 @@ def get_input_info(
|
|||||||
extra_info = input_info[1]
|
extra_info = input_info[1]
|
||||||
else:
|
else:
|
||||||
extra_info = {}
|
extra_info = {}
|
||||||
|
# if input_type is a list, it is a Combo defined in outdated format; convert it
|
||||||
|
if isinstance(input_type, list):
|
||||||
|
extra_info["options"] = input_type
|
||||||
|
input_type = IO.Combo.io_type
|
||||||
return input_type, input_category, extra_info
|
return input_type, input_category, extra_info
|
||||||
|
|
||||||
class TopologicalSort:
|
class TopologicalSort:
|
||||||
|
|||||||
@ -29,9 +29,11 @@ def validate_node_input(
|
|||||||
if received_type == IO.MatchType.io_type or input_type == IO.MatchType.io_type:
|
if received_type == IO.MatchType.io_type or input_type == IO.MatchType.io_type:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if isinstance(received_type, list) and IO.ComboOption.io_type in received_type:
|
if isinstance(received_type, list) and input_type == IO.Combo.io_type:
|
||||||
if input_type == IO.Combo.io_type or isinstance(input_type, list):
|
return True
|
||||||
return True
|
# if isinstance(received_type, list) and IO.ComboOption.io_type in received_type:
|
||||||
|
# if input_type == IO.Combo.io_type or isinstance(input_type, list):
|
||||||
|
# return True
|
||||||
|
|
||||||
# Not equal, and not strings
|
# Not equal, and not strings
|
||||||
if not isinstance(received_type, str) or not isinstance(input_type, str):
|
if not isinstance(received_type, str) or not isinstance(input_type, str):
|
||||||
|
|||||||
54
execution.py
54
execution.py
@ -770,10 +770,13 @@ async def validate_inputs(prompt_id, prompt, item, validated):
|
|||||||
received_types = {}
|
received_types = {}
|
||||||
|
|
||||||
valid_inputs = set(class_inputs.get('required',{})).union(set(class_inputs.get('optional',{})))
|
valid_inputs = set(class_inputs.get('required',{})).union(set(class_inputs.get('optional',{})))
|
||||||
|
combo_inputs = set()
|
||||||
|
|
||||||
for x in valid_inputs:
|
for x in valid_inputs:
|
||||||
input_type, input_category, extra_info = get_input_info(obj_class, x, class_inputs)
|
input_type, input_category, extra_info = get_input_info(obj_class, x, class_inputs)
|
||||||
assert extra_info is not None
|
assert extra_info is not None
|
||||||
|
if input_type == io.Combo.io_type:
|
||||||
|
combo_inputs.add(x)
|
||||||
if x not in inputs:
|
if x not in inputs:
|
||||||
if input_category == "required":
|
if input_category == "required":
|
||||||
error = {
|
error = {
|
||||||
@ -913,8 +916,9 @@ async def validate_inputs(prompt_id, prompt, item, validated):
|
|||||||
errors.append(error)
|
errors.append(error)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(input_type, list):
|
if input_type == io.Combo.io_type and "remote" not in extra_info:
|
||||||
combo_options = input_type
|
combo_inputs.discard(x)
|
||||||
|
combo_options = extra_info["options"]
|
||||||
if val not in combo_options:
|
if val not in combo_options:
|
||||||
input_config = info
|
input_config = info
|
||||||
list_info = ""
|
list_info = ""
|
||||||
@ -940,7 +944,7 @@ async def validate_inputs(prompt_id, prompt, item, validated):
|
|||||||
errors.append(error)
|
errors.append(error)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if len(validate_function_inputs) > 0 or validate_has_kwargs:
|
if len(validate_function_inputs) > 0 or validate_has_kwargs or len(combo_inputs) > 0:
|
||||||
input_data_all, _, v3_data = get_input_data(inputs, obj_class, unique_id)
|
input_data_all, _, v3_data = get_input_data(inputs, obj_class, unique_id)
|
||||||
input_filtered = {}
|
input_filtered = {}
|
||||||
for x in input_data_all:
|
for x in input_data_all:
|
||||||
@ -949,25 +953,37 @@ async def validate_inputs(prompt_id, prompt, item, validated):
|
|||||||
if 'input_types' in validate_function_inputs:
|
if 'input_types' in validate_function_inputs:
|
||||||
input_filtered['input_types'] = [received_types]
|
input_filtered['input_types'] = [received_types]
|
||||||
|
|
||||||
ret = await _async_map_node_over_list(prompt_id, unique_id, obj_class, input_filtered, validate_function_name, v3_data=v3_data)
|
|
||||||
ret = await resolve_map_node_over_list_results(ret)
|
|
||||||
for x in input_filtered:
|
for x in input_filtered:
|
||||||
for i, r in enumerate(ret):
|
combo_inputs.discard(x)
|
||||||
if r is not True and not isinstance(r, ExecutionBlocker):
|
|
||||||
details = f"{x}"
|
|
||||||
if r is not False:
|
|
||||||
details += f" - {str(r)}"
|
|
||||||
|
|
||||||
error = {
|
if len(combo_inputs) > 0:
|
||||||
"type": "custom_validation_failed",
|
zzz = 10
|
||||||
"message": "Custom validation failed for node",
|
combo_inputs.clear()
|
||||||
"details": details,
|
|
||||||
"extra_info": {
|
|
||||||
"input_name": x,
|
if len(validate_function_inputs) > 0 or validate_has_kwargs:
|
||||||
|
ret = await _async_map_node_over_list(prompt_id, unique_id, obj_class, input_filtered, validate_function_name, v3_data=v3_data)
|
||||||
|
ret = await resolve_map_node_over_list_results(ret)
|
||||||
|
for x in input_filtered:
|
||||||
|
for i, r in enumerate(ret):
|
||||||
|
if r is not True and not isinstance(r, ExecutionBlocker):
|
||||||
|
details = f"{x}"
|
||||||
|
if r is not False:
|
||||||
|
details += f" - {str(r)}"
|
||||||
|
|
||||||
|
error = {
|
||||||
|
"type": "custom_validation_failed",
|
||||||
|
"message": "Custom validation failed for node",
|
||||||
|
"details": details,
|
||||||
|
"extra_info": {
|
||||||
|
"input_name": x,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
errors.append(error)
|
||||||
errors.append(error)
|
continue
|
||||||
continue
|
|
||||||
|
if len(combo_inputs) > 0:
|
||||||
|
zzz = 10
|
||||||
|
|
||||||
if len(errors) > 0 or valid is not True:
|
if len(errors) > 0 or valid is not True:
|
||||||
ret = (False, errors, unique_id)
|
ret = (False, errors, unique_id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user