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 a configuration setting.
  
  Parameters
  ----------
  key : str
      The name of the configuration setting. This must be a valid
      Python attribute name i.e. alphanumeric with underscores.
  option_type : function
      A function such as ``float``, ``int`` or ``str`` which takes
      the configuration value and returns an object of the correct
      type.  Note that the values retrieved from environment
      variables are always strings, while those retrieved from the
      YAML file might already be parsed. Hence, the function provided
      here must accept both types of input.
  default : object, optional
      The default configuration to return if not set. By default none
      is set and an error is raised instead.
  env_var : str, optional
      The environment variable name that holds this configuration
      value. If not given, this configuration can only be set in the
      YAML configuration file.
  deprecate: `dict`, optional
      Should define dict(version, alternative), version at which the deprecated option will be
      removed and alternative to use. A deprecation warning will be logged each time this
      option is set by user. The option `name` can be used in addition to `version` and
      `alternative` to provide a different name then the key. This is useful if the key
      is in a subconfiguration and we want the deprecation error message to include the full
      path. This will add (DEPRECATED) at the beginning of the help message.
  help : str, optional
      Documentation for the option. Can be reused to build documentation
      or to build parsers with help messages.
      Default help message is 'Undocumented'.
docstr_tok: ["Add","a","configuration","setting",".","Parameters","--","--","--","--","--","key",":","str","The","name","of","the","configuration","setting",".","This","must","be","a","valid","Python","attribute","name","i.e",".","alphanumeric","with","underscores",".","option_type",":","function","A","function","such","as","``","float","``",",","``","int","``","or","``","str","``","which","takes","the","configuration","value","and","returns","an","object","of","the","correct","type",".","Note","that","the","values","retrieved","from","environment","variables","are","always","strings",",","while","those","retrieved","from","the","YAML","file","might","already","be","parsed",".","Hence",",","the","function","provided","here","must","accept","both","types","of","input",".","default",":","object",",","optional","The","default","configuration","to","return","if","not","set",".","By","default","none","is","set","and","an","error","is","raised","instead",".","env_var",":","str",",","optional","The","environment","variable","name","that","holds","this","configuration","value",".","If","not","given",",","this","configuration","can","only","be","set","in","the","YAML","configuration","file",".","deprecate",":","`","dict","`",",","optional","Should","define","dict","(","version",",","alternative",")",",","version","at","which","the","deprecated","option","will","be","removed","and","alternative","to","use",".","A","deprecation","warning","will","be","logged","each","time","this","option","is","set","by","user",".","The","option","`","name","`","can","be","used","in","addition","to","`","version","`","and","`","alternative","`","to","provide","a","different","name","then","the","key",".","This","is","useful","if","the","key","is","in","a","subconfiguration","and","we","want","the","deprecation","error","message","to","include","the","full","path",".","This","will","add","(","DEPRECATED",")","at","the","beginning","of","the","help","message",".","help",":","str",",","optional","Documentation","for","the","option",".","Can","be","reused","to","build","documentation","or","to","build","parsers","with","help","messages",".","Default","help","message","is","'Undocumented","'","."]
code: def add_option(
      self,
      key,
      option_type,
      default=NOT_SET,
      env_var=None,
      deprecate=None,
      help=None,
  ):
      """Add a configuration setting.
  
      Parameters
      ----------
      key : str
          The name of the configuration setting. This must be a valid
          Python attribute name i.e. alphanumeric with underscores.
      option_type : function
          A function such as ``float``, ``int`` or ``str`` which takes
          the configuration value and returns an object of the correct
          type.  Note that the values retrieved from environment
          variables are always strings, while those retrieved from the
          YAML file might already be parsed. Hence, the function provided
          here must accept both types of input.
      default : object, optional
          The default configuration to return if not set. By default none
          is set and an error is raised instead.
      env_var : str, optional
          The environment variable name that holds this configuration
          value. If not given, this configuration can only be set in the
          YAML configuration file.
      deprecate: `dict`, optional
          Should define dict(version, alternative), version at which the deprecated option will be
          removed and alternative to use. A deprecation warning will be logged each time this
          option is set by user. The option `name` can be used in addition to `version` and
          `alternative` to provide a different name then the key. This is useful if the key
          is in a subconfiguration and we want the deprecation error message to include the full
          path. This will add (DEPRECATED) at the beginning of the help message.
      help : str, optional
          Documentation for the option. Can be reused to build documentation
          or to build parsers with help messages.
          Default help message is 'Undocumented'.
  
      """
      key = _curate(key)
      if key in self._config or key in self._subconfigs:
          raise ValueError(f"Configuration already contains {key}")
      self._config[key] = {"type": option_type}
      if env_var is not None:
          self._config[key]["env_var"] = env_var
      if default is not NOT_SET:
          self._config[key]["default"] = default
      if deprecate is not None:
          if "version" not in deprecate:
              raise ValueError(
                  f"`version` is missing in deprecate option: {deprecate}"
              )
          self._config[key]["deprecated"] = deprecate
  
      if help is None:
          help = "Undocumented"
  
      if default is not NOT_SET:
          help += f" (default: {default})"
      if deprecate is not None:
          help = "(DEPRECATED) " + help
      self._config[key]["help"] = help
  
imports: import contextlib
  import logging
  import os
  import pprint
  import yaml
label_desc: Use image node_id 11 for calling the Configuration obj's underlying member method code with example usage: obj.add_option(key, option_type, default, env_var, deprecate, help) without return types