Skip to content

Commit

Permalink
Merge pull request #465 from fetchai/develop
Browse files Browse the repository at this point in the history
Release v0.1.14
  • Loading branch information
DavidMinarsch authored Nov 29, 2019
2 parents 9688dc8 + 19f446d commit bf4badf
Show file tree
Hide file tree
Showing 244 changed files with 14,957 additions and 6,675 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ venv.bak/
data/*
temp_private_key.pem
.idea/

input_file
output_file
15 changes: 15 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ Release History
- Updates oef connection to re-establish dropped connections
- Updates the car park agent
- Multiple additional minor fixes and changes

0.1.14 (2019-11-29)
-------------------

- Removes dependency on OEF SDK's FIPA API
- Replaces dialogue id with dialogue references
- Improves CLI logging and list/search command output
- Introduces multiplexer and removes mailbox
- Adds much improved tac skills
- Adds support for CLI integration with registry
- Increases test coverage to 99%
- Introduces integration tests for skills and examples
- Adds support to run multiple connections from CLI
- Updates the docs and adds uml diagrams
- Multiple additional minor fixes and changes
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ clean-test:
rm -fr .hypothesis
rm -fr .pytest_cache
rm -fr .mypy_cache/
rm -fr input_file
rm -fr output_file
find . -name 'log.txt' -exec rm -fr {} +
find . -name 'log.*.txt' -exec rm -fr {} +

Expand Down
6 changes: 6 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ pytest-cov = "*"
mypy = "*"
mkdocs = "*"
mkdocs-material = "*"
bs4 = "*"
pymdown-extensions = "*"
pygments = "*"
pytest-asyncio = "*"
gym = "*"
numpy = "*"
scikit-image = "*"
mkdocs-mermaid-plugin = {editable = true,git = "https://github.com/pugong/mkdocs-mermaid-plugin.git"}

[packages]
cryptography = "*"
Expand Down
537 changes: 428 additions & 109 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aea/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
__title__ = 'aea'
__description__ = 'Autonomous Economic Agent framework'
__url__ = 'https://github.com/fetchai/agents-aea.git'
__version__ = '0.1.13'
__version__ = '0.1.14'
__author__ = 'Fetch.AI Limited'
__license__ = 'Apache 2.0'
__copyright__ = '2019 Fetch.AI Limited'
20 changes: 11 additions & 9 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@

"""This module contains the implementation of an Autonomous Economic Agent."""
import logging
from typing import Optional, cast
from asyncio import AbstractEventLoop
from typing import Optional, cast, List

from aea.agent import Agent
from aea.connections.base import Connection
from aea.context.base import AgentContext
from aea.crypto.ledger_apis import LedgerApis
from aea.crypto.wallet import Wallet
from aea.decision_maker.base import DecisionMaker
from aea.mail.base import Envelope, MailBox
from aea.mail.base import Envelope
from aea.registries.base import Filter, Resources
from aea.skills.error.handlers import ErrorHandler

Expand All @@ -37,18 +39,20 @@ class AEA(Agent):
"""This class implements an autonomous economic agent."""

def __init__(self, name: str,
mailbox: MailBox,
connections: List[Connection],
wallet: Wallet,
ledger_apis: LedgerApis,
resources: Resources,
loop: Optional[AbstractEventLoop] = None,
timeout: float = 0.0,
debug: bool = False,
max_reactions: int = 20) -> None:
"""
Instantiate the agent.
:param name: the name of the agent
:param mailbox: the mailbox of the agent.
:param connections: the list of connections of the agent.
:param loop: the event loop to run the connections.
:param wallet: the wallet of the agent.
:param ledger_apis: the ledger apis of the agent.
:param resources: the resources of the agent.
Expand All @@ -58,11 +62,9 @@ def __init__(self, name: str,
:return: None
"""
super().__init__(name=name, wallet=wallet, timeout=timeout, debug=debug)
super().__init__(name=name, wallet=wallet, connections=connections, loop=loop, timeout=timeout, debug=debug)

self.max_reactions = max_reactions

self.mailbox = mailbox
self._decision_maker = DecisionMaker(self.name,
self.max_reactions,
self.outbox,
Expand All @@ -72,12 +74,12 @@ def __init__(self, name: str,
self.wallet.public_keys,
self.wallet.addresses,
ledger_apis,
self.mailbox.connection_status,
self.multiplexer.connection_status,
self.outbox,
self.decision_maker.message_in_queue,
self.decision_maker.ownership_state,
self.decision_maker.preferences,
self.decision_maker.is_ready_to_pursuit_goals)
self.decision_maker.goal_pursuit_readiness)
self._resources = resources
self._filter = Filter(self.resources, self.decision_maker.message_out_queue)

Expand Down
46 changes: 28 additions & 18 deletions aea/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import logging
import time
from abc import abstractmethod, ABC
from asyncio import AbstractEventLoop
from enum import Enum
from typing import Optional
from typing import Optional, List

from aea.connections.base import Connection
from aea.crypto.wallet import Wallet
from aea.mail.base import InBox, OutBox, MailBox
from aea.mail.base import InBox, OutBox, Multiplexer

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -57,39 +59,49 @@ class Agent(ABC):
"""This class implements a template agent."""

def __init__(self, name: str,
connections: List[Connection],
wallet: Wallet,
loop: Optional[AbstractEventLoop] = None,
timeout: float = 1.0,
debug: bool = False) -> None:
"""
Instantiate the agent.
:param name: the name of the agent
:param connections: the list of connections of the agent.
:param wallet: the crypto wallet of the agent.
:param loop: the event loop to run the connections.
:param timeout: the time in (fractions of) seconds to time out an agent between act and react
:param debug: if True, run the agent in debug mode.
:return: None
"""
self._name = name
self._connections = connections
self._wallet = wallet

self._multiplexer = Multiplexer(self._connections, loop=loop)
self._inbox = InBox(self._multiplexer)
self._outbox = OutBox(self._multiplexer)
self._liveness = Liveness()
self._timeout = timeout

self.debug = debug

self.mailbox = None # type: Optional[MailBox]
@property
def multiplexer(self) -> Multiplexer:
"""Get the multiplexer."""
return self._multiplexer

@property
def inbox(self) -> InBox:
"""Get the inbox."""
assert self.mailbox is not None, "Cannot retrieve inbox. No mailbox specified."
return self.mailbox.inbox
return self._inbox

@property
def outbox(self) -> OutBox:
"""Get the outbox."""
assert self.mailbox is not None, "Cannot retrieve outbox. No mailbox specified."
return self.mailbox.outbox
return self._outbox

@property
def name(self) -> str:
Expand Down Expand Up @@ -119,11 +131,11 @@ def agent_state(self) -> AgentState:
:return the agent state.
:raises ValueError: if the state does not satisfy any of the foreseen conditions.
"""
if self.mailbox is None or not self.mailbox.is_connected:
if self.multiplexer is not None and not self.multiplexer.connection_status.is_connected:
return AgentState.INITIATED
elif self.mailbox.is_connected and self.liveness.is_stopped:
elif self.multiplexer.connection_status.is_connected and self.liveness.is_stopped:
return AgentState.CONNECTED
elif self.mailbox.is_connected and not self.liveness.is_stopped:
elif self.multiplexer.connection_status.is_connected and not self.liveness.is_stopped:
return AgentState.RUNNING
else:
raise ValueError("Agent state not recognized.") # pragma: no cover
Expand All @@ -134,9 +146,8 @@ def start(self) -> None:
:return: None
"""
assert self.mailbox is not None, "Cannot call start without mailbox instantiated."
if not self.debug and not self.mailbox.is_connected:
self.mailbox.connect()
if not self.debug and not self.multiplexer.connection_status.is_connected:
self.multiplexer.connect()

logger.debug("[{}]: Calling setup method...".format(self.name))
self.setup()
Expand Down Expand Up @@ -164,15 +175,14 @@ def stop(self) -> None:
:return: None
"""
assert self.mailbox is not None, "Cannot call stop without mailbox instantiated."
logger.debug("[{}]: Stopping message processing...".format(self.name))
self.liveness._is_stopped = True
if self.mailbox.is_connected:
self.mailbox.disconnect()

logger.debug("[{}]: Calling teardown method...".format(self.name))
self.teardown()

logger.debug("[{}]: Stopping message processing...".format(self.name))
if self.multiplexer.connection_status.is_connected:
self.multiplexer.disconnect()

@abstractmethod
def setup(self) -> None:
"""
Expand Down
Loading

0 comments on commit bf4badf

Please sign in to comment.