folder_paths.py doesn't include extra_model_paths
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Expected Behavior
`folder_paths.py` should use `extra_model_paths_config`, like `main.py` does.
### Actual Behavior
`folder_paths` only uses the default folder locations, creating issues for people trying to use ComfyUI as a backend (like https://github.com/pydn/ComfyUI-to-Python-Extension does)
### Steps to Reproduce
In my reproduction instructions, I will write `MODEL_NAME_HERE` for convenience in seeing where the model is. When I ran this, I replaced this variable in my template.
I am running the code below in Python (only providing snippet for ease-of-reading).
```
import random
import torch
import sys
sys.path.append("../")
from nodes import (
VAEDecode,
KSamplerAdvanced,
EmptyLatentImage,
SaveImage,
CheckpointLoaderSimple,
CLIPTextEncode,
)
def main():
with torch.inference_mode():
checkpointloadersimple = CheckpointLoaderSimple()
checkpointloadersimple_4 = checkpointloadersimple.load_checkpoint(
ckpt_name="MODEL_NAME_HERE.safetensors"
)
...
```
I am getting the below error.
```
Traceback (most recent call last):
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\test.py", line 70, in
main()
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\test.py", line 20, in main
checkpointloadersimple_4 = checkpointloadersimple.load_checkpoint(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\nodes.py", line 539, in load_checkpoint
ckpt_path = folder_paths.get_full_path_or_raise("checkpoints", ckpt_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\folder_paths.py", line 284, in get_full_path_or_raise
raise FileNotFoundError(f"Model in folder '{folder_name}' with filename '{filename}' not found.")
FileNotFoundError: Model in folder 'checkpoints' with filename 'MODEL_NAME_HERE.safetensors' not found.
```
I followed the code into this stack. I ended up in `folder_paths.py`'s `get_full_path`.
```
def get_full_path(folder_name: str, filename: str) -> str | None:
global folder_names_and_paths
folder_name = map_legacy(folder_name)
print("folder_names_and_paths:", folder_names_and_paths)
if folder_name not in folder_names_and_paths:
return None
folders = folder_names_and_paths[folder_name]
filename = os.path.relpath(os.path.join("/", filename), "/")
for x in folders[0]:
full_path = os.path.join(x, filename)
if os.path.isfile(full_path):
return full_path
elif os.path.islink(full_path):
logging.warning("WARNING path {} exists but doesn't link anywhere, skipping.".format(full_path))
return None
```
Above is the main branch code, but with one exception... my `folder_names_and_path` print.
I found that it was returning the run-of-the-mill `ComfyUI_windows_portable\\ComfyUI\\models\\checkpoints` folder like it should have. But it did NOT include the custom paths I added using the `extra_model_paths.yaml`.
### Debug Logs
```powershell
folder_names_and_paths: {'checkpoints': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\checkpoints'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'configs': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\configs'], ['.yaml']), 'loras': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\loras'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'vae': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\vae'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'clip': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\clip'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'diffusion_models': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\unet', 'C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\diffusion_models'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'clip_vision': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\clip_vision'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'style_models': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\style_models'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'embeddings': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\embeddings'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'diffusers': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\diffusers'], ['folder']), 'vae_approx': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\vae_approx'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'controlnet': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\controlnet', 'C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\t2i_adapter'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'gligen': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\gligen'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'upscale_models': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\upscale_models'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'custom_nodes': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\custom_nodes'], set()), 'hypernetworks': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\hypernetworks'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'photomaker': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\photomaker'], {'.ckpt', '.pt', '.bin', '.sft', '.pth', '.safetensors', '.pkl'}), 'classifiers': (['C:\\Users\\there\\OneDrive\\Documents\\ComfyUI_windows_portable\\ComfyUI\\models\\classifiers'], {''})}
Traceback (most recent call last):
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\test.py", line 70, in
main()
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\test.py", line 20, in main
checkpointloadersimple_4 = checkpointloadersimple.load_checkpoint(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\nodes.py", line 539, in load_checkpoint
ckpt_path = folder_paths.get_full_path_or_raise("checkpoints", ckpt_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\there\OneDrive\Documents\ComfyUI_windows_portable\ComfyUI\folder_paths.py", line 284, in get_full_path_or_raise
raise FileNotFoundError(f"Model in folder '{folder_name}' with filename '{filename}' not found.")
FileNotFoundError: Model in folder 'checkpoints' with filename 'MODEL_NAME_HERE.safetensors' not found.
```
### Other
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.