Skip to content

default_ml_model() signature stale: TypeError 'task_cls' breaks every task that resolves ml_models #157

Description

@artlbv

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions