* Execution Model Inversion
This PR inverts the execution model -- from recursively calling nodes to
using a topological sort of the nodes. This change allows for
modification of the node graph during execution. This allows for two
major advantages:
1. The implementation of lazy evaluation in nodes. For example, if a
"Mix Images" node has a mix factor of exactly 0.0, the second image
input doesn't even need to be evaluated (and visa-versa if the mix
factor is 1.0).
2. Dynamic expansion of nodes. This allows for the creation of dynamic
"node groups". Specifically, custom nodes can return subgraphs that
replace the original node in the graph. This is an incredibly
powerful concept. Using this functionality, it was easy to
implement:
a. Components (a.k.a. node groups)
b. Flow control (i.e. while loops) via tail recursion
c. All-in-one nodes that replicate the WebUI functionality
d. and more
All of those were able to be implemented entirely via custom nodes,
so those features are *not* a part of this PR. (There are some
front-end changes that should occur before that functionality is
made widely available, particularly around variant sockets.)
The custom nodes associated with this PR can be found at:
https://github.com/BadCafeCode/execution-inversion-demo-comfyui
Note that some of them require that variant socket types ("*") be
enabled.
* Allow `input_info` to be of type `None`
* Handle errors (like OOM) more gracefully
* Add a command-line argument to enable variants
This allows the use of nodes that have sockets of type '*' without
applying a patch to the code.
* Fix an overly aggressive assertion.
This could happen when attempting to evaluate `IS_CHANGED` for a node
during the creation of the cache (in order to create the cache key).
* Fix Pyright warnings
* Add execution model unit tests
* Fix issue with unused literals
Behavior should now match the master branch with regard to undeclared
inputs. Undeclared inputs that are socket connections will be used while
undeclared inputs that are literals will be ignored.
* Make custom VALIDATE_INPUTS skip normal validation
Additionally, if `VALIDATE_INPUTS` takes an argument named `input_types`,
that variable will be a dictionary of the socket type of all incoming
connections. If that argument exists, normal socket type validation will
not occur. This removes the last hurdle for enabling variant types
entirely from custom nodes, so I've removed that command-line option.
I've added appropriate unit tests for these changes.
* Fix example in unit test
This wouldn't have caused any issues in the unit test, but it would have
bugged the UI if someone copy+pasted it into their own node pack.
* Use fstrings instead of '%' formatting syntax
* Use custom exception types.
* Display an error for dependency cycles
Previously, dependency cycles that were created during node expansion
would cause the application to quit (due to an uncaught exception). Now,
we'll throw a proper error to the UI. We also make an attempt to 'blame'
the most relevant node in the UI.
* Add docs on when ExecutionBlocker should be used
* Remove unused functionality
* Rename ExecutionResult.SLEEPING to PENDING
* Remove superfluous function parameter
* Pass None for uneval inputs instead of default
This applies to `VALIDATE_INPUTS`, `check_lazy_status`, and lazy values
in evaluation functions.
* Add a test for mixed node expansion
This test ensures that a node that returns a combination of expanded
subgraphs and literal values functions correctly.
* Raise exception for bad get_node calls.
* Minor refactor of IsChangedCache.get
* Refactor `map_node_over_list` function
* Fix ui output for duplicated nodes
* Add documentation on `check_lazy_status`
* Add file for execution model unit tests
* Clean up Javascript code as per review
* Improve documentation
Converted some comments to docstrings as per review
* Add a new unit test for mixed lazy results
This test validates that when an output list is fed to a lazy node, the
node will properly evaluate previous nodes that are needed by any inputs
to the lazy node.
No code in the execution model has been changed. The test already
passes.
* Allow kwargs in VALIDATE_INPUTS functions
When kwargs are used, validation is skipped for all inputs as if they
had been mentioned explicitly.
* List cached nodes in `execution_cached` message
This was previously just bugged in this PR.
* Add support for simple tooltips
* Fix overflow
* Add tooltips for nodes in the default workflow
* new line
* Prevent potential crash
* PR feedback
* Hide tooltip when clicking (e.g. combo widget)
* Refactor tooltips, add node level support
* Fix
* move
* Fix test (and undo last change)
* Fixed indent
* Fix dom widgets, dont show tooltip if not over canvas
* menu
* wip
* wip
* wip
* wip
* wip
* workflow saving/loading
* Support inserting workflows
Move buttosn to top of lists
* fix session storage
implement renaming
* temp
* refactor, better workflow instance management
* wip
* progress on progress
* added send to workflow
various fixes
* Support multiple image loaders
* Support dynamic size breakpoints based on content
* various fixes
add close unsaved warning
* Add filtering tree
* prevent renaming unsaved
* fix zindex on hover
* fix top offset
* use filename as workflow name
* resize on setting change
* hide element until it is drawn
* remove glow
* Fix export name
* Fix test, revert accidental changes to groupNode
* Fix colors on all themes
* show hover items on smaller screen (mobile)
* remove debugging code
* dialog fix
* Dont reorder open workflows
Allow elements around canvas
* Toggle body display on setting change
* Fix menu disappearing on chrome
* Increase delay when typing, remove margin on Safari, fix dialog location
* Fix overflow issue on iOS
* Add reset view button
Prevent view changes causing history entries
* Bottom menu wip
* Various fixes
* Fix merge
* Fix breaking old menu position
* Fix merge adding restore view to loadGraphData
* Add toggle to enable auto queue when graph is changed
* type fix
* better
* better alignment
* Change undoredo to not ignore inputs when autoqueue in change mode
* wip per user data
* Rename, hide menu
* better error
rework default user
* store pretty
* Add userdata endpoints
Change nodetemplates to userdata
* add multi user message
* make normal arg
* Fix tests
* Ignore user dir
* user tests
* Changed to default to browser storage and add server-storage arg
* fix crash on empty templates
* fix settings added before load
* ignore parse errors
* Prevent cleaning graph state on undo/redo
* Remove pause rendering due to LG bug
* Fix crash on disconnected internal reroutes
* Fix widget inputs being incorrect order and value
* Fix initial primitive values on connect
* basic support for basic rerouted converted inputs
* Populate primitive to reroute input
* dont crash on bad primitive links
* Fix convert to group changing control value
* reduce restrictions
* fix random crash in tests
* setup ui unit tests
* Refactoring, adding connections
* Few tweaks
* Fix type
* Add general test
* Refactored and extended test
* move to describe
* for groups
* wip group nodes
* Relink nodes
Fixed widget values
Convert to nodes
* Reconnect on convert back
* add via node menu + canvas
refactor
* Add ws event handling
* fix using wrong node on widget serialize
* allow reroute pipe
fix control_after_generate configure
* allow multiple images
* Add test for converted widgets on missing nodes + fix crash
* tidy
* mores tests + refactor
* throw earlier to get less confusing error
* support outputs
* more test
* add ci action
* use lts node
* Fix?
* Prevent connecting non matching combos
* update
* accidently removed npm i
* Disable logging extension
* fix naming
allow control_after_generate custom name
allow convert from reroutes
* group node tests
* Add executing info, custom node icon
Tidy
* internal reroute just works
* Fix crash on virtual nodes e.g. note
* Save group nodes to templates
* Fix template nodes not being stored
* Fix aborting convert
* tidy
* Fix reconnecting output links on convert to group
* Fix links on convert to nodes
* Handle missing internal nodes
* Trigger callback on text change
* Apply value on connect
* Fix converted widgets not reconnecting
* Group node updates
- persist internal ids in current session
- copy widget values when converting to nodes
- fix issue serializing converted inputs
* Resolve issue with sanitized node name
* Fix internal id
* allow outputs to be used internally and externally
* order widgets on group node
various fixes
* fix imageupload widget requiring a specific name
* groupnode imageupload test
give widget unique name
* Fix issue with external node links
* Add VAE model
* Fix internal node id check
* fix potential crash
* wip widget input support
* more wip group widget inputs
* Group node refactor
Support for primitives/converted widgets
* Fix convert to nodes with internal reroutes
* fix applying primitive
* Fix control widget values
* fix test