Skip to content

Commit

Permalink
Merge pull request #1597 from fetchai/develop
Browse files Browse the repository at this point in the history
Release v0.5.3
  • Loading branch information
DavidMinarsch authored Aug 5, 2020
2 parents 68ea55d + 4196bc1 commit a6ca234
Show file tree
Hide file tree
Showing 489 changed files with 26,185 additions and 8,675 deletions.
33 changes: 9 additions & 24 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ jobs:
run: |
tox -e py3.8 -- --aea-loop sync -m 'not integration and not unstable'
sync_aea_loop_integrational_tests:
all_integrational_tests:
continue-on-error: True
runs-on: ubuntu-latest

timeout-minutes: 40

steps:
- uses: actions/checkout@master
- uses: actions/setup-python@master
Expand All @@ -52,10 +54,12 @@ jobs:
pip install pipenv
pip install tox
sudo apt-get install -y protobuf-compiler
- name: Integrational tests and coverage
- name: Sync AEA loop integrational tests and coverage
run: |
tox -e py3.8 -- --aea-loop sync -m 'integration and not unstable and not ledger'
- name: Async Integration tests
run: tox -e py3.8 -- -m 'integration and not unstable and not ledger'

common_checks:
runs-on: ubuntu-latest
continue-on-error: True
Expand All @@ -82,6 +86,8 @@ jobs:
tar xvfz go-ipfs.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs
ipfs init
- name: Pipenv lock
run: pipenv lock
- name: Security Check
run: tox -e bandit
- name: Safety Check
Expand Down Expand Up @@ -111,27 +117,6 @@ jobs:
- name: Generate Documentation
run: tox -e docs

integration_checks:
continue-on-error: True
runs-on: ubuntu-latest

timeout-minutes: 40

steps:
- uses: actions/checkout@master
- uses: actions/setup-python@master
with:
python-version: 3.7
- name: Install dependencies (ubuntu-latest)
run: |
sudo apt-get update --fix-missing
sudo apt-get autoremove
sudo apt-get autoclean
pip install pipenv
pip install tox
- name: Integration tests
run: tox -e py3.7 -- -m 'integration and not unstable and not ledger'

integration_checks_ledger:
continue-on-error: True
runs-on: ubuntu-latest
Expand Down
22 changes: 22 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Release History

## 0.5.3 (2020-08-05)

- Adds support for re-starting agent after stopping it
- Adds full test coverage for protocols generator
- Adds support for dynamically adding handlers
- Improves p2p connection startup reliability
- Addresses p2p connection race condition with long running processes
- Adds connection states in connections
- Applies consistent logger usage throughout
- Adds key rotation and randomised locations for integration tests
- Adds request delays in SOEF connection to avoid request limits
- Exposes runtime states on agent and removes agent liveness object
- Adds readme files in protocols and connections
- Improves edge case handling in dialogue models
- Adds support for cosmwasm message signing
- Adds test coverage for test tools
- Adds dialogues models in all connections where required
- Transitions erc1155 skills and simple search to SOEF and p2p
- Adds full test coverage for skills modules
- Multiple docs updates
- Multiple additional tests and test stability fixes

## 0.5.2 (2020-07-21)

- Transitions demos to agent-land test network, P2P and SOEF connections
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include README.md LICENSE HISTORY.md AUTHORS.md SECURITY.md CODE_OF_CONDUCT.md Pipfile mkdocs.yml tox.ini pytest.ini strategy.ini

recursive-include aea *.json *.yaml *.proto *.ico *png *.html *.js *.css
recursive-include aea *.json *.yaml *.proto *.ico *png *.html *.js *.css *.md
recursive-include docs *
recursive-include examples *
recursive-include packages *
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lint:

