Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion comfyui_to_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,18 @@ def generate_workflow(
for idx, data, is_special_function in load_order:
# Generate class definition and inputs from the data
inputs, class_type = data["inputs"], data["class_type"]
input_types = self.node_class_mappings[class_type].INPUT_TYPES()
class_def = self.node_class_mappings[class_type]()

# If required inputs are not present, skip the node as it will break the code if passed through to the script
missing_required_variable = False
if "required" in input_types.keys():
for required in input_types["required"]:
if required not in inputs.keys():
missing_required_variable = True
if missing_required_variable:
continue

# If the class hasn't been initialized yet, initialize it and generate the import statements
if class_type not in initialized_objects:
# No need to use preview image nodes since we are executing the script in a terminal
Expand Down Expand Up @@ -242,7 +252,12 @@ def generate_workflow(
if no_params or key in class_def_params
}
# Deal with hidden variables
if class_def_params is not None:
if (
"hidden" in input_types.keys()
and "unique_id" in input_types["hidden"].keys()
):
inputs["unique_id"] = random.randint(1, 2**64)
elif class_def_params is not None:
if "unique_id" in class_def_params:
inputs["unique_id"] = random.randint(1, 2**64)

Expand Down