Nodes/comfyui_dynamic/dynamic_script (python, executor, code)
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.

By inkbottle-9·Created 8 months ago·Updated about a month ago· 0
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)

    NameTypeDefaultDescription
    input_ports_countINT20–100The number of input ports for this node.
    output_ports_countINT10–100The number of output ports for this node.
    module_countINT00–100Number 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_prefixSTRINGdynamic_modulePrefix for auto-generated module names. The i-th module will be named {prefix}__{i}, then you can import them in your code.
    remove_import_restrictionsBOOLEANfalseAllow importing any module. (use with caution, check the code first !!!)
    lazy_executionBOOLEANfalseExecute 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.
    codeSTRING

    Outputs (1)

    NameTypeDescription
    exception*Exception information or None.