default_ml_model() signature is stale: any task resolving ml_models dies with TypeError: unexpected keyword argument 'task_cls'
Symptom
Any task that resolves the ml_models default -- cf.PlotVariables1D, hbw.CustomCreateYieldTable,
and every other MLModelsMixin task -- fails during parameter resolution, before any work starts:
File "columnflow/tasks/framework/mixins.py", line 1643, in resolve_param_values_pre_init
params["ml_models"] = cls.resolve_config_default_and_groups(
File "columnflow/tasks/framework/base.py", line 791, in resolve_config_default_and_groups
File "columnflow/tasks/framework/base.py", line 681, in resolve_config_default
_param = _param(task_cls=cls, container=_container, task_params=task_params)
TypeError: default_ml_model() got an unexpected keyword argument 'task_cls'
Observed with columnflow v0.3.1-49-gd20db156.
Cause
columnflow calls the config's default_ml_model callable with keyword arguments:
# columnflow/tasks/framework/base.py:681
_param = _param(task_cls=cls, container=_container, task_params=task_params)
but hbw declares the first parameter as cls:
# hbw/config/sl_defaults_and_groups.py:39 (and hbw/config/defaults_and_groups.py:48)
def default_ml_model(cls, container, task_params):
Both are registered as config_inst.x.default_ml_model
(sl_defaults_and_groups.py:127, defaults_and_groups.py:123), so both are affected.
Suggested fix
Rename the first parameter to task_cls in both definitions, and accept **kwargs so a future
signature change upstream does not break it again:
def default_ml_model(task_cls, container, task_params, **kwargs):
cls = task_cls # keep the existing body unchanged
The body uses cls only via hasattr(cls, "ml_model"), so the rename is local.
Workaround
Pass --ml-models "" explicitly, which skips default resolution entirely.
Context
Hit while running the TOPO trigger sensitivity study (sl1_topo selector, l24v15); not specific
to that setup -- it reproduces on any plotting task that does not pin --ml-models.
default_ml_model()signature is stale: any task resolvingml_modelsdies withTypeError: unexpected keyword argument 'task_cls'Symptom
Any task that resolves the
ml_modelsdefault --cf.PlotVariables1D,hbw.CustomCreateYieldTable,and every other
MLModelsMixintask -- fails during parameter resolution, before any work starts:Observed with columnflow
v0.3.1-49-gd20db156.Cause
columnflow calls the config's
default_ml_modelcallable with keyword arguments:but hbw declares the first parameter as
cls:Both are registered as
config_inst.x.default_ml_model(
sl_defaults_and_groups.py:127,defaults_and_groups.py:123), so both are affected.Suggested fix
Rename the first parameter to
task_clsin both definitions, and accept**kwargsso a futuresignature change upstream does not break it again:
The body uses
clsonly viahasattr(cls, "ml_model"), so the rename is local.Workaround
Pass
--ml-models ""explicitly, which skips default resolution entirely.Context
Hit while running the TOPO trigger sensitivity study (
sl1_toposelector,l24v15); not specificto that setup -- it reproduces on any plotting task that does not pin
--ml-models.