mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 14:56:55 +08:00
fix data_loader dict type bug
This commit is contained in:
@@ -62,9 +62,11 @@ class DataHandler(Serializable):
|
||||
|
||||
# Setup data loader
|
||||
assert data_loader is not None # to make start_time end_time could have None default value
|
||||
self.data_loader = init_instance_by_config(data_loader,
|
||||
None if 'module_path' in data_loader else data_loader_module,
|
||||
accept_types=DataLoader)
|
||||
|
||||
self.data_loader = init_instance_by_config(
|
||||
data_loader,
|
||||
None if (isinstance(data_loader, dict) and 'module_path' in data_loader) else data_loader_module,
|
||||
accept_types=DataLoader)
|
||||
|
||||
self.instruments = instruments
|
||||
self.start_time = start_time
|
||||
|
||||
@@ -195,22 +195,24 @@ def get_cls_kwargs(config: Union[dict, str], module) -> (type, dict):
|
||||
|
||||
|
||||
def init_instance_by_config(
|
||||
config: Union[str, dict], module=None, accept_types: Union[type, Tuple[type]] = tuple([]), **kwargs
|
||||
config: Union[str, dict, object], module=None, accept_types: Union[type, Tuple[type]] = tuple([]), **kwargs
|
||||
) -> object:
|
||||
"""
|
||||
get initialized instance with config
|
||||
|
||||
Parameters
|
||||
----------
|
||||
config : Union[str, dict]
|
||||
config : Union[str, dict, object]
|
||||
dict example.
|
||||
{
|
||||
'class': 'ClassName',
|
||||
'kwargs': dict, # It is optional. {} will be used if not given
|
||||
'model_path': path, # It is optional if module is given
|
||||
}
|
||||
{
|
||||
'class': 'ClassName',
|
||||
'kwargs': dict, # It is optional. {} will be used if not given
|
||||
'model_path': path, # It is optional if module is given
|
||||
}
|
||||
str example.
|
||||
"ClassName": getattr(module, config)() will be used.
|
||||
"ClassName": getattr(module, config)() will be used.
|
||||
object example:
|
||||
instance of accept_types
|
||||
module : Python module
|
||||
Optional. It should be a python module.
|
||||
NOTE: the "module_path" will be override by `module` arguments
|
||||
|
||||
Reference in New Issue
Block a user