dvc icon indicating copy to clipboard operation
dvc copied to clipboard

Support Access of Dictionary Items in matrix-stages

Open mfakaehler opened this issue 3 years ago • 2 comments

When I work with matrix-stages I would like to use further parameters for each item, specified in the params.yaml A prototpy-stage would look like

# dvc.yaml
stages:
  eval:
    matrix:
      model: ${models}
      testset: ${testsets}
   cmd: python src/eval_script.py --model ${item.model} --evalset ${item.evalset} --model-family ${item.model.family}
...

And the params.yaml would be:

# params.yaml
models:
  m1:
    family: b21
  m2: 
    family: x22
      
testsets: [evalA, evalB]

This is similar to foreach-stages, where you can access properties by calling ${item.property}

mfakaehler avatar Nov 14 '23 09:11 mfakaehler

@skshetry Thoughts on this request?

dberenbaum avatar Nov 27 '23 13:11 dberenbaum

This seems a natural functionality to be present, similar to foreach indeed. I've got a two-in-one case to use. Having large data split in multiple subdirectories, and several preprocessors, I generate matrix stages, one per (preprocessor x data_subdir).

  1. I have several dict configs defining subsets of data subdirs, and would like to combine them via Hydra. But since Hydra supports only dict extension and not list extension (and matrix can't access items of dict), this seems impossible atm (requires creating additional config files for each combination).
  2. For each preprocessor (dict config), I'd like to place a dependency on file containing it's class. Once again, can't access the type from dict config in matrix. Could be accessed in via nested interpolation from main config, but that doesn't work as well.

jogepari avatar Dec 05 '23 09:12 jogepari