2
2
from typing import Sequence , Mapping , Any , Union
3
3
import sys
4
4
5
- sys .path .append (' ../' )
5
+ sys .path .append (" ../" )
6
6
7
7
8
8
def import_custom_nodes () -> None :
@@ -13,7 +13,7 @@ def import_custom_nodes() -> None:
13
13
"""
14
14
import asyncio
15
15
import execution
16
- from nodes import init_custom_nodes
16
+ from nodes import init_extra_nodes
17
17
import server
18
18
19
19
# Creating a new event loop and setting it as the default loop
@@ -25,18 +25,18 @@ def import_custom_nodes() -> None:
25
25
execution .PromptQueue (server_instance )
26
26
27
27
# Initializing custom nodes
28
- init_custom_nodes ()
28
+ init_extra_nodes ()
29
29
30
30
31
31
def find_path (name : str , path : str = None ) -> str :
32
32
"""
33
- Recursively looks at parent folders starting from the given path until it finds the given name.
33
+ Recursively looks at parent folders starting from the given path until it finds the given name.
34
34
Returns the path as a Path object if found, or None otherwise.
35
35
"""
36
36
# If no path is given, use the current working directory
37
37
if path is None :
38
38
path = os .getcwd ()
39
-
39
+
40
40
# Check if the current directory contains the name
41
41
if name in os .listdir (path ):
42
42
path_name = os .path .join (path , name )
@@ -58,7 +58,7 @@ def add_comfyui_directory_to_sys_path() -> None:
58
58
"""
59
59
Add 'ComfyUI' to the sys.path
60
60
"""
61
- comfyui_path = find_path (' ComfyUI' )
61
+ comfyui_path = find_path (" ComfyUI" )
62
62
if comfyui_path is not None and os .path .isdir (comfyui_path ):
63
63
sys .path .append (comfyui_path )
64
64
print (f"'{ comfyui_path } ' added to sys.path" )
@@ -68,15 +68,20 @@ def add_extra_model_paths() -> None:
68
68
"""
69
69
Parse the optional extra_model_paths.yaml file and add the parsed paths to the sys.path.
70
70
"""
71
- from main import load_extra_path_config
71
+ try :
72
+ from main import load_extra_path_config
73
+ except ImportError :
74
+ print (
75
+ "Could not import load_extra_path_config from main.py. Looking in utils.extra_config instead."
76
+ )
77
+ from utils .extra_config import load_extra_path_config
72
78
73
79
extra_model_paths = find_path ("extra_model_paths.yaml" )
74
-
80
+
75
81
if extra_model_paths is not None :
76
82
load_extra_path_config (extra_model_paths )
77
83
else :
78
84
print ("Could not find the extra_model_paths config file." )
79
-
80
85
81
86
82
87
def get_value_at_index (obj : Union [Sequence , Mapping ], index : int ) -> Any :
@@ -86,18 +91,18 @@ def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
86
91
If the object is a mapping (like a dictionary), returns the value at the index-th key.
87
92
88
93
Some return a dictionary, in these cases, we look for the "results" key
89
-
94
+
90
95
Args:
91
96
obj (Union[Sequence, Mapping]): The object to retrieve the value from.
92
97
index (int): The index of the value to retrieve.
93
-
98
+
94
99
Returns:
95
100
Any: The value at the given index.
96
-
101
+
97
102
Raises:
98
103
IndexError: If the index is out of bounds for the object and the object is not a mapping.
99
104
"""
100
105
try :
101
106
return obj [index ]
102
107
except KeyError :
103
- return obj [' result' ][index ]
108
+ return obj [" result" ][index ]
0 commit comments