Skip to content

Support for a config_path root key name #356

Description

@actuallyaswin

I saw the following comment in the SimpleParsing source code:

                # The file should have the same format as the command-line args, e.g. contain the
                # fields of the 'root' dataclass directly (e.g. "foo: 123"), rather a dict with
                # "config: foo: 123" where foo is a field of the root dataclass at dest 'config'.
                # Therefore, we add the prefix back here.

So it sounds like, if I was to use a config path in my main.py, e.g.:

@dataclass
class MyDataClass:
    a: int
    b: str

args = simple_parsing.parse(MyDataClass, config_path="config.yaml")

Then config.yaml would have to look like:

a: 12
b: test

Now say for example, due to some other external stipulation, I needed to have a root-level grouping in my config.yaml, e.g.:

parameters:
  a: 12
  b: test

Is there a feature that allows me to lookup that root key first before doing the parse? Something like:

args = simple_parsing.parse(
  MyDataClass, 
  config_path="config.yaml",
  config_root_key="parameters")

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions