Skip to content

Append new fields to primary YAML config by default #2457

Answered by Jasha10
addisonklinke asked this question in Q&A
Discussion options

You must be logged in to vote

I think passing an override will be the easiest way go, which means hacking sys.argv or using the the overrides keyword to compose.

Another idea is to use a different config as top-level and pull in configs/config.yaml as a subconfig:

# app2.py
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
from omegaconf import OmegaConf

@dataclass
class Extras:
    hello: str = "world"

cs = ConfigStore.instance()
cs.store(group="extras", name="example", package="_global_", node=Extras)

top_level_config = {
    "defaults": [
        "config",  # this pulls in `configs/config.yaml`
        {"extras": "example"},
    ]
}
cs.store(name="top_level_config", node

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by addisonklinke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants