mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-14 00:06:58 +08:00
fix picker error on importlib loaded module
This commit is contained in:
@@ -8,6 +8,7 @@ from __future__ import print_function
|
|||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import yaml
|
import yaml
|
||||||
@@ -178,8 +179,10 @@ def get_module_by_module_path(module_path: Union[str, ModuleType]):
|
|||||||
module = module_path
|
module = module_path
|
||||||
else:
|
else:
|
||||||
if module_path.endswith(".py"):
|
if module_path.endswith(".py"):
|
||||||
module_spec = importlib.util.spec_from_file_location("", module_path)
|
module_name = "dummy"
|
||||||
|
module_spec = importlib.util.spec_from_file_location(module_name, module_path)
|
||||||
module = importlib.util.module_from_spec(module_spec)
|
module = importlib.util.module_from_spec(module_spec)
|
||||||
|
sys.modules[module_name] = module
|
||||||
module_spec.loader.exec_module(module)
|
module_spec.loader.exec_module(module)
|
||||||
else:
|
else:
|
||||||
module = importlib.import_module(module_path)
|
module = importlib.import_module(module_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user