Skip to content

Commit

Permalink
Merge pull request #1864 from fetchai/develop
Browse files Browse the repository at this point in the history
Release v0.7.0
  • Loading branch information
DavidMinarsch authored Oct 22, 2020
2 parents 63e46ce + 9006d02 commit 2aaddb7
Show file tree
Hide file tree
Showing 599 changed files with 64,977 additions and 6,756 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
timeout-minutes: 30
timeout-minutes: 40
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@master
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ input_file
output_file

!packages/fetchai/contracts/erc1155/build
!packages/fetchai/contracts/staking_erc20/build
packages/fetchai/connections/p2p_libp2p/libp2p_node

!tests/data/dummy_contract/build
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ ignored-modules=aiohttp,defusedxml,gym,fetch,matplotlib,memory_profiler,numpy,oe

[DESIGN]
min-public-methods=1
max-public-methods=35
max-public-methods=36
20 changes: 20 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Release History

## 0.7.0 (2020-10-22)

- Adds two AEAs for Agent World 1
- Adds support to apply config overrides to CLI calls transfer and get-wealth
- Adds install scripts to install AEA and dependencies on all major OS (Windows, MacOs, Ubuntu)
- Adds developer mailing list opt-in step to CLI init
- Modifies custom configs in aea-config to use public id
- Adds all non-optional fields in aea-config by default
- Fixes upgrade command to properly handle dependencies of non-vendor packages
- Remove all distributed packages and add them to registry
- Adds public ids to all skill init files and makes it a requirement
- Adds primitive benchmarks for libp2p node
- Adds Prometheus monitoring to libp2p node
- Makes body a private attribute in message base class
- Renames bodyy to body in http protocol
- Adds support for abstract connections
- Refactors protobuf schemas for protocols to avoid code duplication
- Multiple docs updates based on user feedback
- Multiple additional tests and test stability fixes

## 0.6.3 (2020-10-16)

- Adds skill testing tools and documentation
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,20 @@ common_checks: security misc_checks lint static docs

.PHONY: test
test:
pytest -rfE --doctest-modules aea packages/fetchai/protocols packages/fetchai/connections packages/fetchai/skills/generic_buyer tests/ --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov=aea --cov=packages/fetchai/protocols --cov=packages/fetchai/connections --cov=packages/fetchai/skills/generic_buyer --cov-config=.coveragerc
pytest -rfE --doctest-modules aea packages/fetchai/protocols packages/fetchai/connections packages/fetchai/skills/generic_buyer packages/fetchai/skills/generic_seller tests/ --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov=aea --cov=packages/fetchai/protocols --cov=packages/fetchai/connections --cov=packages/fetchai/skills/generic_buyer --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;

.PHONY: test-sub
test-sub:
pytest -rfE --doctest-modules aea packages/fetchai/connections tests/test_$(tdir) --cov=aea.$(dir) --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov-config=.coveragerc
pytest -rfE --doctest-modules aea packages/fetchai/connections packages/fetchai/protocols packages/fetchai/skills/generic_buyer packages/fetchai/skills/generic_seller tests/test_$(tdir) --cov=aea.$(dir) --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;

.PHONY: test-sub-p
test-sub-p:
pytest -rfE --doctest-modules aea packages/fetchai/connections packages/fetchai/protocols packages/fetchai/skills/generic_buyer packages/fetchai/skills/generic_seller tests/test_packages/test_$(tdir) --cov=packages.fetchai.$(dir) --cov-report=html --cov-report=xml --cov-report=term-missing --cov-report=term --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;


.PHONY: test-all
test-all:
tox
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.6.3"
__version__ = "0.7.0"
__author__ = "Fetch.AI Limited"
__license__ = "Apache-2.0"
__copyright__ = "2019 Fetch.AI Limited"
81 changes: 51 additions & 30 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
List,
Optional,
Sequence,
TYPE_CHECKING,
Tuple,
Type,
cast,
Expand All @@ -38,26 +39,31 @@
from aea.agent import Agent
from aea.agent_loop import AsyncAgentLoop, BaseAgentLoop, SyncAgentLoop
from aea.configurations.base import PublicId
from aea.configurations.constants import DEFAULT_SKILL
from aea.configurations.constants import (
DEFAULT_PROTOCOL,
DEFAULT_SEARCH_SERVICE_ADDRESS,
DEFAULT_SKILL,
)
from aea.connections.base import Connection
from aea.context.base import AgentContext
from aea.crypto.wallet import Wallet
from aea.decision_maker.base import DecisionMakerHandler
from aea.decision_maker.default import (
DecisionMakerHandler as DefaultDecisionMakerHandler,
)
from aea.exceptions import AEAException
from aea.helpers.exception_policy import ExceptionPolicyEnum
from aea.helpers.logging import AgentLoggerAdapter, get_logger
from aea.identity.base import Identity
from aea.mail.base import Envelope
from aea.protocols.base import Message
from aea.protocols.default.message import DefaultMessage
from aea.protocols.base import Message, Protocol
from aea.registries.filter import Filter
from aea.registries.resources import Resources
from aea.runtime import _StopRuntime
from aea.skills.base import Behaviour, Handler
from aea.skills.error.handlers import ErrorHandler


