33
33
34
34
import execution
35
35
import server
36
+ import folder_paths
37
+ import yaml
36
38
37
39
def prompt_worker (q , server ):
38
40
e = execution .PromptExecutor (server )
@@ -59,6 +61,26 @@ def cleanup_temp():
59
61
if os .path .exists (temp_dir ):
60
62
shutil .rmtree (temp_dir , ignore_errors = True )
61
63
64
+ def load_extra_path_config (yaml_path ):
65
+ with open (yaml_path , 'r' ) as stream :
66
+ config = yaml .safe_load (stream )
67
+ for c in config :
68
+ conf = config [c ]
69
+ if conf is None :
70
+ continue
71
+ base_path = None
72
+ if "base_path" in conf :
73
+ base_path = conf .pop ("base_path" )
74
+ for x in conf :
75
+ for y in conf [x ].split ("\n " ):
76
+ if len (y ) == 0 :
77
+ continue
78
+ full_path = y
79
+ if base_path is not None :
80
+ full_path = os .path .join (base_path , full_path )
81
+ print ("Adding extra search path" , x , full_path )
82
+ folder_paths .add_model_folder_path (x , full_path )
83
+
62
84
if __name__ == "__main__" :
63
85
cleanup_temp ()
64
86
@@ -79,6 +101,15 @@ def cleanup_temp():
79
101
if '--dont-print-server' in sys .argv :
80
102
dont_print = True
81
103
104
+ extra_model_paths_config_path = os .path .join (os .path .dirname (os .path .realpath (__file__ )), "extra_model_paths.yaml" )
105
+ if os .path .isfile (extra_model_paths_config_path ):
106
+ load_extra_path_config (extra_model_paths_config_path )
107
+
108
+ if '--extra-model-paths-config' in sys .argv :
109
+ indices = [(i + 1 ) for i in range (len (sys .argv ) - 1 ) if sys .argv [i ] == '--extra-model-paths-config' ]
110
+ for i in indices :
111
+ load_extra_path_config (sys .argv [i ])
112
+
82
113
port = 8188
83
114
try :
84
115
p_index = sys .argv .index ('--port' )
0 commit comments