Skip to content

aea.helpers.env_vars

Implementation of the environment variables support.

is_env_variable

def is_env_variable(value: Any) -> bool

Check is variable string with env variable pattern.

restrict_model_args

def restrict_model_args(export_path: List[str]) -> Tuple[List[str], List[str]]

Do not allow more levels than one for a model's argument.

export_path_to_env_var_string

def export_path_to_env_var_string(
        export_path: List[str]) -> Tuple[List[str], str]

Convert export path to environment variable string.

parse_list

def parse_list(var_prefix: str, env_variables: dict) -> str

Parse list object.

replace_with_env_var

def replace_with_env_var(value: str,
                         env_variables: dict,
                         default_value: Any = NotSet,
                         default_var_name: Optional[str] = None) -> JSON_TYPES

Replace env var with value.

apply_env_variables

def apply_env_variables(data: Union[Dict, List[Dict]],
                        env_variables: Mapping[str, Any],
                        path: Optional[List[str]] = None,
                        default_value: Any = NotSet) -> JSON_TYPES

Create new resulting dict with env variables applied.

convert_value_str_to_type

def convert_value_str_to_type(value: str, type_str: str) -> JSON_TYPES

Convert value by type name to native python type.

apply_env_variables_on_agent_config

def apply_env_variables_on_agent_config(
        data: List[Dict], env_variables: Mapping[str, Any]) -> List[Dict]

Create new resulting dict with env variables applied.

is_strict_list

def is_strict_list(data: Union[List, Tuple]) -> bool

Check if a data list is an strict list

The data list contains a mapping object we need to process it as an object containing configurable parameters. For example

cert_requests: - public_key: example_public_key

This will get exported as CONNECTION_NAME_CERT_REQUESTS_0_PUBLIC_KEY=example_public_key

Where as

parameters: - hello - world

will get exported as SKILL_NAME_PARAMETERS=["hello", "world"]

Arguments:

  • data: Data list

Returns:

Boolean specifying whether it's a strict list or not

list_to_nested_dict

def list_to_nested_dict(lst: list, val: Any) -> dict

Convert a list to a nested dict.

ensure_dict

def ensure_dict(dict_: Dict[str, Union[dict, str]]) -> dict

Return the given dictionary converting any values which are json strings as dicts.

ensure_json_content

def ensure_json_content(dict_: dict) -> dict

Return the given dictionary converting any nested dictionary values as json strings.

merge_dicts

def merge_dicts(a: dict, b: dict) -> dict

Merge two dictionaries.

generate_env_vars_recursively

def generate_env_vars_recursively(data: Union[Dict, List],
                                  export_path: List[str]) -> Dict

Generate environment variables recursively.