{"record":{"id":"e6ded14ed2ee8873","repo":"microsoft/qlib","slug":"implement-this-method-if-you-want-to-use-expressio","errorCode":null,"errorMessage":"Implement this method if you want to use expression cache","messagePattern":"Implement this method if you want to use expression cache","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/data/cache.py","lineNumber":360,"sourceCode":"        \"\"\"\n        try:\n            return self._expression(instrument, field, start_time, end_time, freq)\n        except NotImplementedError:\n            return self.provider.expression(instrument, field, start_time, end_time, freq)\n\n    def _uri(self, instrument, field, start_time, end_time, freq):\n        \"\"\"Get expression cache file uri.\n\n        Override this method to define how to get expression cache file uri corresponding to users' own cache mechanism.\n        \"\"\"\n        raise NotImplementedError(\"Implement this function to match your own cache mechanism\")\n\n    def _expression(self, instrument, field, start_time, end_time, freq):\n        \"\"\"Get expression data using cache.\n\n        Override this method to define how to get expression data corresponding to users' own cache mechanism.\n        \"\"\"\n        raise NotImplementedError(\"Implement this method if you want to use expression cache\")\n\n    def update(self, cache_uri: Union[str, Path], freq: str = \"day\"):\n        \"\"\"Update expression cache to latest calendar.\n\n        Override this method to define how to update expression cache corresponding to users' own cache mechanism.\n\n        Parameters\n        ----------\n        cache_uri : str or Path\n            the complete uri of expression cache file (include dir path).\n        freq : str\n\n        Returns\n        -------\n        int\n            0(successful update)/ 1(no need to update)/ 2(update failure).\n        \"\"\"\n        raise NotImplementedError(\"Implement this method if you want to make expression cache up to date\")","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/cache.py#L342-L378","documentation":"Error \"Implement this method if you want to use expression cache\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/data/cache.py:360 when the guard condition fails: \"Implement this method if you want to use expression cache\". 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":["Implement the `update` method in your expression cache subclass to keep the cache up to date.","Use the built-in DiskExpressionCache which implements this method."],"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"}