ComfyUI Node
dynamic_script (python, executor, code)
This node is used to execute Python scripts within a workflow, enabling functionality that is difficult or impossible to achieve using nodes alone. It accepts multiple inputs and produces multiple outputs. When an exception occurs, relevant information is output to the fixed 'exception' port. The first N dynamic inputs (determined by module_count) are treated as user-defined module code.
dynamic_script (python, executor, code)
- exception
◄input_ports_count2►
◄output_ports_count1►
◄module_count0►
◄module_name_prefixdynamic_module►
◄remove_import_restrictionsfalse►
◄lazy_executionfalse►
◄code—►
Categorydynamic/script
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| input_ports_count | INT | 20–100 | The number of input ports for this node. |
| output_ports_count | INT | 10–100 | The number of output ports for this node. |
| module_count | INT | 00–100 | Number of leading dynamic inputs to treat as user module code. These inputs will be compiled into importable modules before the main script runs. The actual script inputs start from input_{module_count}, but you can still access the input module code by inputs list in code |
| module_name_prefix | STRING | dynamic_module | Prefix for auto-generated module names. The i-th module will be named {prefix}__{i}, then you can import them in your code. |
| remove_import_restrictions | BOOLEAN | false | Allow importing any module. (use with caution, check the code first !!!) |
| lazy_execution | BOOLEAN | false | Execute the code lazily. Note: Enable this option only when the script executed by this node is a pure function (output depends solely on the input; in other words, the same input always produces the same output). When this option is enabled, the node will re-execute only when the value at its input changes. |
| code | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| exception | * | Exception information or None. |