class_docstr: The abstract base class of experiment config classes.
  
  A config class should be a type-hinted dataclass inheriting ``ConfigBase``.
  Or for a training service config class, it can inherit ``TrainingServiceConfig``.
  
  .. code-block:: python
  
      @dataclass(init=False)
      class ExperimentConfig(ConfigBase):
          name: Optional[str]
          ...
  
  Subclasses are suggested to override ``_canonicalize()`` and ``_validate_canonical()`` methods.
  
  Users can create a config object with constructor or ``ConfigBase.load()``,
  validate its legality with ``ConfigBase.validate()``,
  and finally convert it to the format accepted by NNI manager with ``ConfigBase.json()``.
  
  Example usage:
  
  .. code-block:: python
  
      # when using Python API
      config1 = ExperimentConfig(trialCommand='...', trialConcurrency=1, ...)
      config1.validate()
      print(config1.json())
  
      # when using config file
      config2 = ExperimentConfig.load('examples/config.yml')
      config2.validate()
      print(config2.json())
  
  Config objects will remember where they are loaded; therefore relative paths can be resolved smartly.
  If a config object is created with constructor, the base path will be current working directory.
  If it is loaded with ``ConfigBase.load(path)``, the base path will be ``path``'s parent.
  
  .. attention::
  
      All the classes that inherit ``ConfigBase`` are not allowed to use ``from __future__ import annotations``,
      because ``ConfigBase`` uses ``typeguard`` to perform runtime check and it does not support lazy annotations.
class_docstr_tok: ["The","abstract","base","class","of","experiment","config","classes",".","A","config","class","should","be","a","type-hinted","dataclass","inheriting","``","ConfigBase","``",".","Or","for","a","training","service","config","class",",","it","can","inherit","``","TrainingServiceConfig","``",".","..","code-block",":",":","python","@","dataclass","(","init=False",")","class","ExperimentConfig","(","ConfigBase",")",":","name",":","Optional","[","str","]","...","Subclasses","are","suggested","to","override","``","_canonicalize","(",")","``","and","``","_validate_canonical","(",")","``","methods",".","Users","can","create","a","config","object","with","constructor","or","``","ConfigBase.load","(",")","``",",","validate","its","legality","with","``","ConfigBase.validate","(",")","``",",","and","finally","convert","it","to","the","format","accepted","by","NNI","manager","with","``","ConfigBase.json","(",")","``",".","Example","usage",":","..","code-block",":",":","python","#","when","using","Python","API","config1","=","ExperimentConfig","(","trialCommand=","'","...","'",",","trialConcurrency=1",",","...",")","config1.validate","(",")","print","(","config1.json","(",")",")","#","when","using","config","file","config2","=","ExperimentConfig.load","(","'examples\/config.yml","'",")","config2.validate","(",")","print","(","config2.json","(",")",")","Config","objects","will","remember","where","they","are","loaded",";","therefore","relative","paths","can","be","resolved","smartly",".","If","a","config","object","is","created","with","constructor",",","the","base","path","will","be","current","working","directory",".","If","it","is","loaded","with","``","ConfigBase.load","(","path",")","``",",","the","base","path","will","be","``","path","``","'s","parent",".","..","attention",":",":","All","the","classes","that","inherit","``","ConfigBase","``","are","not","allowed","to","use","``","from","__future__","import","annotations","``",",","because","``","ConfigBase","``","uses","``","typeguard","``","to","perform","runtime","check","and","it","does","not","support","lazy","annotations","."]
docstr: Load a YAML config file from file system.
  
  Since YAML is a superset of JSON, it can also load JSON files.
  
  This method raises exception if:
  
  - The file is not available
  - The file content is not valid YAML
  - Top level value of the YAML is not object
  - The YAML contains not supported fields
  
  It does not raise exception when the YAML misses fields or contains bad fields.
  
  Parameters
  ----------
  path : PathLike
      Path of the config file.
  
  Returns
  -------
  cls
      An object of ConfigBase subclass.
docstr_tok: ["Load","a","YAML","config","file","from","file","system",".","Since","YAML","is","a","superset","of","JSON",",","it","can","also","load","JSON","files",".","This","method","raises","exception","if",":","-","The","file","is","not","available","-","The","file","content","is","not","valid","YAML","-","Top","level","value","of","the","YAML","is","not","object","-","The","YAML","contains","not","supported","fields","It","does","not","raise","exception","when","the","YAML","misses","fields","or","contains","bad","fields",".","Parameters","--","--","--","--","--","path",":","PathLike","Path","of","the","config","file",".","Returns","--","--","--","-","cls","An","object","of","ConfigBase","subclass","."]
code: def load(cls, path):
      """
      Load a YAML config file from file system.
  
      Since YAML is a superset of JSON, it can also load JSON files.
  
      This method raises exception if:
  
      - The file is not available
      - The file content is not valid YAML
      - Top level value of the YAML is not object
      - The YAML contains not supported fields
  
      It does not raise exception when the YAML misses fields or contains bad fields.
  
      Parameters
      ----------
      path : PathLike
          Path of the config file.
  
      Returns
      -------
      cls
          An object of ConfigBase subclass.
      """
      with open(path, encoding="utf_8") as yaml_file:
          data = yaml.safe_load(yaml_file)
      if not isinstance(data, dict):
          raise TypeError(
              f"Conent of config file {path} is not a dict/object"
          )
      utils.set_base_path(Path(path).parent)
      config = cls(**data)
      utils.unset_base_path()
      return config
  
file_path: nni/nni/experiment/config/base.py
imports: import copy
  import dataclasses
  from pathlib import Path
  import yaml
  from .None import utils
label_desc: Use image node_id 2 for calling the ConfigBase obj's underlying member method code with example usage: obj.load(cls, path) and returns: config