.PHONY: pylint
pylint:
pylint aea benchmark examples packages scripts
pylint aea benchmark packages scripts examples/*

.PHONY: security
security:
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ openapi-spec-validator = "==0.2.8"
pexpect = "==4.8.0"
psutil = "==5.7.0"
pydocstyle = "==3.0.0"
pydoc-markdown = "==3.3.0"
pygments = "==2.5.2"
pylint = "==2.5.2"
pymdown-extensions = "==6.3"
Expand Down
55 changes: 45 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,51 @@
# AEA Framework
<h1 align="center">
<b>AEA Framework</b>
</h1>

[![PyPI](https://img.shields.io/pypi/v/aea)](https://pypi.org/project/aea/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aea)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/aea)
[![](https://img.shields.io/pypi/l/aea)](https://github.com/fetchai/agents-aea/blob/master/LICENSE)
![PyPI - Downloads](https://img.shields.io/pypi/dm/aea)
[![](https://img.shields.io/badge/slack-fetchai-black.svg)](https://fetch-ai.slack.com/join/shared_invite/enQtNDI2MDYwMjE3OTQwLWY0ZjAyYjM0NGQzNWRhNDMxMzdjYmVhYTE3NDNhNTAyMTE0YWRkY2VmOWRmMGQ3ODM1N2NjOWUwNDExM2U3YjY)

![AEA framework sanity checks and tests](https://github.com/fetchai/agents-aea/workflows/AEA%20framework%20sanity%20checks%20and%20tests/badge.svg?branch=master)
![Codecov](https://img.shields.io/codecov/c/github/fetchai/agents-aea)
<p align="center">
<a href="https://pypi.org/project/aea/">
<img alt="PyPI" src="https://img.shields.io/pypi/v/aea">
</a>
<a href="https://pypi.org/project/aea/">
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/aea">
</a>
<a>
<img alt="PyPI - Wheel" src="https://img.shields.io/pypi/wheel/aea">
</a>
<a href="https://github.com/fetchai/agents-aea/blob/master/LICENSE">
<img alt="License" src="https://img.shields.io/pypi/l/aea">
</a>
<a href="https://pypi.org/project/aea/">
<img alt="License" src="https://img.shields.io/pypi/dm/aea">
</a>
<a href="https://fetch-ai.slack.com/join/shared_invite/enQtNDI2MDYwMjE3OTQwLWY0ZjAyYjM0NGQzNWRhNDMxMzdjYmVhYTE3NDNhNTAyMTE0YWRkY2VmOWRmMGQ3ODM1N2NjOWUwNDExM2U3YjY">
<img alt="Slack" src="https://img.shields.io/badge/slack-fetchai-purple.svg">
</a>
</p>
<p align="center">
<a href="https://github.com/fetchai/agents-aea/workflows/AEA%20framework%20sanity%20checks%20and%20tests">
<img alt="AEA framework sanity checks and tests" src="https://github.com/fetchai/agents-aea/workflows/AEA%20framework%20sanity%20checks%20and%20tests/badge.svg?branch=master">
</a>
<a href="">
<img alt="Codecov" src="https://img.shields.io/codecov/c/github/fetchai/agents-aea">
</a>
<a href="https://img.shields.io/badge/lint-flake8-blueviolet">
<img alt="flake8" src="https://img.shields.io/badge/lint-flake8-yellow" >
</a>
<a href="https://github.com/python/mypy">
<img alt="mypy" src="https://img.shields.io/badge/static%20check-mypy-blue">
</a>
<a href="https://github.com/psf/black">
<img alt="Black" src="https://img.shields.io/badge/code%20style-black-black">
</a>
<a href="https://github.com/PyCQA/bandit">
<img alt="mypy" src="https://img.shields.io/badge/security-bandit-lightgrey">
</a>
</p>

<p align="center">
A framework for autonomous economic agent (AEA) development
</p>

<p align="center">
<img src="/data/aea.png?raw=true" alt="AEA Description" width="70%"/>
Expand Down
2 changes: 1 addition & 1 deletion aea/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__title__ = "aea"
__description__ = "Autonomous Economic Agent framework"
__url__ = "https://github.com/fetchai/agents-aea.git"
__version__ = "0.5.2"
__version__ = "0.5.3"
__author__ = "Fetch.AI Limited"
__license__ = "Apache-2.0"
__copyright__ = "2019 Fetch.AI Limited"
25 changes: 14 additions & 11 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from aea.exceptions import AEAException
from aea.helpers.exception_policy import ExceptionPolicyEnum
from aea.helpers.exec_timeout import ExecTimeoutThreadGuard, TimeoutException
from aea.helpers.logging import AgentLoggerAdapter
from aea.helpers.logging import AgentLoggerAdapter, WithLogger
from aea.identity.base import Identity
from aea.mail.base import Envelope
from aea.protocols.base import Message
Expand All @@ -45,10 +45,8 @@
from aea.skills.error.handlers import ErrorHandler
from aea.skills.tasks import TaskManager

logger = logging.getLogger(__name__)


class AEA(Agent):
class AEA(Agent, WithLogger):
"""This class implements an autonomous economic agent."""

RUN_LOOPS: Dict[str, Type[BaseAgentLoop]] = {
Expand Down Expand Up @@ -108,6 +106,10 @@ def __init__(
loop_mode=loop_mode,
runtime_mode=runtime_mode,
)
aea_logger = AgentLoggerAdapter(
logger=logging.getLogger(__name__), agent_name=identity.name
)
WithLogger.__init__(self, logger=cast(logging.Logger, aea_logger))

self.max_reactions = max_reactions
self._task_manager = TaskManager()
Expand Down Expand Up @@ -256,14 +258,14 @@ def _handle(self, envelope: Envelope) -> None:
:param envelope: the envelope to handle.
:return: None
"""
logger.debug("Handling envelope: {}".format(envelope))
self.logger.debug("Handling envelope: {}".format(envelope))
protocol = self.resources.get_protocol(envelope.protocol_id)

# TODO specify error handler in config and make this work for different skill/protocol versions.
error_handler = self._get_error_handler()

if error_handler is None:
logger.warning("ErrorHandler not initialized. Stopping AEA!")
self.logger.warning("ErrorHandler not initialized. Stopping AEA!")
self.stop()
return
error_handler = cast(ErrorHandler, error_handler)
Expand All @@ -278,9 +280,11 @@ def _handle(self, envelope: Envelope) -> None:
else:
msg = protocol.serializer.decode(envelope.message)
msg.counterparty = envelope.sender
msg.sender = envelope.sender
# msg.to = envelope.to
msg.is_incoming = True
except Exception as e: # pylint: disable=broad-except # thats ok, because we send the decoding error back
logger.warning("Decoding error. Exception: {}".format(str(e)))
self.logger.warning("Decoding error. Exception: {}".format(str(e)))
error_handler.send_decoding_error(envelope)
return

Expand Down Expand Up @@ -334,13 +338,13 @@ def _execution_control(
"""
# docstyle: ignore
def log_exception(e, fn, component):
logger.exception(f"<{e}> raised during `{fn}` call of `{component}`")
self.logger.exception(f"<{e}> raised during `{fn}` call of `{component}`")

try:
with ExecTimeoutThreadGuard(self._execution_timeout):
return fn(*(args or []), **(kwargs or {}))
except TimeoutException:
logger.warning(
self.logger.warning(
"`{}` of `{}` was terminated as its execution exceeded the timeout of {} seconds. Please refactor your code!".format(
fn, component, self._execution_timeout
)
Expand Down Expand Up @@ -383,8 +387,7 @@ def teardown(self) -> None:
:return: None
"""
logger.debug("[{}]: Calling teardown method...".format(self.name))
self.liveness.stop()
self.logger.debug("[{}]: Calling teardown method...".format(self.name))
self.decision_maker.stop()
self.task_manager.stop()
self.resources.teardown()
Expand Down
76 changes: 20 additions & 56 deletions aea/aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@
)
from aea.configurations.loader import ConfigLoader
from aea.contracts import contract_registry
from aea.crypto.helpers import (
IDENTIFIER_TO_KEY_FILES,
create_private_key,
try_validate_private_key_path,
)
from aea.crypto.registries import crypto_registry
from aea.crypto.helpers import verify_or_create_private_keys
from aea.crypto.wallet import Wallet
from aea.decision_maker.base import DecisionMakerHandler
from aea.decision_maker.default import (
Expand Down Expand Up @@ -1301,7 +1296,9 @@ def from_aea_project(
"""
aea_project_path = Path(aea_project_path)
cls._try_to_load_agent_configuration_file(aea_project_path)
_verify_or_create_private_keys(aea_project_path)
verify_or_create_private_keys(
aea_project_path=aea_project_path, exit_on_error=False
)
builder = AEABuilder(with_default_packages=False)

# TODO isolate environment
Expand Down Expand Up @@ -1343,11 +1340,17 @@ def _load_and_add_components(

if configuration in self._component_instances[component_type].keys():
component = self._component_instances[component_type][configuration]
if configuration.component_type != ComponentType.SKILL:
component.logger = cast(
logging.Logger, make_logger(configuration, agent_name)
)
else:
configuration = deepcopy(configuration)
component = load_component_from_config(configuration, **kwargs)
_logger = make_logger(configuration, agent_name)
component = load_component_from_config(
configuration, logger=_logger, **kwargs
)

_set_logger_to_component(component, configuration, agent_name)
resources.add_component(component)

def _populate_contract_registry(self):
Expand Down Expand Up @@ -1394,58 +1397,19 @@ def _check_we_can_build(self):
)


def _set_logger_to_component(
component: Component, configuration: ComponentConfiguration, agent_name: str,
) -> None:
def make_logger(
configuration: ComponentConfiguration, agent_name: str,
) -> Optional[logging.Logger]:
"""
Set the logger to the component.
Make the logger for a component.
:param component: the component instance.
:param configuration: the component configuration
:param agent_name: the agent name
:return: None
:return: the logger.
"""
if configuration.component_type == ComponentType.SKILL:
# skip because skill object already have their own logger from the skill context.
return
return None
logger_name = f"aea.packages.{configuration.author}.{configuration.component_type.to_plural()}.{configuration.name}"
logger = AgentLoggerAdapter(logging.getLogger(logger_name), agent_name)
component.logger = logger


# TODO this function is repeated in 'aea.cli.utils.package_utils.py'
def _verify_or_create_private_keys(aea_project_path: Path) -> None:
"""Verify or create private keys."""
path_to_configuration = aea_project_path / DEFAULT_AEA_CONFIG_FILE
agent_loader = ConfigLoader("aea-config_schema.json", AgentConfig)
fp_read = path_to_configuration.open(mode="r", encoding="utf-8")
agent_configuration = agent_loader.load(fp_read)

for identifier, _value in agent_configuration.private_key_paths.read_all():
if identifier not in crypto_registry.supported_ids:
raise ValueError(f"Item not registered with id '{identifier}'.")

for identifier, private_key_path in IDENTIFIER_TO_KEY_FILES.items():
config_private_key_path = agent_configuration.private_key_paths.read(identifier)
if config_private_key_path is None:
create_private_key(
identifier, private_key_file=str(aea_project_path / private_key_path)
)
agent_configuration.private_key_paths.update(identifier, private_key_path)
else:
try:
try_validate_private_key_path(
identifier,
str(aea_project_path / private_key_path),
exit_on_error=False,
)
except FileNotFoundError: # pragma: no cover
logger.error(
"File {} for private key {} not found.".format(
repr(private_key_path), identifier,
)
)
raise

fp_write = path_to_configuration.open(mode="w", encoding="utf-8")
agent_loader.dump(agent_configuration, fp_write)
_logger = AgentLoggerAdapter(logging.getLogger(logger_name), agent_name)
return cast(logging.Logger, _logger)
Loading

0 comments on commit a6ca234

Please sign in to comment.