pythongosssss / ComfyUI-Custom-Scripts

Enhancements & experiments for ComfyUI, mostly focusing on UI features
MIT License
1.73k stars 134 forks source link

Custom node breaks Save File Formatting #191

Open dexeonify opened 7 months ago

dexeonify commented 7 months ago

Steps to Reproduce

  1. Launch a clean instance of ComfyUI without any custom nodes.
  2. Create a simple workflow that loads an image and save the file formatted as %date:yyyy-MM-dd%, using two methods: a) Using filename_prefix directly image b) Connect a primitive node after converting filename_prefix to input image
  3. Check the output folder.
  4. Install ComfyUI-Custom-Scripts and relaunch ComfyUI, then retry the two workflows above.

Expected result

Both methods should work just like vanilla ComfyUI, or at least print a warning/error somewhere.

Actual result

With the custom node installed, the first method works flawlessly, while the second method silently broke. If you checked the output folder, an incomplete file %date is created. No console messages was logged by Custom-Scripts or ComfyUI.

Notes

cloudsurfer28699 commented 6 months ago

I have the same issue, however if i use "%date:yyyy-MM-dd%/%KSampler.seed%" it gives me the following error:

`Error occurred when executing SaveImage:

[WinError 267] The directory name is invalid: '\ComfyUI_windows_portable\ComfyUI\output\%date:yyyy-MM-dd%'

File "\ComfyUI_windows_portable\ComfyUI\execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\ComfyUI_windows_portable\ComfyUI\execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\ComfyUI_windows_portable\ComfyUI\execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1428, in save_images full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\ComfyUI_windows_portable\ComfyUI\folder_paths.py", line 260, in get_save_image_path os.makedirs(full_output_folder, exist_ok=True) File "", line 225, in makedirs`

pythongosssss commented 6 months ago

Have you set "Run widget replace on values" to true on the primitive node? The default on Primitives is off, so replacements are not run, whereas it always runs on the SaveImage node.

image

If I enable that, it works fine (but there is a bug with the primitive node reloading these values when you reload the workflow)

dexeonify commented 6 months ago

Yes, it works fine with that option enabled. Now I wonder how/why does vanilla ComfyUI perform replacements without that option enabled. To further complicate the matter, some users have reported that it doesn't work even without this custom node installed (comfyanonymous/ComfyUI#2832).

Delerium commented 6 months ago

I'd like to add that by setting "Run widget replace on values" to true, any time you pull this image into ComfyUI, it will not retain your custom save file formatting, as it will be overwritten with the hard coded result your formatting generated the first time. This is not desired at all. Any way around this?

dexeonify commented 6 months ago

If I enable that, it works fine (but there is a bug with the primitive node reloading these values when you reload the workflow)

It's a known bug. The workaround, or should I say the proper method, is to use the first method and forego using primitive node entirely.

NPDX909 commented 2 weeks ago

This is still a bug.