Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling "UI-only" nodes #42

Open
ghostsquad opened this issue Jun 12, 2024 · 13 comments
Open

Handling "UI-only" nodes #42

ghostsquad opened this issue Jun 12, 2024 · 13 comments
Labels
bug Something isn't working transpiler

Comments

@ghostsquad
Copy link

Some nodes it seems are client-only nodes, like Reroute (rgthree). I'm getting this error, and I'm assuming that is why, as it's only javascript, there's no associated Python code with it. How should I handle that?

Traceback (most recent call last):
  File "E:\custom_nodes\ComfyScript\src\comfy_script\nodes\__init__.py", line 97, in chunks
    comfy_script = transpile.WorkflowToScriptTranspiler(workflow).to_script(end_nodes)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\custom_nodes\ComfyScript\src\comfy_script\transpile\__init__.py", line 340, in to_script
    c += self._node_to_assign_st(self.G.nodes[node])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\custom_nodes\ComfyScript\src\comfy_script\transpile\__init__.py", line 193, in _node_to_assign_st
    args = self._keyword_args_to_positional(v.type, args_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\custom_nodes\ComfyScript\src\comfy_script\transpile\__init__.py", line 122, in _keyword_args_to_positional
    input_types = self._get_input_types(node_type)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\custom_nodes\ComfyScript\src\comfy_script\transpile\__init__.py", line 81, in _get_input_types
    return self.nodes_info[node_type]['input']
           ~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'Reroute (rgthree)'
@Chaoses-Ib Chaoses-Ib added bug Something isn't working transpiler labels Jun 13, 2024
@Chaoses-Ib
Copy link
Owner

It's now fixed. Thanks for your report.

If you encounter other UI-only nodes in the future, you can workaround this problem by exporting the API format workflow and transpiling it. I've also added this in the exception message:

image

@ghostsquad
Copy link
Author

I've updated, and now I'm getting this:

Traceback (most recent call last):
  File "E:\custom_nodes\ComfyScript\src\comfy_script\nodes\__init__.py", line 97, in chunks
    comfy_script = transpile.WorkflowToScriptTranspiler(workflow).to_script(end_nodes)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\custom_nodes\ComfyScript\src\comfy_script\transpile\__init__.py", line 344, in to_script
    c += self._node_to_assign_st(self.G.nodes[node])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\custom_nodes\ComfyScript\src\comfy_script\transpile\__init__.py", line 191, in _node_to_assign_st
    'exp': output_ids[u_slot],
           ~~~~~~~~~~^^^^^^^^
KeyError: 3

@Chaoses-Ib
Copy link
Owner

Can you share the workflow? I've tested workflow with Reroute (rgthree) and saw no errors.

image

@Chaoses-Ib
Copy link
Owner

I've added a fallback mechanism to workaround this sort of issues. In case a node cannot be found, the transpiler hook will try to transpile the API format workflow again.

image

(Reroute (rgthree) support is removed for demo)

@ghostsquad
Copy link
Author

here's my complex workflow, which is the reason I'm looking to go to ComfyScript. I'm running into way too many UI limitations, and it's hard to grok what is different between generations (when I turn knobs, adjust parameters, etc.).

comfyscript-troubleshooting.json

@Chaoses-Ib
Copy link
Owner

Chaoses-Ib commented Jun 14, 2024

It's indeed a complex workflow... Can you share the workflow in API format too? There are too many missing nodes on my side and I can't export it in API format correctly. The "Save (API Format)" button will be visible after turning on "Enable Dev mode Options" in the settings of the web UI.

@ghostsquad
Copy link
Author

workflow_api.json

as requested

@ghostsquad
Copy link
Author

Here's another one: Node not found: Fast Groups Muter (rgthree)

@ghostsquad
Copy link
Author

Instead of throwing this error, is there a way to do the transpilation programmatically?

@Chaoses-Ib
Copy link
Owner

Here's another one: Node not found: Fast Groups Muter (rgthree)

Is there only this error? I've already added a mechanism that will use the API format (which has no UI-only nodes) after the web UI format fails.

Instead of throwing this error, is there a way to do the transpilation programmatically?

You can specify the node where the transpilation starts, e.g. WorkflowToScriptTranspiler.to_script([123]), but that's all.

@ghostsquad
Copy link
Author

Oh, maybe I just need to update again.

@Chaoses-Ib
Copy link
Owner

The fallback only exists in the web UI SaveImage hook before. In case you are using the metadata viewer, I've also added fallback to it now.

@Chaoses-Ib
Copy link
Owner

#77 reported a similar problem. And because the used UE Nodes don't support API format (#78), API format fallback also failed. Such case probably can only be handled by adding support for specific UI-only nodes, or adding some complex tracing hacks to record the actually executed workflow...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working transpiler
Projects
None yet
Development

No branches or pull requests

2 participants