aea.configurations.base

Classes to handle AEA configurations.

Dependency

A dependency is a dictionary with the following (optional) keys: - version: a version specifier(s) (e.g. '==0.1.0'). - index: the PyPI index where to download the package from (default: https://pypi.org) - git: the URL to the Git repository (e.g. https://github.com/fetchai/agents-aea.git) - ref: either the branch name, the tag, the commit number or a Git reference (default: 'master'.) If the 'git' field is set, the 'version' field will be ignored. These fields will be forwarded to the 'pip' command.

Dependencies

A dictionary from package name to dependency data structure (see above). The package name must satisfy the constraints on Python packages names.

The main advantage of having a dictionary is that we implicitly filter out dependency duplicates. We cannot have two items with the same package name since the keys of a YAML object form a set.

PackageType

class PackageType(Enum)

Package types.

to_plural

 | to_plural() -> str

Get the plural name.

PackageType.AGENT.to_plural() 'agents' PackageType.PROTOCOL.to_plural() 'protocols' PackageType.CONNECTION.to_plural() 'connections' PackageType.SKILL.to_plural() 'skills' PackageType.CONTRACT.to_plural() 'contracts'

__str__

 | __str__()

Convert to string.

ComponentType

class ComponentType(Enum)

Enum of component types supported.

to_configuration_type

 | to_configuration_type() -> PackageType

Get package type for component type.

to_plural

 | to_plural() -> str

Get the plural version of the component type.

ComponentType.PROTOCOL.to_plural() 'protocols' ComponentType.CONNECTION.to_plural() 'connections' ComponentType.SKILL.to_plural() 'skills' ComponentType.CONTRACT.to_plural() 'contracts'

__str__

 | __str__() -> str

Get the string representation.

ProtocolSpecificationParseError

class ProtocolSpecificationParseError(Exception)

Exception for parsing a protocol specification file.

JSONSerializable

class JSONSerializable(ABC)

Interface for JSON-serializable objects.

json

 | @property
 | @abstractmethod
 | json() -> Dict

Compute the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Build from a JSON object.

Configuration

class Configuration(JSONSerializable,  ABC)

Configuration class.

__init__

 | __init__()

Initialize a configuration object.

from_json

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

Build from a JSON object.

ordered_json

 | @property
 | 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.

CRUDCollection

class CRUDCollection(Generic[T])

Interface of a CRUD collection.

__init__

 | __init__()

Instantiate a CRUD collection.

create

 | create(item_id: str, item: T) -> None

Add an item.

Arguments:

  • item_id: the item id.
  • item: the item to be added.

Returns:

None

Raises:

  • ValueError: if the item with the same id is already in the collection.

read

 | read(item_id: str) -> Optional[T]

Get an item by its name.

Arguments:

  • item_id: the item id.

Returns:

the associated item, or None if the item id is not present.

update

 | update(item_id: str, item: T) -> None

Update an existing item.

Arguments:

  • item_id: the item id.
  • item: the item to be added.

Returns:

None

delete

 | delete(item_id: str) -> None

Delete an item.

read_all

 | read_all() -> List[Tuple[str, T]]

Read all the items.

PublicId

class PublicId(JSONSerializable)

This class implement a public identifier.

A public identifier is composed of three elements: - author - name - version

The concatenation of those three elements gives the public identifier:

author/name:version

public_id = PublicId("author", "my_package", "0.1.0") assert public_id.author == "author" assert public_id.name == "my_package" assert public_id.version == "0.1.0" another_public_id = PublicId("author", "my_package", "0.1.0") assert hash(public_id) == hash(another_public_id) assert public_id == another_public_id

__init__

 | __init__(author: str, name: str, version: PackageVersionLike)

Initialize the public identifier.

author

 | @property
 | author() -> str

Get the author.

name

 | @property
 | name() -> str

Get the name.

version

 | @property
 | version() -> str

Get the version.

version_info

 | @property
 | version_info() -> PackageVersion

Get the package version.

from_str

 | @classmethod
 | from_str(cls, public_id_string: str) -> "PublicId"

Initialize the public id from the string.

str(PublicId.from_str("author/package_name:0.1.0")) 'author/package_name:0.1.0'

A bad formatted input raises value error:

PublicId.from_str("bad/formatted:input") Traceback (most recent call last): ... ValueError: Input 'bad/formatted:input' is not well formatted.

Arguments:

  • public_id_string: the public id in string format.

Returns:

the public id object.

Raises:

  • ValueError: if the string in input is not well formatted.

from_uri_path

 | @classmethod
 | from_uri_path(cls, public_id_uri_path: str) -> "PublicId"

Initialize the public id from the string.

str(PublicId.from_uri_path("author/package_name/0.1.0")) 'author/package_name:0.1.0'

A bad formatted input raises value error:

PublicId.from_uri_path("bad/formatted:input") Traceback (most recent call last): ... ValueError: Input 'bad/formatted:input' is not well formatted.

Arguments:

  • public_id_uri_path: the public id in uri path string format.

Returns:

the public id object.

Raises:

  • ValueError: if the string in input is not well formatted.

to_uri_path

 | @property
 | to_uri_path() -> str

Turn the public id into a uri path string.

Returns:

uri path string

json

 | @property
 | json() -> Dict

Compute the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Build from a JSON object.

__hash__

 | __hash__()

Get the hash.

__str__

 | __str__()

Get the string representation.

__repr__

 | __repr__()

Get the representation.

__eq__

 | __eq__(other)

Compare with another object.

__lt__

 | __lt__(other)

Compare two public ids.

public_id_1 = PublicId("author_1", "name_1", "0.1.0") public_id_2 = PublicId("author_1", "name_1", "0.1.1") public_id_3 = PublicId("author_1", "name_2", "0.1.0") public_id_1 > public_id_2 False public_id_1 < public_id_2 True

public_id_1 < public_id_3 Traceback (most recent call last): ... ValueError: The public IDs author_1/name_1:0.1.0 and author_1/name_2:0.1.0 cannot be compared. Their author and name attributes are different.

PackageId

class PackageId()

A package identifier.

__init__

 | __init__(package_type: Union[PackageType, str], public_id: PublicId)

Initialize the package id.

Arguments:

  • package_type: the package type.
  • public_id: the public id.

package_type

 | @property
 | package_type() -> PackageType

Get the package type.

public_id

 | @property
 | public_id() -> PublicId

Get the public id.

author

 | @property
 | author() -> str

Get the author of the package.

name

 | @property
 | name() -> str

Get the name of the package.

version

 | @property
 | version() -> str

Get the version of the package.

package_prefix

 | @property
 | package_prefix() -> Tuple[PackageType, str, str]

Get the package identifier without the version.

__hash__

 | __hash__()

Get the hash.

__str__

 | __str__()

Get the string representation.

__eq__

 | __eq__(other)

Compare with another object.

__lt__

 | __lt__(other)

Compare two public ids.

ComponentId

class ComponentId(PackageId)

Class to represent a component identifier.

A component id is a package id, but excludes the case when the package is an agent.

pacakge_id = PackageId(PackageType.PROTOCOL, PublicId("author", "name", "0.1.0")) component_id = ComponentId(ComponentType.PROTOCOL, PublicId("author", "name", "0.1.0")) pacakge_id == component_id True

component_id2 = ComponentId(ComponentType.PROTOCOL, PublicId("author", "name", "0.1.1")) pacakge_id == component_id2 False

__init__

 | __init__(component_type: Union[ComponentType, str], public_id: PublicId)

Initialize the component id.

Arguments:

  • component_type: the component type.
  • public_id: the public id.

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

component_prefix

 | @property
 | component_prefix() -> Tuple[ComponentType, str, str]

Get the component identifier without the version.

prefix_import_path

 | @property
 | prefix_import_path() -> str

Get the prefix import path for this component.

PackageConfiguration

class PackageConfiguration(Configuration,  ABC)

This class represent a package configuration.

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

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", aea_version: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = 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.

directory

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

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

aea_version_specifiers

 | @property
 | aea_version_specifiers() -> SpecifierSet

Get the AEA version set specifier.

public_id

 | @property
 | public_id() -> PublicId

Get the public id.

package_dependencies

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

Get the package dependencies.

ComponentConfiguration

class ComponentConfiguration(PackageConfiguration,  ABC)

Class to represent an agent component configuration.

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", aea_version: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = None, dependencies: Optional[Dependencies] = None)

Set component configuration.

pypi_dependencies

 | @property
 | pypi_dependencies() -> Dependencies

Get PyPI dependencies.

component_type

 | @property
 | @abstractmethod
 | component_type() -> ComponentType

Get the component type.

component_id

 | @property
 | component_id() -> ComponentId

Get the component id.

prefix_import_path

 | @property
 | prefix_import_path() -> str

Get the prefix import path for this component.

load

 | @staticmethod
 | load(component_type: ComponentType, directory: Path, skip_consistency_check: bool = False) -> "ComponentConfiguration"

Load configuration and check that it is consistent against the directory.

Arguments:

  • component_type: the component type.
  • directory: the root of the package
  • skip_consistency_check: if True, the consistency check are skipped.

Returns:

the configuration object.

check_fingerprint

 | check_fingerprint(directory: Path) -> None

Check that the fingerprint are correct against a directory path.

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

check_aea_version

 | check_aea_version()

Check that the AEA version matches the specifier set.

:raises ValueError if the version of the aea framework falls within a specifier.

ConnectionConfig

class ConnectionConfig(ComponentConfiguration)

Handle connection configuration.

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", aea_version: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = None, class_name: str = "", protocols: Optional[Set[PublicId]] = None, restricted_to_protocols: Optional[Set[PublicId]] = None, excluded_protocols: Optional[Set[PublicId]] = None, dependencies: Optional[Dependencies] = None, description: str = "", **config, ,)

Initialize a connection configuration object.

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

package_dependencies

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

Get the connection dependencies.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

ProtocolConfig

class ProtocolConfig(ComponentConfiguration)

Handle protocol configuration.

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = None, aea_version: str = "", dependencies: Optional[Dependencies] = None, description: str = "")

