Exemplo n.º 1
0
def load(config_file: Optional[Text]) -> List['Policy']:
    """Load policy data stored in the specified file."""

    if config_file and os.path.isfile(config_file):
        config_data = utils.read_yaml_file(config_file)
    else:
        raise ValueError("You have to provide a valid path to a config file. "
                         "The file '{}' could not be found."
                         "".format(os.path.abspath(config_file)))

    return PolicyEnsemble.from_dict(config_data)
Exemplo n.º 2
0
def load(config_file):
    # type: (Optional[Text], Dict[Text, Any], int) -> List[Policy]
    """Load policy data stored in the specified file. fallback_args and
    max_history are typically command line arguments. They take precedence
    over the arguments specified in the config yaml.
    """
    if config_file:
        config_data = utils.read_yaml_file(config_file)
    else:
        raise ValueError("You have to provide a config file")

    return PolicyEnsemble.from_dict(config_data)
Exemplo n.º 3
0
def load(config_file, fallback_args, max_history):
    # type: (Optional[Text], Dict[Text, Any], int) -> List[Policy]
    """Load policy data stored in the specified file. fallback_args and
    max_history are typically command line arguments. They take precedence
    over the arguments specified in the config yaml.
    """

    if config_file is None:
        return PolicyEnsemble.default_policies(fallback_args, max_history)

    config_data = utils.read_yaml_file(config_file)
    config_data = handle_precedence_and_defaults(config_data, fallback_args,
                                                 max_history)

    return PolicyEnsemble.from_dict(config_data)