ComfyUI-Custom-Scripts icon indicating copy to clipboard operation
ComfyUI-Custom-Scripts copied to clipboard

Custom node breaks Save File Formatting

Open dexeonify opened this issue 1 year ago • 6 comments

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

  • I've read the README and I don't see anything that mentions this change in behaviour of the save image and primitive node.
  • I'm surprised this wasn't reported considering it breaks a core functionality, are there some other issues at play here?

dexeonify avatar Feb 22 '24 16:02 dexeonify

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`

cloudsurfer28699 avatar Mar 20 '24 08:03 cloudsurfer28699

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)

pythongosssss avatar Mar 24 '24 17:03 pythongosssss

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).

dexeonify avatar Mar 25 '24 07:03 dexeonify

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?

Delerium avatar Mar 28 '24 02:03 Delerium

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.

dexeonify avatar Mar 28 '24 03:03 dexeonify

This is still a bug.

NPDX909 avatar Sep 17 '24 04:09 NPDX909