if TYPE_CHECKING:
from packages.fetchai.skills.error.handlers import ( # noqa: F401 # pragma: nocover
ErrorHandler,
)


class AEA(Agent):
Expand All @@ -78,17 +84,15 @@ def __init__(
period: float = 0.05,
execution_timeout: float = 0,
max_reactions: int = 20,
decision_maker_handler_class: Type[
DecisionMakerHandler
] = DefaultDecisionMakerHandler,
decision_maker_handler_class: Optional[Type[DecisionMakerHandler]] = None,
skill_exception_policy: ExceptionPolicyEnum = ExceptionPolicyEnum.propagate,
connection_exception_policy: ExceptionPolicyEnum = ExceptionPolicyEnum.propagate,
loop_mode: Optional[str] = None,
runtime_mode: Optional[str] = None,
default_connection: Optional[PublicId] = None,
default_routing: Optional[Dict[PublicId, PublicId]] = None,
connection_ids: Optional[Collection[PublicId]] = None,
search_service_address: str = "fetchai/soef:*",
search_service_address: str = DEFAULT_SEARCH_SERVICE_ADDRESS,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -132,6 +136,13 @@ def __init__(
)

self.max_reactions = max_reactions

if decision_maker_handler_class is None:
from aea.decision_maker.default import ( # isort:skip # pylint: disable=import-outside-toplevel
DecisionMakerHandler as DefaultDecisionMakerHandler,
)

decision_maker_handler_class = DefaultDecisionMakerHandler
decision_maker_handler = decision_maker_handler_class(
identity=identity, wallet=wallet
)
Expand Down Expand Up @@ -229,38 +240,37 @@ def get_multiplexer_setup_options(self) -> Optional[Dict]:
default_connection=self.context.default_connection,
)

def _get_error_handler(self) -> Optional[Handler]:
def _get_error_handler(self) -> Handler:
"""Get error handler."""
return self.resources.get_handler(DefaultMessage.protocol_id, DEFAULT_SKILL)
handler = self.resources.get_handler(DEFAULT_PROTOCOL, DEFAULT_SKILL)
if handler is None:
self.logger.warning("ErrorHandler not initialized. Stopping AEA!")
raise _StopRuntime()
return handler

def _get_msg_and_handlers_for_envelope(
self, envelope: Envelope
) -> Tuple[Optional[Message], List[Handler]]:
protocol = self.resources.get_protocol(envelope.protocol_id)

msg, handlers = self._handle_decoding(envelope, protocol)

return msg, handlers

def _handle_decoding(
self, envelope: Envelope, protocol: Optional[Protocol]
) -> Tuple[Optional[Message], List[Handler]]:
error_handler = self._get_error_handler()

if error_handler is None:
self.logger.warning("ErrorHandler not initialized. Stopping AEA!")
raise _StopRuntime()
from packages.fetchai.skills.error.handlers import ( # noqa: F811 # pylint: disable=import-outside-toplevel
ErrorHandler,
)

error_handler = cast(ErrorHandler, error_handler)

if protocol is None:
error_handler.send_unsupported_protocol(envelope)
return None, []

if isinstance(envelope.message, Message):
msg = envelope.message
else:
try:
msg = protocol.serializer.decode(envelope.message)
msg.sender = envelope.sender
msg.to = envelope.to
except Exception as e: # pylint: disable=broad-except # thats ok, because we send the decoding error back
self.logger.warning("Decoding error. Exception: {}".format(str(e)))
error_handler.send_decoding_error(envelope)
return None, []
return None, [] # Tuple[Optional[Message], List[Handler]]

handlers = self.filter.get_active_handlers(
protocol.public_id, envelope.skill_id
Expand All @@ -270,7 +280,18 @@ def _get_msg_and_handlers_for_envelope(
error_handler.send_unsupported_skill(envelope)
return None, []

return msg, handlers
if isinstance(envelope.message, Message):
msg = envelope.message
return msg, handlers
try:
msg = protocol.serializer.decode(envelope.message)
msg.sender = envelope.sender
msg.to = envelope.to
return msg, handlers
except Exception as e: # pylint: disable=broad-except # thats ok, because we send the decoding error back
self.logger.warning("Decoding error. Exception: {}".format(str(e)))
error_handler.send_decoding_error(envelope)
return None, []

def handle_envelope(self, envelope: Envelope) -> None:
"""
Expand Down
Loading

0 comments on commit 2aaddb7

Please sign in to comment.