armory icon indicating copy to clipboard operation
armory copied to clipboard

Referenced Parameters for Configs?

Open davidslater opened this issue 2 years ago • 3 comments

Often a single parameter needs be reused in multiple places; this requires modifying it consistently across a config file.

Is there a principled way of having a "@param(targeted)" sort of field in the JSON that is replaced with values from some _params: {targeted = True, ...} dict in the JSON?

davidslater avatar Oct 26 '22 20:10 davidslater

This is the sort of hierarchical configuration that hydra (hydra-zen) affords. A simple use is shown at https://hydra.cc/docs/tutorials/basic/your_first_app/config_groups/ where the command line

python my_app.py +db=postgresql

creates a top-level db member the body of which is filled in by reference from postegresql.yaml yielding

db:
  driver: postgresql
  pass: drowssap
  timeout: 10
  user: postgres_user

Mapping to your request would be something like

$ cat targeted.yaml
 _params:
     targeted: true
     thingy: art.thingy.method

with

 armory run experiments/carla_mot.yaml +attack.foo=targeted +defense.foo=targeted

with similar sub-configurations in untargeted.yaml

mwartell avatar Oct 26 '22 21:10 mwartell

What I am trying to prevent is the +attack.foo=targeted +defense.foo=targeted sort of thing. I would rather be able to do armory run experiments/carla_mot.yaml +targeted=false

This comes up, for instance, in what format data annotations are. (E.g., COCO format vs MOT format). This format type needs to be propagated to the dataset, metrics, model, and (sometimes) attack.

davidslater avatar Oct 26 '22 22:10 davidslater

OmegaConf (which is what Hydra uses under the hood for configuration) accomplishes this via variable interpolation: https://omegaconf.readthedocs.io/en/2.2_branch/usage.html#variable-interpolation

dxoigmn avatar Oct 27 '22 00:10 dxoigmn