facebookresearch/hydra

[Feature Request] Append to a list from command line

KeAWang opened this issue ยท 8 comments

๐Ÿš€ Feature Request

I don't think there's a way to do this currently, but it would be great if we could append to a list from the command line. For example say my config.yaml has

extras:
    tags: [experiment, trial_1]

It would be great if we could do something like: extras.tags+="[another_tag, yet_another_tag]" in the command line interface instead of having to retype the old entries in the list: extras.tags="[experiment, trial_1, another_tag, yet_another_tag]"

omry commented

Thanks for the feature request.
This is not currently supported and is something we can consider for a future version.
There are some upcoming enhancements to OmegaConf that will offer an alternative approach for this (which will be available in Hydra 1.1), so we may end up sticking to those.

As a side note: adding support for += operator is a pretty big deal.
We do have generic functions support which we might leverage instead.

e.g:

"extras.tags=append([another_tag, yet_another_tag])"

It's a bit odd but will not introduce a change to something very fundamental.

any updates on this?

Thanks for the ping @yunfanjiang. No updates yet.

Thumbs up for this feature

Something like tags+="[another_tag]" would be very useful!

The feature requests this for the command line, but that's not possible through configuration files either right? The use case I'm looking for is tags very much like @ashleve mentioned.

but that's not possible through configuration files either right?

Currently there is no elegant solution. There are some clunky solutions, usually involving OmegaConf's oc.dict.values resolver. The standard approach is to create a "tags dict" instead of a "tags list". The values of the tag dict can then be converted into a list.

See the comments here and here for an example of how to apply such a recipe using the defaults list.

Would be a cool feature to have e.g. if you conduct a test run and want to tag them to just be able to logger.tags+="[test_tag]" rather than having to specify all the other tags as well (which change if I want to train with different config presets).

up on this !