Initialize a connection configuration object.

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

SkillComponentConfiguration

class SkillComponentConfiguration()

This class represent a skill component configuration.

__init__

 | __init__(class_name: str, **args)

Initialize a skill component configuration.

Arguments:

  • skill_component_type: the skill component type.
  • class_name: the class name of the component.
  • args: keyword arguments.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

SkillConfig

class SkillConfig(ComponentConfiguration)

Class to represent a skill configuration file.

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", aea_version: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = None, protocols: List[PublicId] = None, contracts: List[PublicId] = None, dependencies: Optional[Dependencies] = None, description: str = "")

Initialize a skill configuration.

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

package_dependencies

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

Get the connection dependencies.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

AgentConfig

class AgentConfig(PackageConfiguration)

Class to represent the agent configuration file.

__init__

 | __init__(agent_name: str, author: str, version: str = "", license: str = "", aea_version: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = None, registry_path: str = DEFAULT_REGISTRY_PATH, description: str = "", logging_config: Optional[Dict] = None, timeout: Optional[float] = None, execution_timeout: Optional[float] = None, max_reactions: Optional[int] = None, decision_maker_handler: Optional[Dict] = None, skill_exception_policy: Optional[str] = None, default_routing: Optional[Dict] = None, loop_mode: Optional[str] = None)

