ding.config¶
Config¶
- class ding.config.Config(cfg_dict: dict | None = None, cfg_text: str | None = None, filename: str | None = None)[source]¶
- Overview:
Base class for config.
- Interface:
__init__, file_to_dict
- Property:
cfg_dict
- __init__(cfg_dict: dict | None = None, cfg_text: str | None = None, filename: str | None = 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
read_config¶
- ding.config.read_config(path: str) Tuple[dict, dict] [source]¶
- Overview:
Read configuration from a file path(now only support python file). And select some proper parts.
- Arguments:
path (
str
): Path of configuration file
- Returns:
cfg (
Tuple[dict, dict]
): A collection(tuple) of configuration dict, divided into main_config and create_cfg two parts.
save_config¶
- ding.config.save_config(config_: dict, path: str, type_: str = 'py', save_formatted: bool = False) None [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.compile_config(cfg: ~easydict.EasyDict, env_manager: type | None = None, policy: type | None = None, learner: type = <class 'ding.worker.learner.base_learner.BaseLearner'>, collector: type | None = None, evaluator: type = <class 'ding.worker.collector.interaction_serial_evaluator.InteractionSerialEvaluator'>, buffer: type | None = None, env: type | None = None, reward_model: type | None = None, world_model: type | None = None, seed: int = 0, auto: bool = False, create_cfg: dict | None = None, save_cfg: bool = True, save_path: str = 'total_config.py', renew_dir: bool = True) 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 InteractionSerialEvaluatorbuffer (
type
): Input buffer class, defaults to IBufferenv (
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 filerenew_dir (
bool
): Whether to new a directory for saving config.
- Returns:
cfg (
EasyDict
): Config after compiling