Skip to content

aea.configurations.base

Classes to handle AEA configurations.

as_posix_str

def as_posix_str(path: Union[Path, str]) -> str

Cast to POSIX format

dependencies_from_json

def dependencies_from_json(obj: Dict[str, Dict[str, str]]) -> Dependencies

Parse a JSON object to get an instance of Dependencies.

Arguments:

  • obj: a dictionary whose keys are package names and values are dictionary with package specifications.

Returns:

a Dependencies object.

dependencies_to_json

def dependencies_to_json(
        dependencies: Dependencies) -> Dict[str, Dict[str, str]]

Transform a Dependencies object into a JSON object.

Arguments:

  • dependencies: an instance of "Dependencies" type.

Returns:

a dictionary whose keys are package names and values are the JSON version of a Dependency object.

ProtocolSpecificationParseError Objects

class ProtocolSpecificationParseError(Exception)

Exception for parsing a protocol specification file.

Configuration Objects

class Configuration(JSONSerializable, ABC)

Configuration class.

__init__

def __init__() -> None

Initialize a configuration object.

from_json

@classmethod
@abstractmethod
def from_json(cls, obj: Dict) -> "Configuration"

Build from a JSON object.

ordered_json

@property
def ordered_json() -> OrderedDict

Reorder the dictionary according to a key ordering.

This method takes all the keys in the key_order list and get the associated value in the dictionary (if present). For the remaining keys not considered in the order, it will use alphanumerical ordering.

In particular, if key_order is an empty sequence, this reduces to alphanumerical sorting.

It does not do side-effect.

Returns:

the ordered dictionary.

PackageConfiguration Objects

class PackageConfiguration(Configuration, ABC)

This class represent a package configuration.

A package can be one of: - agents - protocols - connections - skills - contracts

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None) -> None

Initialize a package configuration.

Arguments:

  • name: the name of the package.
  • author: the author of the package.
  • version: the version of the package (SemVer format).
  • license_: the license.
  • aea_version: either a fixed version, or a set of specifiers describing the AEA versions allowed. (default: empty string - no constraint). The fixed version is interpreted with the specifier '=='.
  • fingerprint: the fingerprint.
  • fingerprint_ignore_patterns: a list of file patterns to ignore files to fingerprint.
  • build_entrypoint: path to a script to execute at build time.

name

@property
def name() -> str

Get the name.

name

@name.setter
def name(value: SimpleIdOrStr) -> None

Set the name.

author

@property
def author() -> str

Get the author.

author

@author.setter
def author(value: SimpleIdOrStr) -> None

Set the author.

aea_version

@property
def aea_version() -> str

Get the 'aea_version' attribute.

aea_version

@aea_version.setter
def aea_version(new_aea_version: str) -> None

Set the 'aea_version' attribute.

check_aea_version

def check_aea_version() -> None

Check that the AEA version matches the specifier set.

directory

@property
def directory() -> Optional[Path]

Get the path to the configuration file associated to this file, if any.

directory

@directory.setter
def directory(directory: Path) -> None

Set directory if not already set.

package_id

@property
def package_id() -> PackageId

Get package id.

parse_aea_version_specifier

@staticmethod
def parse_aea_version_specifier(aea_version_specifiers: str) -> SpecifierSet

Parse an 'aea_version' field.

If 'aea_version' is a version, then output the specifier set "==${version}" Else, interpret it as specifier set.

Arguments:

  • aea_version_specifiers: the AEA version, or a specifier set.

Returns:

A specifier set object.

aea_version_specifiers

@property
def aea_version_specifiers() -> SpecifierSet

Get the AEA version set specifier.

public_id

@property
def public_id() -> PublicId

Get the public id.

package_dependencies

@property
def package_dependencies() -> Set[ComponentId]

Get the package dependencies.

update

def update(data: Dict, env_vars_friendly: bool = False) -> None

Update configuration with other data.

Arguments:

  • data: the data to replace.
  • env_vars_friendly: whether or not it is env vars friendly.

validate_config_data

@classmethod
def validate_config_data(cls,
                         json_data: Dict,
                         env_vars_friendly: bool = False) -> None

Perform config validation.

from_json

@classmethod
def from_json(cls, obj: Dict) -> "PackageConfiguration"

Initialize from a JSON object.

make_resulting_config_data

def make_resulting_config_data(overrides: Dict) -> Dict

Make config data with overrides applied.

Does not update config, just creates json representation.

Arguments:

  • overrides: the overrides

Returns:

config with overrides applied

check_overrides_valid

def check_overrides_valid(overrides: Dict,
                          env_vars_friendly: bool = False) -> None

Check overrides is correct, return list of errors if present.

get_overridable

def get_overridable() -> dict

