{"record":{"id":"7e58c56d714fbf52","repo":"microsoft/qlib","slug":"astype-not-supported-astype","errorCode":null,"errorMessage":"astype not supported: {astype}","messagePattern":"astype not supported: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/rolling/ddgda.py","lineNumber":156,"sourceCode":"        \"\"\"\n        # NOTE: here is just for aligning with previous implementation\n        # It is not necessary for the current implementation\n        handler = task[\"dataset\"].setdefault(\"kwargs\", {}).setdefault(\"handler\", {})\n        if astype == \"gbdt\":\n            task[\"model\"] = LGBM_MODEL\n            if isinstance(handler, dict):\n                # We don't need preprocessing when using GBDT model\n                for k in [\"infer_processors\", \"learn_processors\"]:\n                    if k in handler.setdefault(\"kwargs\", {}):\n                        handler[\"kwargs\"].pop(k)\n        elif astype == \"linear\":\n            task[\"model\"] = LINEAR_MODEL\n            if isinstance(handler, dict):\n                handler[\"kwargs\"].update(PROC_ARGS)\n            else:\n                self.logger.warning(\"The handler can't be adjusted.\")\n        else:\n            raise ValueError(f\"astype not supported: {astype}\")\n        return task\n\n    def _get_feature_importance(self):\n        # this must be lightGBM, because it needs to get the feature importance\n        task = self.basic_task(enable_handler_cache=False)\n        task = self._adjust_task(task, astype=\"gbdt\")\n        task = replace_task_handler_with_cache(task, self.working_dir)\n\n        with R.start(experiment_name=\"feature_importance\"):\n            model = init_instance_by_config(task[\"model\"])\n            dataset = init_instance_by_config(task[\"dataset\"])\n            model.fit(dataset)\n\n        fi = model.get_feature_importance()\n        # Because the model use numpy instead of dataframe for training lightgbm\n        # So the we must use following extra steps to get the right feature importance\n        df = dataset.prepare(segments=slice(None), col_set=\"feature\", data_key=DataHandlerLP.DK_R)\n        cols = df.columns","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/rolling/ddgda.py#L138-L174","documentation":"DDGDA._adjust_task (qlib/contrib/rolling/ddgda.py) reconfigures the base task for either a GBDT model (dropping processors) or a linear model (adding PROC_ARGS). The astype argument must be exactly 'gbdt' or 'linear'; anything else raises ValueError('astype not supported: ...').","triggerScenarios":"Calling _adjust_task(task, astype=...) with a value other than 'gbdt' or 'linear', e.g. 'lstm', 'GBDT' (case-sensitive), or None. Internal call sites use astype='gbdt' for feature importance and the configured type elsewhere.","commonSituations":"Subclassing DDGDA and extending _adjust_task with a new model family without handling the new astype string; passing an uppercase or misspelled model type from a custom config.","solutions":["Use astype='gbdt' or astype='linear' exactly (lowercase)","If you subclass DDGDA, override _adjust_task to handle your custom astype values before delegating to super()","Check the value coming from your workflow config for typos or case differences"],"exampleFix":"# before\ntask = self._adjust_task(task, astype='GBDT')\n\n# after\ntask = self._adjust_task(task, astype='gbdt')","handlingStrategy":"validation","validationCode":"assert astype in ('gbdt', 'linear'), f'astype must be gbdt or linear, got {astype!r}'\ntask = self._adjust_task(task, astype=astype)","typeGuard":"def is_supported_astype(astype: str) -> bool:\n    return astype in {'gbdt', 'linear'}","tryCatchPattern":null,"preventionTips":["Lowercase and whitelist astype before calling _adjust_task","Subclasses adding model families should extend the accepted set inside their own override"],"tags":["qlib","rolling","ddgda","configuration"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}