From 2fa7ef32fbfec1bbb83ab96b0465bf3a6891579f Mon Sep 17 00:00:00 2001 From: Dong Zhou Date: Tue, 18 May 2021 22:37:31 +0800 Subject: [PATCH] fix picker error on importlib loaded module --- qlib/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qlib/utils/__init__.py b/qlib/utils/__init__.py index fe039df4f..dbbe69d43 100644 --- a/qlib/utils/__init__.py +++ b/qlib/utils/__init__.py @@ -179,7 +179,7 @@ def get_module_by_module_path(module_path: Union[str, ModuleType]): module = module_path else: if module_path.endswith(".py"): - module_name = "dummy" + module_name = re.sub("^[^a-zA-Z_]+", "", re.sub("[^0-9a-zA-Z_]", "", module_path[:-3].replace("/", "_"))) module_spec = importlib.util.spec_from_file_location(module_name, module_path) module = importlib.util.module_from_spec(module_spec) sys.modules[module_name] = module