Get dictionary of values that can be updated for this config.

ComponentConfiguration Objects

class ComponentConfiguration(PackageConfiguration, ABC)

Class to represent an agent component configuration.

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None,
             build_directory: Optional[str] = None,
             dependencies: Optional[Dependencies] = None) -> None

Set component configuration.

build_directory

@property
def build_directory() -> Optional[str]

Get the component type.

build_directory

@build_directory.setter
def build_directory(value: Optional[str]) -> None

Get the component type.

component_type

@property
def component_type() -> ComponentType

Get the component type.

component_id

@property
def component_id() -> ComponentId

Get the component id.

prefix_import_path

@property
def prefix_import_path() -> str

Get the prefix import path for this component.

is_abstract_component

@property
def is_abstract_component() -> bool

Check whether the component is abstract.

check_fingerprint

def check_fingerprint(directory: Path) -> None

Check that the fingerprint are correct against a directory path.

Arguments:

  • directory: the directory path.

Raises:

  • ValueError: if
  • the argument is not a valid package directory
  • the fingerprints do not match.

check_public_id_consistency

def check_public_id_consistency(directory: Path) -> None

Check that the public ids in the init file match the config.

Arguments:

  • directory: the directory path.

Raises:

  • ValueError: if
  • the argument is not a valid package directory
  • the public ids do not match.

ConnectionConfig Objects

class ConnectionConfig(ComponentConfiguration)

Handle connection configuration.

__init__

def __init__(name: SimpleIdOrStr = "",
             author: SimpleIdOrStr = "",
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None,
             build_directory: Optional[str] = None,
             class_name: str = "",
             protocols: Optional[Set[PublicId]] = None,
             connections: Optional[Set[PublicId]] = None,
             restricted_to_protocols: Optional[Set[PublicId]] = None,
             excluded_protocols: Optional[Set[PublicId]] = None,
             dependencies: Optional[Dependencies] = None,
             description: str = "",
             connection_id: Optional[PublicId] = None,
             is_abstract: bool = False,
             cert_requests: Optional[List[CertRequest]] = None,
             **config: Any) -> None

Initialize a connection configuration object.

package_dependencies

@property
def package_dependencies() -> Set[ComponentId]

Get the connection dependencies.

is_abstract_component

@property
def is_abstract_component() -> bool

Check whether the component is abstract.

json

@property
def json() -> Dict

Return the JSON representation.

ProtocolConfig Objects

class ProtocolConfig(ComponentConfiguration)

Handle protocol configuration.

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None,
             build_directory: Optional[str] = None,
             aea_version: str = "",
             dependencies: Optional[Dependencies] = None,
             description: str = "",
             protocol_specification_id: Optional[str] = None) -> None

Initialize a connection configuration object.

json

@property
def json() -> Dict

Return the JSON representation.

SkillComponentConfiguration Objects

class SkillComponentConfiguration()

This class represent a skill component configuration.

__init__

def __init__(class_name: str,
             file_path: Optional[str] = None,
             **args: Any) -> None

Initialize a skill component configuration.

Arguments:

  • class_name: the class name of the component.
  • file_path: the file path.
  • args: keyword arguments.

json

@property
def json() -> Dict

Return the JSON representation.

from_json

@classmethod
def from_json(cls, obj: Dict) -> "SkillComponentConfiguration"

Initialize from a JSON object.

SkillConfig Objects

class SkillConfig(ComponentConfiguration)

Class to represent a skill configuration file.

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None,
             build_directory: Optional[str] = None,
             connections: Optional[Set[PublicId]] = None,
             protocols: Optional[Set[PublicId]] = None,
             contracts: Optional[Set[PublicId]] = None,
             customs: Optional[Set[PublicId]] = None,
             skills: Optional[Set[PublicId]] = None,
             dependencies: Optional[Dependencies] = None,
             description: str = "",
             is_abstract: bool = False) -> None

Initialize a skill configuration.

package_dependencies

@property
def package_dependencies() -> Set[ComponentId]

Get the skill dependencies.

is_abstract_component

@property
def is_abstract_component() -> bool

Check whether the component is abstract.

json

@property
def json() -> Dict

Return the JSON representation.

get_overridable

def get_overridable() -> dict

Get overridable configuration data.

AgentConfig Objects

class AgentConfig(PackageConfiguration)

Class to represent the agent configuration file.

__init__

