qlib icon indicating copy to clipboard operation
qlib copied to clipboard

fix panic during normalizing the invalid data

Open m3ngyang opened this issue 1 year ago • 2 comments

Description

Fix the panic when normalizing the invalid data.

Before the fix:

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "scripts/data_collector/yahoo/collector.py", line 1018, in <module>
    fire.Fire(Run)
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "scripts/data_collector/yahoo/collector.py", line 837, in normalize_data
    super(Run, self).normalize_data(
  File "/home/yang/Workspace/github.com/m3ngyang/qlib/scripts/data_collector/base.py", line 438, in normalize_data
    yc.normalize()
  File "/home/yang/Workspace/github.com/m3ngyang/qlib/scripts/data_collector/base.py", line 317, in normalize
    for _ in worker.map(self._executor, file_list):
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/concurrent/futures/process.py", line 484, in _chain_from_iterable_of_lists
    for element in iterable:
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
    yield fs.pop().result()
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/home/yang/Devenv/miniconda/envs/qlib/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
KeyError: datetime.date(2015, 1, 2)

After the fix:

image

Motivation and Context

How Has This Been Tested?

  • [x] Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • [ ] If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Pipeline test: image

  2. Your own tests:

Types of changes

  • [x] Fix bugs
  • [ ] Add new feature
  • [ ] Update documentation

m3ngyang avatar Nov 22 '23 12:11 m3ngyang

@you-n-g hi, please help review the pr. thx.

m3ngyang avatar Nov 23 '23 02:11 m3ngyang

@microsoft-github-policy-service agree

m3ngyang avatar Nov 23 '23 15:11 m3ngyang