class_docstr: Configuration object
  
  Provides default values configurable at different levels. The configuration object can have
  global default values, which may be overridden by user with yaml configuration files,
  environment variables or by setting directly the values in the configuration object. In order,
  direct definition overrides, environment variables, which overrides yaml configuration, which
  overrides default values in configuration object definition.
  
  Examples
  --------
  >>> config = Configuration()
  >>> config.add_option('test', str, 'hello', 'TEST_ENV')
  >>> config.test
  'hello'
  >>> config.load_yaml('some_config.yaml')
  >>> config.test
  'in yaml!'
  >>> os.environ['TEST_ENV'] = 'there!'
  >>> config.test
  'there!'
  >>> config.test = 'here'
  >>> config.test
  'here'
class_docstr_tok: ["Configuration","object","Provides","default","values","configurable","at","different","levels",".","The","configuration","object","can","have","global","default","values",",","which","may","be","overridden","by","user","with","yaml","configuration","files",",","environment","variables","or","by","setting","directly","the","values","in","the","configuration","object",".","In","order",",","direct","definition","overrides",",","environment","variables",",","which","overrides","yaml","configuration",",","which","overrides","default","values","in","configuration","object","definition",".","Examples","--","--","--","--",">",">",">","config","=","Configuration","(",")",">",">",">","config.add_option","(","'test","'",",","str",",","'hello","'",",","'TEST_ENV","'",")",">",">",">","config.test","'hello'",">",">",">","config.load_yaml","(","'some_config.yaml","'",")",">",">",">","config.test","'in","yaml","!","'",">",">",">","os.environ","[","'TEST_ENV","'","]","=","'there","!","'",">",">",">","config.test","'there","!","'",">",">",">","config.test","=","'here'",">",">",">","config.test","'here","'"]
docstr: Add arguments to an `argparse` parser based on configuration
  
  This does not support subconfigurations. They will be ignored.
  
  Parameters
  ----------
  parser: `argparse.ArgumentParser`
      Parser to which this function will add arguments
  rename: dict, optional
      Mappings to provide different commandline names. Ex `{key: --my-arg}`
docstr_tok: ["Add","arguments","to","an","`","argparse","`","parser","based","on","configuration","This","does","not","support","subconfigurations",".","They","will","be","ignored",".","Parameters","--","--","--","--","--","parser",":","`","argparse.ArgumentParser","`","Parser","to","which","this","function","will","add","arguments","rename",":","dict",",","optional","Mappings","to","provide","different","commandline","names",".","Ex","`","{","key",":","--","my-arg","}","`"]
code: def add_arguments(self, parser, rename=None):
      """Add arguments to an `argparse` parser based on configuration
  
      This does not support subconfigurations. They will be ignored.
  
      Parameters
      ----------
      parser: `argparse.ArgumentParser`
          Parser to which this function will add arguments
      rename: dict, optional
          Mappings to provide different commandline names. Ex `{key: --my-arg}`
  
      """
      if rename is None:
          rename = {}
  
      for key, item in self._config.items():
          # TODO: Try with list and nargs='*', but it may case issues with
          # nargs=argparse.REMAINDER.
          if item["type"] in (dict, list, tuple):
              continue
  
          # NOTE: Do not set default, if parser.parse_argv().options[key] is None, then code
          # should look to config[key].
          arg_name = rename.get(key, f"--{key.replace('_', '-')}")
          parser.add_argument(
              arg_name,
              type=item["type"],
              help=item.get("help"),
          )
  
imports: import contextlib
  import logging
  import os
  import pprint
  import yaml
label_desc: Use image node_id 13 for calling the Configuration obj's underlying member method code with example usage: obj.add_arguments(parser, rename) without return types