config.config¶
config¶
Config¶
- class ding.config.Config(cfg_dict: Optional[dict] = None, cfg_text: Optional[str] = None, filename: Optional[str] = None)[source]¶
- Overview:
Base class for config.
- Interface:
__init__, file_to_dict
- Property:
cfg_dict
- __init__(cfg_dict: Optional[dict] = None, cfg_text: Optional[str] = None, filename: Optional[str] = None) → None[source]¶
- Overview:
Init method. Create config including dict type config and text type config.
- Arguments:
cfg_dict (
Optional[dict]): dict type configcfg_text (
Optional[str]): text type configfilename (
Optional[str]): config file name
- static _file_to_dict(filename: str) → Tuple[dict, str][source]¶
- Overview:
Read config file and convert the config file to dict type config and text type config.
- Arguments:
filename (
Optional[str]): config file name.
- Returns:
cfg_dict (
Optional[dict]): dict type configcfg_text (
Optional[str]): text type config
- static file_to_dict(filename: str) → ding.config.config.Config[source]¶
- Overview:
Read config file and create config.
- Arguments:
filename (
Optional[str]): config file name.
- Returns:
cfg_dict (
Config): config class
read_config_yaml¶
save_config_yaml¶
save_config_py¶
read_config¶
- ding.config.config.read_config(cfg: str, direct: bool = False) → Tuple[dict, dict][source]¶
- Overview:
read configuration from python file
- Arguments:
cfg (
str): Path of python filedirect (
bool): Read config directly if direct is true or divide config into main_config, create_config and system_config if direct is false
- Returns:
cfg (
Tuple[dict, dict]): Config dict, such as [main_config, create_config, system_config] or main_config, create_config, system_config
save_config¶
- ding.config.config.save_config(config_: dict, path: str, type_: str = 'py', save_formatted: bool = False) → NoReturn[source]¶
- Overview:
save configuration to python file or yaml file
- Arguments:
config (
dict): Config dictpath (
str): Path of target yaml or target python filetype (
str): If type isyaml, save configuration to yaml file. If type ispy, save configuration to python file.save_formatted (
bool): If save_formatted is true, save formatted config to path. Formatted config can be read by serial_pipeline directly.
compile_config¶
- ding.config.config.compile_config(cfg: easydict.EasyDict, env_manager: Optional[type] = None, policy: Optional[type] = None, learner: type = <class 'ding.worker.learner.base_learner.BaseLearner'>, collector: Optional[type] = None, evaluator: type = <class 'ding.worker.collector.base_serial_evaluator.BaseSerialEvaluator'>, buffer: Optional[type] = None, env: Optional[type] = None, reward_model: Optional[type] = None, seed: int = 0, auto: bool = False, create_cfg: Optional[dict] = None, save_cfg: bool = True, save_path: str = 'total_config.py') → easydict.EasyDict[source]¶
- Overview:
Combine the input config information with other input information. Compile config to make it easy to be called by other programs
- Arguments:
cfg (
EasyDict): Input config dict which is to be used in the following pipelineenv_manager (
type): Env_manager class which is to be used in the following pipelinepolicy (
type): Policy class which is to be used in the following pipelinelearner (
type): Input learner class, defaults to BaseLearnercollector (
type): Input collector class, defaults to BaseSerialCollectorevaluator (
type): Input evaluator class, defaults to BaseSerialEvaluatorbuffer (
type): Input buffer class, defaults to BufferManagerenv (
type): Environment class which is to be used in the following pipelinereward_model (
type): Reward model class which aims to offer various and valuable rewardseed (
int): Random number seedauto (
bool): Compile create_config dict or notcreate_cfg (
dict): Input create config dictsave_cfg (
bool): Save config or notsave_path (
str): Path of saving file
- Returns:
cfg (
EasyDict): Config after compiling
compile_config_parallel¶
- ding.config.config.compile_config_parallel(cfg: easydict.EasyDict, create_cfg: easydict.EasyDict, system_cfg: easydict.EasyDict, seed: int = 0, save_cfg: bool = True, save_path: str = 'total_config.py', platform: str = 'local', coordinator_host: Optional[str] = None, learner_host: Optional[str] = None, collector_host: Optional[str] = None, coordinator_port: Optional[int] = None, learner_port: Optional[int] = None, collector_port: Optional[int] = None) → easydict.EasyDict[source]¶
- Overview:
Combine the input parallel mode configuration information with other input information. Compile config to make it easy to be called by other programs
- Arguments:
cfg (
EasyDict): Input main config dictcreate_cfg (
dict): Input create config dict, including type parameters, such as environment typesystem_cfg (
dict): Input system config dict, including system parameters, such as file path, communication mode, use multiple GPUs or notseed (
int): Random number seedsave_cfg (
bool): Save config or notsave_path (
str): Path of saving fileplatform (
str): Where to run the program, ‘local’ or ‘slurm’coordinator_host (
Optional[str]): Input coordinator’s host when platform is slurmlearner_host (
Optional[str]): Input learner’s host when platform is slurmcollector_host (
Optional[str]): Input collector’s host when platform is slurm
- Returns:
cfg (
EasyDict): Config after compiling