Exemplo n.º 1
0
def configure(config={}, gym_level=gym.logger.INFO):
    """
        Configure logging.

        Update the default configuration by a configuration file.
        Also configure the gym logger.

    :param config: logging configuration, or path to a configuration file
    :param gym_level: desired level for gym logger
    """
    if config:
        if isinstance(config, str):
            with Path(config).open() as f:
                config = json.load(f)
        Configurable.rec_update(logging_config, config)
    logging.config.dictConfig(logging_config)
    gym.logger.set_level(gym_level)
Exemplo n.º 2
0
def load_agent_config(config_path):
    """
        Load an agent configuration from file, with inheritance.
    :param config_path: path to a json config file
    :return: the configuration dict
    """
    with open(config_path) as f:
        agent_config = json.loads(f.read())
    if "base_config" in agent_config:
        base_config = load_agent_config(agent_config["base_config"])
        del agent_config["base_config"]
        agent_config = Configurable.rec_update(base_config, agent_config)
    return agent_config
Exemplo n.º 3
0
def load_environment_config(env_config):
    """
        Load an environment from a configuration file.

    :param env_config: the configuration, or path to the environment configuration file
    :return: the environment
    """
    if not isinstance(env_config, dict):
        with open(env_config) as f:
            env_config = json.loads(f.read())

    if "base_config" in env_config:
        base_config = load_environment_config(env_config["base_config"])
        # del env_config["base_config"]
        env_config = Configurable.rec_update(base_config, env_config)
    return env_config