Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referenced Parameters for Configs? #1718

Open
davidslater opened this issue Oct 26, 2022 · 3 comments
Open

Referenced Parameters for Configs? #1718

davidslater opened this issue Oct 26, 2022 · 3 comments

Comments

@davidslater
Copy link
Contributor

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?

@mwartell
Copy link
Collaborator

mwartell commented Oct 26, 2022

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 mwartell self-assigned this Oct 26, 2022
@davidslater
Copy link
Contributor Author

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.

@dxoigmn
Copy link

dxoigmn commented Oct 27, 2022

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

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

No branches or pull requests

3 participants