adieyal / comfyui-dynamicprompts

ComfyUI custom nodes for Dynamic Prompts
MIT License
187 stars 20 forks source link

Hit a Python exception while executing DPRandomGenerator due to '\u014d' Unicode character (ō) in wildcard file. #12

Open ejrejr opened 10 months ago

ejrejr commented 10 months ago

First the exception and then I'll tell you about my work flow (and attach a PNG).

Exception:

Error occurred when executing DPRandomGenerator: 
'charmap' codec can't encode character '\u014d' in position 59: character maps to

File "C:\Users\Eric\repos\Stable-Diffusion\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) 
File "C:\Users\Eric\repos\Stable-Diffusion\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) 
File "C:\Users\Eric\repos\Stable-Diffusion\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) 
File "C:\Users\Eric\repos\Stable-Diffusion\ComfyUI\custom_nodes\comfyui-dynamicprompts\nodes\sampler.py", line 100, in get_prompt print(f"New prompt: {new_prompt}") 
File "C:\Users\Eric\repos\Stable-Diffusion\ComfyUI\custom_nodes\ComfyUI-Manager\prestartup_script.py", line 24, in write self.file.write(message) 
File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0]

My workflow (PNG) attached uses several wildcard files. The one I suspect is an artists.txt file (from https://github.com/rikkar69/SDXL-artist-study) that might contain Unicode characters for the artists' names. I extracted out those names, based on the problematic character, into a given file and reproduced the issue.

Repro:

Environment:

Steps

Expect:

Result:

Current comfyui-dynamicprompts repo that I'm sync'd to:

git log --name-status HEAD^..HEAD
commit 584b204cc3c0aee793227479dd9bf1eabfc6b23c (HEAD -> main, origin/main, origin/HEAD)

(I will say, looking at the stack I'm not familiar w/ the presence of ComfyUI-Manager, which I do have installed, like lots of folks, for managing my custom node extensions.)

Let me know if you need anymore info. Thanks.

Attached: (1) original flow that eventually caused the issue (2) a wildcard file, testArtists.txt, that will directly repro the issue if referred to in a random prompt.

Epic Professional quality (art by Jacques Villon and Ingrid Baars-1 6) of dynamic action cinemat_0002 testArtists.txt

linnkoln commented 9 months ago

Same