Commit Graph

53 Commits

Author SHA1 Message Date
Jacob Segal
5d72965863 Implement conditional Execution Blocking
Execution blocking can be done by returning an `ExecutionBlocker`
(imported from graph_utils) either in place of results or as a specific
output. Any node that uses an `ExecutionBlocker` as input will be
skipped. This operates on a per-entry basis when inputs are lists.

If the `ExecutionBlocker` is initialized with an error message, that
message will be displayed on the first node it's used on (and further
downstream nodes will be silently skipped).
2023-07-28 22:28:18 -07:00
Jacob Segal
b09620f89c In For loops, display feedback on original node
Rather than displaying live feedback on the "End For" node, the feedback
will be displayed in the UI on the original node.
2023-07-22 23:02:10 -07:00
Jacob Segal
b66253b930 Improve recognition of node linkage
Honestly, I'm still a little concerned here. There's nothing stopping a
custom node from having a data type of ["str",int]. I've improved
recognition to at least prevent the detection of other types, but we
may still want a more systemic fix (e.g. wrapping literals within a
class when using them as inputs to nodes in subgraphs).
2023-07-22 22:38:17 -07:00
Jacob Segal
9d9e1e65ab Add nodes for dealing with BOOLs 2023-07-20 21:04:08 -07:00
Jacob Segal
88fc046180 Make BOOL an intrinsically supported type 2023-07-20 21:02:06 -07:00
Jacob Segal
4f1858cacf Fix a bug when nodes have no required inputs 2023-07-20 21:01:27 -07:00
Jacob Segal
83eb7e5057 Validate optional inputs
Previously, nodes that were connected to output nodes only via optional
inputs were never validated, but were still run. This would cause a
Python error and stop execution wherever we happen to be in the
execution list. This bug exists on master, but may be more noticeable in
this branch because execution order is non-deterministic.

Other minor change this commit introduces: `raw_link` can be specified
as an option on an input to receive the raw link (in the standard form
of [node_id, output_index]) rather than a resolved value.
2023-07-19 23:19:58 -07:00
Jacob Segal
b234baee2c Add lazy evaluation and dynamic node expansion
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
without hooking or replacing any core functionality. Within this PR,
I've included all of these proof-of-concepts within a custom node pack.
In reality, I would expect some number of them to be merged into the
core node set (with the rest left to be implemented by custom nodes).

I made very few changes to the front-end, so there are probably some
easy UX wins for someone who is more willing to wade into .js land. The
user experience is a lot better than I expected though -- progress shows
correctly in the UI over the nodes that are being expanded.
2023-07-18 20:08:12 -07:00
Jacob Segal
7e4bc4451b Enable the use of variant types in node out/input 2023-07-18 19:49:05 -07:00
comfyanonymous
6e9f28401f Persist node instances between executions instead of deleting them.
If the same node id with the same class exists between two executions the
same instance will be used.

