peal.global_utils.add_class_arguments

peal.global_utils.add_class_arguments(parser, config_class, base_str='')[source]

Add one command line argument per annotated config field.

Every annotation of config_class becomes --<base_str><name> with default None, so that only the flags actually passed override the config file. Fields whose type is itself a *Config class are recursed into with a dotted prefix (--data.input_size); for Union types the first member is inspected.

Parameters:
  • parser (argparse.ArgumentParser) – Parser the arguments are added to, in place.

  • config_class (type) – A pydantic config class.

  • base_str (str, optional) – Dotted prefix for nested configs.