aea.configurations.data_
types
Base config data types.
JSONSerializable Objects
Interface for JSON-serializable objects.
json
Compute the JSON representation.
from_
json
Build from a JSON object.
PackageVersion Objects
A package version.
__
init__
Initialize a package version.
Arguments:
version_like
: a string, os a semver.VersionInfo object.
is_
latest
Check whether the version is 'latest'.
__
str__
Get the string representation.
__
eq__
Check equality.
__
lt__
Compare with another object.
PackageType Objects
Package types.
to_
plural
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'
Returns:
pluralised package type
__
str__
Convert to string.
ComponentType Objects
Enum of component types supported.
to_
package_
type
Get package type for component type.
plurals
Get the collection of type names, plural.
ComponentType.plurals() ['protocols', 'connections', 'skills', 'contracts']
Returns:
list of all pluralised component types
to_
plural
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'
Returns:
pluralised component type
__
str__
Get the string representation.
PublicId Objects
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 latest_public_id = PublicId("author", "my_package", "latest") latest_public_id
latest_public_id.package_version.is_latest True
__
init__
| __init__(author: SimpleIdOrStr, name: SimpleIdOrStr, version: Optional[PackageVersionLike] = None) -> None
Initialize the public identifier.
author
Get the author.
name
Get the name.
version
Get the version string.
package_
version
Get the package version object.
to_
any
Return the same public id, but with any version.
same_
prefix
Check if the other public id has the same author and name of this.
to_
latest
Return the same public id, but with latest version.
is_
valid_
str
Check if a string is a public id.
Arguments:
public_id_string
: the public id in string format.
Returns:
bool indicating validity
from_
str
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.
try_
from_
str
Safely try to get public id from string.
Arguments:
public_id_string
: the public id in string format.
Returns:
the public id object or None
from_
uri_
path
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
Turn the public id into a uri path string.
Returns:
uri path string
json
Compute the JSON representation.
from_
json
Build from a JSON object.
__
hash__
Get the hash.
__
str__
Get the string representation.
__
repr__
Get the representation.
__
eq__
Compare with another object.
__
lt__
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 or name attributes are different.
Arguments:
other
: the object to compate to
Raises:
ValueError
: if the public ids cannot be confirmed
Returns:
whether or not the inequality is satisfied
PackageId Objects
A package identifier.
__
init__
Initialize the package id.
Arguments:
package_type
: the package type.public_id
: the public id.
package_
type
Get the package type.
public_
id
Get the public id.
author
Get the author of the package.
name
Get the name of the package.
version
Get the version of the package.
package_
prefix
Get the package identifier without the version.
from_
uri_
path
Initialize the package id from the string.
str(PackageId.from_uri_path("skill/author/package_name/0.1.0")) '(skill, author/package_name:0.1.0)'
A bad formatted input raises value error:
PackageId.from_uri_path("very/bad/formatted:input") Traceback (most recent call last): ... ValueError: Input 'very/bad/formatted:input' is not well formatted.
Arguments:
package_id_uri_path
: the package id in uri path string format.
Returns:
the package id object.
Raises:
ValueError
: if the string in input is not well formatted.
to_
uri_
path
Turn the package id into a uri path string.
Returns:
uri path string
__
hash__
Get the hash.
__
str__
Get the string representation.
__
repr__
Get the object representation in string.
__
eq__
Compare with another object.
__
lt__
Compare two public ids.
ComponentId Objects
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__
Initialize the component id.
Arguments:
component_type
: the component type.public_id
: the public id.
component_
type
Get the component type.
component_
prefix
Get the component identifier without the version.
same_
prefix
Check if the other component id has the same type, author and name of this.
prefix_
import_
path
Get the prefix import path for this component.
json
Get the JSON representation.
from_
json
Create component id from json data.
PyPIPackageName Objects
A PyPI Package name.
GitRef Objects
A Git reference.
It can be a branch name, a commit hash or a tag.
Dependency Objects
This class represents a PyPI dependency.
It contains the following information: - 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.
__
init__
| __init__(name: Union[PyPIPackageName, str], version: Union[str, SpecifierSet] = "", index: Optional[str] = None, git: Optional[str] = None, ref: Optional[Union[GitRef, str]] = None) -> None
Initialize a PyPI dependency.
Arguments:
name
: the package name.version
: the specifier set objectindex
: the URL to the PyPI server.git
: the URL to a git repository.ref
: the Git reference (branch/commit/tag).
name
Get the name.
version
Get the version.
index
Get the index.
git
Get the git.
ref
Get the ref.
from_
json
Parse a dependency object from a dictionary.
to_
json
Transform the object to JSON.
get_
pip_
install_
args
Get 'pip install' arguments.
__
str__
Get the string representation.
__
eq__
Compare with another object.
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.
CRUDCollection Objects
Interface of a CRUD collection.
__
init__
Instantiate a CRUD collection.
create
Add an item.
Arguments:
item_id
: the item id.item
: the item to be added.
Raises:
ValueError
: if the item with the same id is already in the collection.
read
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 an existing item.
Arguments:
item_id
: the item id.item
: the item to be added.
delete
Delete an item.
read_
all
Read all the items.
keys
Get the set of keys.