This means you can now cache things in nodes for more efficiency.
2023-06-29 23:38:56 -04:00
comfyanonymous
d52ed407a7 Send websocket message only when prompt is actually done executing. 2023-06-13 13:38:43 -04:00
comfyanonymous
af91df85c2 Add a /history/{prompt_id} endpoint. 2023-06-12 14:34:30 -04:00
comfyanonymous
ad81fd682a Fix issue with cancelling prompt. 2023-05-28 00:32:26 -04:00
space-nuko
03f2d0a764 Rename exception message field 2023-05-27 21:06:07 -05:00
space-nuko
52c9590b7b Exception message 2023-05-27 21:06:07 -05:00
space-nuko
62bdd9d26a Catch typecast errors 2023-05-27 21:06:07 -05:00
space-nuko
a9e7e23724 Fix 2023-05-27 21:06:07 -05:00
space-nuko
e2d080b694 Return null for value format 2023-05-27 21:06:07 -05:00
space-nuko
6b2a8a3845 Show message in the frontend if prompt execution raises an exception 2023-05-27 21:06:07 -05:00
space-nuko
ffec815257 Send back more information about exceptions that happen during execution 2023-05-27 21:06:07 -05:00
space-nuko
0d834e3a2b Add missing input name/config 2023-05-27 21:06:07 -05:00
space-nuko
c33b7c5549 Improve invalid prompt error message 2023-05-27 21:06:07 -05:00
space-nuko
73e85fb3f4 Improve error output for failed nodes 2023-05-27 21:06:07 -05:00
comfyanonymous
48fcc5b777 Parsing error crash. 2023-05-22 20:51:30 -04:00
comfyanonymous
ffc56c53c9 Add a node_errors to the /prompt error json response.
"node_errors" contains a dict keyed by node ids. The contents are a message
and a list of dependent outputs.
2023-05-22 13:22:38 -04:00
comfyanonymous
516119ad83 Print min and max values in validation error message. 2023-05-21 00:24:28 -04:00
comfyanonymous
1dd846a7ba Fix outputs gone from history. 2023-05-15 00:27:28 -04:00
comfyanonymous
9bf67c4c5a Print prompt execution time. 2023-05-14 01:34:25 -04:00
comfyanonymous
44f9f9baf1 Add the prompt id to some websocket messages. 2023-05-13 11:17:16 -04:00
BlenderNeko
1201d2eae5
Make nodes map over input lists (#579)
* allow nodes to map over lists

* make work with IS_CHANGED and VALIDATE_INPUTS

* give list outputs distinct socket shape

* add rebatch node

* add batch index logic

* add repeat latent batch

* deal with noise mask edge cases in latentfrombatch
2023-05-13 11:15:45 -04:00
comfyanonymous
dfc74c19d9 Add the prompt_id to some websocket messages. 2023-05-11 01:22:40 -04:00
comfyanonymous
3a7c3acc72 Send websocket message with list of cached nodes right before execution. 2023-05-10 15:59:24 -04:00
comfyanonymous
602095f614 Send execution_error message on websocket on execution exception. 2023-05-10 15:49:49 -04:00
comfyanonymous
d6dee8af1d Only validate each input once. 2023-05-10 00:29:31 -04:00
comfyanonymous
02ca1c67f8 Don't print traceback when processing interrupted. 2023-05-09 23:51:52 -04:00
comfyanonymous
3a1f9dba20 If IS_CHANGED returns exception delete the output instead of crashing. 2023-04-26 02:13:56 -04:00
comfyanonymous
951c0c2bbe Don't keep cached outputs for removed nodes. 2023-04-26 02:05:57 -04:00
comfyanonymous
0ac319fd81 Don't delete all outputs when execution gets interrupted. 2023-04-23 22:44:38 -04:00
comfyanonymous
ccad603b2e Add a way for nodes to validate their own inputs. 2023-04-23 16:03:26 -04:00
ltdrdata
f7a8218814
Add clipspace feature. (#541)
* Add clipspace feature.
* feat: copy content to clipspace
* feat: paste content from clipspace

Extend validation to allow for validating annotated_path in addition to other parameters.

Add support for annotated_filepath in folder_paths function.

Generalize the '/upload/image' API to allow for uploading images to the 'input', 'temp', or 'output' directories.

* rename contentClipboard -> clipspace

* Do deep copy for imgs on copy to clipspace.

* add original_imgs into clipspace
* Preserve the original image when 'imgs' are modified

* robust patch & refactoring folder_paths about annotated_filepath

* Only show the Paste menu if the ComfyApp.clipspace is not empty

* instant refresh on paste

force triggering 'changed' on paste action

* subfolder fix on paste logic

attach subfolder if subfolder isn't empty

---------

Co-authored-by: Lt.Dr.Data <lt.dr.data@gmail.com>
2023-04-23 15:58:55 -04:00
comfyanonymous
deb2b93e79 Move code to empty gpu cache to model_management.py 2023-04-15 11:19:07 -04:00
藍+85CD
d63705d919 Support releases all unoccupied cached memory from XPU 2023-04-15 15:50:51 +08:00
pythongosssss
6f72c4c6ff Allows nodes to return ui data and output data
Fire executed event on node when message received
2023-03-29 18:53:24 +01:00
Davemane42
1e0f2b232b add unique_id to nodes hidden inputs
@classmethod
    def INPUT_TYPES(cls):
        return {
            "hidden": {"unique_id": "UNIQUE_ID"},
        }
2023-03-28 02:52:12 -04:00
comfyanonymous
bb1223d83f Fix errors appearing more than once. 2023-03-27 02:16:58 -04:00
comfyanonymous
3444ffff3b Fix IS_CHANGED not working on nodes with an input from another node. 2023-03-27 01:56:22 -04:00
comfyanonymous
f67c00622f Use inference_mode instead of no_grad. 2023-03-22 03:48:26 -04:00
pythongosssss
5c55c93367 Updated to reuse session id if available 2023-03-07 13:24:15 +00:00
comfyanonymous
c8ce599a8f Add a button to interrupt processing to the ui. 2023-03-02 15:24:51 -05:00
comfyanonymous
69cc75fbf8 Add a way to interrupt current processing in the backend. 2023-03-02 14:42:03 -05:00