Instantiate the agent configuration object.

package_dependencies

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

Get the package dependencies.

private_key_paths_dict

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

Get dictionary version of private key paths.

ledger_apis_dict

 | @property
 | ledger_apis_dict() -> Dict[str, Dict[str, Union[str, int]]]

Get dictionary version of ledger apis.

default_connection

 | @default_connection.setter
 | default_connection(connection_id: Optional[Union[str, PublicId]])

Set the default connection.

Arguments:

  • connection_id: the name of the default connection.

Returns:

None

default_ledger

 | @default_ledger.setter
 | default_ledger(ledger_id: str)

Set the default ledger.

Arguments:

  • ledger_id: the id of the default ledger.

Returns:

None

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

SpeechActContentConfig

class SpeechActContentConfig(Configuration)

Handle a speech_act content configuration.

__init__

 | __init__(**args)

Initialize a speech_act content configuration.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

ProtocolSpecification

class ProtocolSpecification(ProtocolConfig)

Handle protocol specification.

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", aea_version: str = "", description: str = "")

Initialize a protocol specification configuration object.

protobuf_snippets

 | @protobuf_snippets.setter
 | protobuf_snippets(protobuf_snippets: Dict)

Set the protobuf snippets.

dialogue_config

 | @dialogue_config.setter
 | dialogue_config(dialogue_config: Dict)

Set the dialogue config.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.

ContractConfig

class ContractConfig(ComponentConfiguration)

Handle contract configuration.

__init__

 | __init__(name: str, author: str, version: str = "", license: str = "", aea_version: str = "", fingerprint: Optional[Dict[str, str]] = None, fingerprint_ignore_patterns: Optional[Sequence[str]] = None, dependencies: Optional[Dependencies] = None, description: str = "", path_to_contract_interface: str = "", class_name: str = "")

Initialize a protocol configuration object.

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

json

 | @property
 | json() -> Dict

Return the JSON representation.

from_json

 | @classmethod
 | from_json(cls, obj: Dict)

Initialize from a JSON object.