File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -227,13 +227,16 @@ def get_models(
227227 logging .info (
228228 f"Loading models from { path } . Errors below are likely due to the model."
229229 )
230- prev_sys_path = copy .deepcopy (sys .path )
231- sys .path .append (os .path .dirname (os .path .abspath (path )))
232- python_module = SourceFileLoader (f"model{ n_models } " , path ).load_module ()
230+ abs_dir = os .path .dirname (os .path .abspath (path ))
231+ base_name = os .path .splitext (os .path .basename (path ))[0 ]
232+ module_name = f"_hwc_model_{ base_name } _{ n_models } "
233+ if abs_dir not in sys .path :
234+ sys .path .append (abs_dir )
235+ python_module = SourceFileLoader (module_name , path ).load_module ()
236+ sys .modules [module_name ] = python_module
233237 new_models += get_models_in_module (
234238 python_module , model_ids , _return_wrappers
235239 )
236- sys .path = prev_sys_path
237240 n_models += 1
238241
239242 if not new_models :
You can’t perform that action at this time.
0 commit comments