microsoft/qlib · error · ValueError
astype not supported: {astype}
Error message
astype not supported: {astype} What it means
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: ...').
Source
Thrown at qlib/contrib/rolling/ddgda.py:156
"""
# NOTE: here is just for aligning with previous implementation
# It is not necessary for the current implementation
handler = task["dataset"].setdefault("kwargs", {}).setdefault("handler", {})
if astype == "gbdt":
task["model"] = LGBM_MODEL
if isinstance(handler, dict):
# We don't need preprocessing when using GBDT model
for k in ["infer_processors", "learn_processors"]:
if k in handler.setdefault("kwargs", {}):
handler["kwargs"].pop(k)
elif astype == "linear":
task["model"] = LINEAR_MODEL
if isinstance(handler, dict):
handler["kwargs"].update(PROC_ARGS)
else:
self.logger.warning("The handler can't be adjusted.")
else:
raise ValueError(f"astype not supported: {astype}")
return task
def _get_feature_importance(self):
# this must be lightGBM, because it needs to get the feature importance
task = self.basic_task(enable_handler_cache=False)
task = self._adjust_task(task, astype="gbdt")
task = replace_task_handler_with_cache(task, self.working_dir)
with R.start(experiment_name="feature_importance"):
model = init_instance_by_config(task["model"])
dataset = init_instance_by_config(task["dataset"])
model.fit(dataset)
fi = model.get_feature_importance()
# Because the model use numpy instead of dataframe for training lightgbm
# So the we must use following extra steps to get the right feature importance
df = dataset.prepare(segments=slice(None), col_set="feature", data_key=DataHandlerLP.DK_R)
cols = df.columnsView on GitHub (pinned to 79633dd950)
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
Example fix
# before task = self._adjust_task(task, astype='GBDT') # after task = self._adjust_task(task, astype='gbdt')
Defensive patterns
Strategy: validation
Validate before calling
assert astype in ('gbdt', 'linear'), f'astype must be gbdt or linear, got {astype!r}'
task = self._adjust_task(task, astype=astype) Type guard
def is_supported_astype(astype: str) -> bool:
return astype in {'gbdt', 'linear'} Prevention
- Lowercase and whitelist astype before calling _adjust_task
- Subclasses adding model families should extend the accepted set inside their own override
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- This type of input is not supported
- inner_order_indicators is necessary in un-atomic executor
- unknown loss `%s`
- unknown metric `%s`
- Empty data from dataset, please check your dataset config.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/7e58c56d714fbf52.
Report an issue: GitHub.