@@ -224,6 +224,16 @@ def process_config(config: dict[str, Any]) -> list[ModelConfig]:
224224 for name , model_data in config .get ("models" , {}).items ()
225225 ]
226226
227+ def resolve_config_path_from_env_var () -> Path | None :
228+ """Resolve the config path from the environment variable."""
229+ config_dir = os .getenv ("VEC_INF_CONFIG_DIR" )
230+ config_path = os .getenv ("VEC_INF_MODEL_CONFIG" )
231+ if config_path :
232+ return Path (config_path )
233+ if config_dir :
234+ return Path (config_dir , "models.yaml" )
235+ return None
236+
227237 def update_config (
228238 config : dict [str , Any ], user_config : dict [str , Any ]
229239 ) -> dict [str , Any ]:
@@ -250,18 +260,16 @@ def update_config(
250260 config = load_yaml_config (default_path )
251261
252262 # 3. If user config exists, merge it
253- user_path = os .getenv ("VEC_INF_CONFIG_DIR" )
254- if user_path :
255- user_path_obj = Path (user_path , "models.yaml" )
256- if user_path_obj .exists ():
257- user_config = load_yaml_config (user_path_obj )
258- config = update_config (config , user_config )
259- else :
260- warnings .warn (
261- f"WARNING: Could not find user config directory: { user_path } , revert to default config located at { default_path } " ,
262- UserWarning ,
263- stacklevel = 2 ,
264- )
263+ user_path = resolve_config_path_from_env_var ()
264+ if user_path and user_path .exists ():
265+ user_config = load_yaml_config (user_path )
266+ config = update_config (config , user_config )
267+ elif user_path :
268+ warnings .warn (
269+ f"WARNING: Could not find user config: { str (user_path )} , revert to default config located at { default_path } " ,
270+ UserWarning ,
271+ stacklevel = 2 ,
272+ )
265273
266274 return process_config (config )
267275
0 commit comments