ComfyUI-to-Python-Extension icon indicating copy to clipboard operation
ComfyUI-to-Python-Extension copied to clipboard

KeyError: '➕'

Open Harr7y opened this issue 7 months ago • 5 comments

I am running a FLUX try-on workflow, but an error occurs.

Traceback (most recent call last): File "/scratch/dyvm6xra/dyvm6xrauser25/comfyUI/ComfyUI/custom_nodes/comfyui-to-python-extension/init.py", line 50, in save_as_script ComfyUItoPython(workflow=workflow, output_file=sio) File "/scratch/dyvm6xra/dyvm6xrauser25/comfyUI/ComfyUI/custom_nodes/comfyui-to-python-extension/comfyui_to_python.py", line 544, in init self.execute() File "/scratch/dyvm6xra/dyvm6xrauser25/comfyUI/ComfyUI/custom_nodes/comfyui-to-python-extension/comfyui_to_python.py", line 573, in execute generated_code = code_generator.generate_workflow( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/dyvm6xra/dyvm6xrauser25/comfyUI/ComfyUI/custom_nodes/comfyui-to-python-extension/comfyui_to_python.py", line 290, in generate_workflow final_code = self.assemble_python_code( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scratch/dyvm6xra/dyvm6xrauser25/comfyUI/ComfyUI/custom_nodes/comfyui-to-python-extension/comfyui_to_python.py", line 413, in assemble_python_code final_code = black.format_str(final_code, mode=black.Mode()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/black/init.py", line 1208, in format_str File "src/black/init.py", line 1222, in _format_str_once File "src/black/parsing.py", line 73, in lib2to3_parse File "src/blib2to3/pgen2/driver.py", line 204, in parse_string File "src/blib2to3/pgen2/driver.py", line 149, in parse_tokens KeyError: '➕'

Harr7y avatar May 13 '25 03:05 Harr7y

I printed the code and found the error:

power_lora_loader_rgthree = NODE_CLASS_MAPPINGS["Power Lora Loader (rgthree)"]()
power_lora_loader_rgthree_102 = power_lora_loader_rgthree.load_loras(PowerLoraLoaderHeaderWidget={'type': 'PowerLoraLoaderHeaderWidget'}, ➕ Add Lora="", model=get_value_at_index(checkpointloadersimple_133, 0), clip=get_value_at_index(dualcliploader_11, 0))

Harr7y avatar May 13 '25 06:05 Harr7y

I printed the code and found the error:

power_lora_loader_rgthree = NODE_CLASS_MAPPINGS["Power Lora Loader (rgthree)"]()
power_lora_loader_rgthree_102 = power_lora_loader_rgthree.load_loras(PowerLoraLoaderHeaderWidget={'type': 'PowerLoraLoaderHeaderWidget'}, ➕ Add Lora="", model=get_value_at_index(checkpointloadersimple_133, 0), clip=get_value_at_index(dualcliploader_11, 0))

How did you fix this? Im running into a similar error

lukesorvik avatar Jun 26 '25 22:06 lukesorvik

Nvm I looked at comfyui-to-python-assemble_python_code and tried sanitizing the inputs and it did not fix It looks like to be a problem with rgthree's formatting of their node, the parser does not work (even when i changed assemble_python_code() to sanitize the emoji from the input)

I fixed by removing the rgthree lora multi loader from the workflow

lukesorvik avatar Jun 26 '25 22:06 lukesorvik

I also removed the "rgthree lora". The error occurred because there was this "➕" in the "power_lora_loader_rgthree.load_loras" code that can not be handled by 'black.format_str'

Harr7y avatar Jun 28 '25 16:06 Harr7y

try this in line 413., then remove the "➕" in the generated python file. With this change I could use the rgthree lora:

 
       try:
            final_code = black.format_str(final_code, mode=black.Mode()) 
       except Exception as e: print("[ComfyUI-to-Python] black formatting failed, writing unformatted code:", e) 
            # fall back to unformatted code 
            pass 

       return final_code 

aminamazlin avatar Aug 30 '25 15:08 aminamazlin