Repository: microsoft/qlib
File: qlib/data/dataset/handler.py (Python)

Code before:
            The stock list to retrive.
        start_time :
            start_time of the original data.
        end_time :
            end_time of the original data.
        data_loader : Tuple[dict, str, DataLoader]
            data loader to load the data.
        init_data :
            intialize the original data in the constructor.
        fetch_orig : bool
            Return the original data instead of copy if possible.
        **kwargs:
            it will be passed into data_loader
        """
        # Set logger
        self.logger = get_module_logger("DataHandler")

        # Setup data loader
        assert data_loader is not None  # to make start_time end_time could have None default value

        # what data source to load data
        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,
            **kwargs,
        )

        # what data to be loaded from data source
        # For IDE auto-completion.
        self.instruments = instruments
        self.start_time = start_time
        self.end_time = end_time

        self.fetch_orig = fetch_orig
        if init_data:
            with TimeInspector.logt("Init data"):
                self.init()
        super().__init__()

    def conf_data(self, **kwargs):
        """
        configuration of data.
        # what data to be loaded from data source

        This method will be used when loading pickled handler from dataset.
        The data will be initialized with different time range.

        """
        attr_list = {"instruments", "start_time", "end_time"}
        for k, v in kwargs.items():

Review comment (suggestion):
Is it necessary to pass kwargs to `data_loader`?
I think all arguments of `data_loader` should be in config.

Code after:
        start_time :
            start_time of the original data.
        end_time :
            end_time of the original data.
        data_loader : Tuple[dict, str, DataLoader]
            data loader to load the data.
        init_data :
            intialize the original data in the constructor.
        fetch_orig : bool
            Return the original data instead of copy if possible.
        """
        # Set logger
        self.logger = get_module_logger("DataHandler")

        # Setup data loader
        assert data_loader is not None  # to make start_time end_time could have None default value

        # what data source to load data
        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,
        )

        # what data to be loaded from data source
        # For IDE auto-completion.
        self.instruments = instruments
        self.start_time = start_time
        self.end_time = end_time

        self.fetch_orig = fetch_orig
        if init_data:
            with TimeInspector.logt("Init data"):
                self.init()
        super().__init__()

    def conf_data(self, **kwargs):
        """
        configuration of data.
        # what data to be loaded from data source

        This method will be used when loading pickled handler from dataset.
        The data will be initialized with different time range.

        """
        attr_list = {"instruments", "start_time", "end_time"}
        for k, v in kwargs.items():
            if k in attr_list:
                setattr(self, k, v)
            else:
                raise KeyError("Such config is not supported.")