8000 fix: Missing data dirs should be handled gracefully by polarathene · Pull Request #8115 · comfyanonymous/ComfyUI · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Missing data dirs should be handled gra 8000 cefully #8115

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

polarathene
Copy link
@polarathene polarathene commented May 14, 2025

Fixes: #8110

Overview:

  • input/ + temp/ directories moved to a common function call run after apply_custom_paths().
    • These were both implicitly created at startup at different locations. It seemed better to co-locate?
    • The input/ dir was created before it could be updated by the CLI arg. Now it will not create another directory before the input dir path is changed.
    • The temp/ dir seems like it might have been implemented a bit wrong? Rather than set a specific directory like the others, it creates a temp/ folder at that path (so --temp-directory /tmp would create /tmp/temp)... fixing that would technically be a breaking change though.
  • custom_nodes/ is another default directory that caused ComfyUI to crash if it did not exist when it's contents was checked. Instead prefer to skip empty custom node directories at startup.

References:


Slight inconsistency observed with the user/ directory.

--user-directory is a newer option added to the CLI (8 months ago) after the related ones (2 years ago). For some reason it was not co-located with the existing options (affects list order in help output) and unlike the other related options it enforces a check on the given path to exist, rather than create when missing.

parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")

I could likewise shift that user dir logic into the common setup function and co-locate the CLI arg? (normalizing on your preference of enforcing the path given to exist or not)

Copy link
Author
@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing inline feedback if helpful

parser.add_argument("--output-directory", type=str, default=None, help="Set the ComfyUI output directory. Overrides --base-directory.")
parser.add_argument("--temp-directory", type=str, default=None, help="Set the ComfyUI temp directory (default is in the ComfyUI directory). Overrides --base-directory.")
parser.add_argument("--input-directory", type=str, default=None, help="Set the ComfyUI input directory. Overrides --base-directory.")
parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, could set this to str and it'll be created if it's missing, otherwise the other related options could also use type=is_valid_directory to enforce a valid dir is provided (but that may break some expectations?)

Suggested change
parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")
parser.add_argument("--user-directory", type=str, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.")

Comment on lines +34 to +37
if args.temp_directory:
temp_dir = os.path.join(os.path.abspath(args.temp_directory), "temp")
logging.info(f"Setting temp directory to: {temp_dir}")
folder_paths.set_temp_directory(temp_dir)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change, but would be consistent with expectations of related args:

Suggested change
if args.temp_directory:
temp_dir = os.path.join(os.path.abspath(args.temp_directory), "temp")
logging.info(f"Setting temp directory to: {temp_dir}")
folder_paths.set_temp_directory(temp_dir)
if args.temp_directory:
temp_dir = os.path.abspath(args.temp_directory)
logging.info(f"Setting temp directory to: {temp_dir}")
folder_paths.set_temp_directory(temp_dir)

Comment on lines +65 to +68
data_dirs = [
folder_paths.get_input_directory(),
folder_paths.get_temp_directory()
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionally create the user/ directory here (UserManager already does so at startup?), and restore the output/ directory creation (presumably not necessary and is instead handled on-demand).

Suggested change
data_dirs = [
folder_paths.get_input_directory(),
folder_paths.get_temp_directory()
]
data_dirs = [
folder_paths.get_input_directory(),
folder_paths.get_output_directory(),
folder_paths.get_temp_directory(),
folder_paths.get_user_directory()
]

Comment on lines +95 to +97
if not os.path.exists(custom_node_path):
logging.warning(f"Directory {custom_node_path} for custom nodes does not exist, skipping")
continue
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the primary fix I'm interested in, if the directory does not need to exist but is checked by default, it seems better to skip instead of crash?

I am not sure if that aligns with your expectations, so if it makes sense to log a warning I've added one here, otherwise the warning could be removed?

logging.warning(f"Directory {custom_node_path} for custom nodes does not exist, skipping")
continue

possible_modules = os.listdir(os.path.realpath(custom_node_path))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.path.realpath was added here but could be reverted.

A user reported the lack of resolving symlinks as problematic for similar custom_node_path logic at nodes.py and resolved it by adding os.path.realpath: #2035

I added it here for consistency.

@polarathene polarathene changed the title fix: Should gracefully handle missing data dirs fix: Missing data dirs should be handled gracefully May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileNotFoundError for custom_nodes directory at startup (should be created instead of bailing)
1 participant
0