Skip to content

aea.configurations.utils

AEA configuration utils.

package_dotted_path

def package_dotted_path(author: str, package_type_plural: str,
                        package_name: str, file_stem: str) -> str

Compose the canonical dotted path string for a file inside an AEA package.

Returns a string of the form packages.<author>.<plural>.<name>.<stem>. Has no side effects; the loaded module is registered in sys.modules by aea.helpers.base.load_module.

Arguments:

  • author: package author (e.g. "valory").
  • package_type_plural: plural package-type token ("skills" / "contracts" / "connections" / "protocols").
  • package_name: the package's local name.
  • file_stem: source file stem without the .py suffix ("contract" / "connection" / "behaviours" / ...).

Returns:

the composed packages-prefixed dotted path string.

replace_component_ids

@singledispatch
def replace_component_ids(
        _arg: PackageConfiguration,
        _replacements: Dict[ComponentType, Dict[PublicId, PublicId]]) -> None

Update public id references in a package configuration.

This depends on the actual configuration being considered.

_

@replace_component_ids.register(AgentConfig)
def _(arg: AgentConfig, replacements: Dict[ComponentType,
                                           Dict[PublicId, PublicId]]) -> None

Replace references in agent configuration.

It breaks down in: 1) replace public ids in 'protocols', 'connections', 'contracts' and 'skills'; 2) replace public ids in default routing; 3) replace public id of default connection; 4) replace custom component configurations.

Arguments:

  • arg: the agent configuration.
  • replacements: the replacement mapping.

_

@replace_component_ids.register(ProtocolConfig)
def _(_arg: ProtocolConfig,
      _replacements: Dict[ComponentType, Dict[PublicId, PublicId]]) -> None

Do nothing - protocols have no references.

_

@replace_component_ids.register(ConnectionConfig)
def _(arg: ConnectionConfig,
      replacements: Dict[ComponentType, Dict[PublicId, PublicId]]) -> None

Replace references in a connection configuration.

_

@replace_component_ids.register(ContractConfig)
def _(_arg: ContractConfig,
      _replacements: Dict[ComponentType, Dict[PublicId, PublicId]]) -> None

Do nothing - contracts have no references.

_

@replace_component_ids.register(SkillConfig)
def _(arg: SkillConfig, replacements: Dict[ComponentType,
                                           Dict[PublicId, PublicId]]) -> None

Replace references in a skill configuration.

get_latest_component_id_from_prefix

def get_latest_component_id_from_prefix(
        agent_config: AgentConfig,
        component_prefix: PackageIdPrefix) -> Optional[ComponentId]

Get component id with the greatest version in an agent configuration given its prefix.

Arguments:

  • agent_config: the agent configuration.
  • component_prefix: the package prefix.

Returns:

the package id with the greatest version, or None if not found.