{"record":{"id":"97d15b7275cb5e5a","repo":"microsoft/qlib","slug":"no-data-to-sync-to-disk","errorCode":null,"errorMessage":"No data to sync to disk.","messagePattern":"No data to sync to disk\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/cache.py","lineNumber":815,"sourceCode":"        This class is the proxy of the disk data.\n        \"\"\"\n\n        KEY = \"df\"\n\n        def __init__(self, cache_path: Union[str, Path]):\n            self.index_path = cache_path.with_suffix(\".index\")\n            self._data = None\n            self.logger = get_module_logger(self.__class__.__name__)\n\n        def get_index(self, start_time=None, end_time=None):\n            # TODO: fast read index from the disk.\n            if self._data is None:\n                self.sync_from_disk()\n            return self._data.loc[start_time:end_time].copy()\n\n        def sync_to_disk(self):\n            if self._data is None:\n                raise ValueError(\"No data to sync to disk.\")\n            self._data.sort_index(inplace=True)\n            self._data.to_hdf(self.index_path, key=self.KEY, mode=\"w\", format=\"table\")\n            # The index should be readable for all users\n            self.index_path.chmod(stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)\n\n        def sync_from_disk(self):\n            # The file will not be closed directly if we read_hdf from the disk directly\n            with pd.HDFStore(self.index_path, mode=\"r\") as store:\n                if \"/{}\".format(self.KEY) in store.keys():\n                    self._data = pd.read_hdf(store, key=self.KEY)\n                else:\n                    self._data = pd.DataFrame()\n\n        def update(self, data, sync=True):\n            self._data = data.astype(np.int32).copy()\n            if sync:\n                self.sync_to_disk()\n","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/cache.py#L797-L833","documentation":"Error \"No data to sync to disk.\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/data/cache.py:815 when the guard condition fails: \"No data to sync to disk.\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Ensure there is data in the cache before calling sync/flush to disk.","Check that the cache was populated (e.g. features were queried) before triggering the sync."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}