Skip to content

Conditional parameters #8283

@schwobr

Description

@schwobr

I'd like to be able to select a set of parameters depending on another parameter. I've looked into it quite a bit and I don't think it is a current feature, but don't hesitate to tell me if I'm mistaken.

To be more clear, I would like my params.yaml to look like this:

selector_param: A
dependent_params:
   A:
      p1: a1
      p2: a2
   B:
      p1: b1
      p2: b2

Then I could load the corresponding set of dependent_params depending on the selector_param. I thought about several ways of doing this but none seemed to work:

  • Use nested templating, like ${dependent_params.${selector_param}}. I don't find this option very elegant.
  • Have several parameters files (A.yaml, B.yaml) for each option and load the right one in vars depending on selector_param. I thought this would work but it seems like templating is disabled in vars.
  • In a similar vein, I could put all the dependent params in another file dependent_params.yaml and then load them in vars using templating. That would require to be able to rename the loaded params to avoid nested templating, like dependent_params.yaml:${selector_param} as selected_params. That would allow to do something like ${selected_params.p1}
  • Create a new keyword in dvc.yaml that could look like:
param_load:
  from: dependent_params
  key: ${selector_param}
cmd: python script.py ${dependent_params}

There are probably other solutions, but all in all I feel this would be a nice feature to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions