[Python] fb-hydra: How to get inner configurations to inherit outer configuration fields?

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to write a hierarchical configuration structure such that config files in the inner directories inherit from the config files in the outer directories. For example, in the following scenario

    upper_config
    |
    |-middle_config
    | |
    | |-lower_config


    I would like middle_config to be able to inherit & override the parameters of upper_config, and lower_config to be able to inherit & override the parameters of both middle_config and upper_config.

    One solution would be to write a configuration parser such that outer modules are read first, and as inner modules are read they overwrite the fields in the outer modules.

    However, I would like to use Hydra (or some other tool, open to suggestions) for all of the added conveniences. I've read the documentation front to back a few times, and though it feels like either config groups or packages directives should be able to handle this, I can't quite piece it together.

    I believe this post asks a very similar question, but the answer hasn't enlightened me, and it seems that the person who asked the question decided to implement a version of the config parser I described above.

    I am hoping that there is a way for an inner config file's package directive to be changed to point to a parent configuration and somehow inherit its default list that way.

    Continue reading...

Compartilhe esta Página