def __init__(agent_name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None,
             description: str = "",
             logging_config: Optional[Dict] = None,
             period: Optional[float] = None,
             execution_timeout: Optional[float] = None,
             max_reactions: Optional[int] = None,
             error_handler: Optional[Dict] = None,
             decision_maker_handler: Optional[Dict] = None,
             skill_exception_policy: Optional[str] = None,
             connection_exception_policy: Optional[str] = None,
             default_ledger: Optional[str] = None,
             required_ledgers: Optional[List[str]] = None,
             currency_denominations: Optional[Dict[str, str]] = None,
             default_connection: Optional[str] = None,
             default_routing: Optional[Dict[str, str]] = None,
             loop_mode: Optional[str] = None,
             runtime_mode: Optional[str] = None,
             task_manager_mode: Optional[str] = None,
             storage_uri: Optional[str] = None,
             data_dir: Optional[str] = None,
             component_configurations: Optional[Dict[ComponentId,
                                                     Dict]] = None,
             dependencies: Optional[Dependencies] = None) -> None

Instantiate the agent configuration object.

component_configurations

@property
def component_configurations() -> Dict[ComponentId, Dict]

Get the custom component configurations.

component_configurations

@component_configurations.setter
def component_configurations(d: Dict[ComponentId, Dict]) -> None

Set the component configurations.

package_dependencies

@property
def package_dependencies() -> Set[ComponentId]

Get the package dependencies.

private_key_paths_dict

@property
def private_key_paths_dict() -> Dict[str, str]

Get dictionary version of private key paths.

connection_private_key_paths_dict

@property
def connection_private_key_paths_dict() -> Dict[str, str]

Get dictionary version of connection private key paths.

component_configurations_json

def component_configurations_json() -> List[OrderedDict]

Get the component configurations in JSON format.

json

@property
def json() -> Dict

Return the JSON representation.

all_components_id

@property
def all_components_id() -> List[ComponentId]

Get list of the all components for this agent config.

update

def update(data: Dict,
           env_vars_friendly: bool = False,
           dict_overrides: Optional[Dict] = None) -> None

Update configuration with other data.

To update the component parts, populate the field "component_configurations" as a mapping from ComponentId to configurations.

Arguments:

  • data: the data to replace.
  • env_vars_friendly: whether or not it is env vars friendly.
  • dict_overrides: A dictionary containing mapping for Component ID -> List of paths

SpeechActContentConfig Objects

class SpeechActContentConfig(Configuration)

Handle a speech_act content configuration.

__init__

def __init__(**args: Any) -> None

Initialize a speech_act content configuration.

json

@property
def json() -> Dict

Return the JSON representation.

from_json

@classmethod
def from_json(cls, obj: Dict) -> "SpeechActContentConfig"

Initialize from a JSON object.

ProtocolSpecification Objects

class ProtocolSpecification(ProtocolConfig)

Handle protocol specification.

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             description: str = "",
             protocol_specification_id: Optional[str] = None) -> None

Initialize a protocol specification configuration object.

protobuf_snippets

@property
def protobuf_snippets() -> Dict

Get the protobuf snippets.

protobuf_snippets

@protobuf_snippets.setter
def protobuf_snippets(protobuf_snippets: Dict) -> None

Set the protobuf snippets.

dialogue_config

@property
def dialogue_config() -> Dict

Get the dialogue config.

dialogue_config

@dialogue_config.setter
def dialogue_config(dialogue_config: Dict) -> None

Set the dialogue config.

json

@property
def json() -> Dict

Return the JSON representation.

ContractConfig Objects

class ContractConfig(ComponentConfiguration)

Handle contract configuration.

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             build_entrypoint: Optional[str] = None,
             build_directory: Optional[str] = None,
             dependencies: Optional[Dependencies] = None,
             description: str = "",
             contract_interface_paths: Optional[Dict[str, str]] = None,
             class_name: str = "",
             contracts: Optional[Set[PublicId]] = None) -> None

Initialize a protocol configuration object.

json

@property
def json() -> Dict

Return the JSON representation.

package_dependencies

@property
def package_dependencies() -> Set[ComponentId]

Get the contract dependencies.

CustomComponentConfig Objects

class CustomComponentConfig(PackageConfiguration)

Custom component configuratiopn.

__init__

def __init__(name: SimpleIdOrStr,
             author: SimpleIdOrStr,
             version: str = "",
             license_: str = "",
             aea_version: str = "",
             description: str = "",
             fingerprint: Optional[Dict[str, str]] = None,
             fingerprint_ignore_patterns: Optional[Sequence[str]] = None,
             dependencies: Optional[Dependencies] = None,
             **kwargs: Any) -> None

Initialize a custom configuration object.

get

def get(name: str) -> Any

Get parameter.

set

def set(name: str, value: Any) -> None

Set extra parameter value.

json

@property
def json() -> Dict

Return the JSON representation.

AEAVersionError Objects

class AEAVersionError(ValueError)

Special Exception for version error.

__init__

def __init__(package_id: PublicId,
             aea_version_specifiers: SpecifierSet) -> None

Init exception.