Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is connected status to skill context #390

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, name: str,
self.wallet.public_keys,
self.wallet.addresses,
ledger_apis,
self.mailbox.is_connected,
self.outbox,
self.decision_maker.message_in_queue,
self.decision_maker.ownership_state,
Expand Down
8 changes: 8 additions & 0 deletions aea/context/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, agent_name: str,
public_keys: Dict[str, str],
addresses: Dict[str, str],
ledger_apis: LedgerApis,
is_connected: bool,
outbox: OutBox,
decision_maker_message_queue: Queue,
ownership_state: OwnershipState,
Expand All @@ -45,6 +46,7 @@ def __init__(self, agent_name: str,
:param agent_name: the agent's name
:param public_keys: the public keys of the agent
:param ledger_apis: the ledger apis
:param is_connected: the connection status
:param outbox: the outbox
:param decision_maker_message_queue: the (in) queue of the decision maker
:param ownership_state: the ownership state of the agent
Expand All @@ -55,6 +57,7 @@ def __init__(self, agent_name: str,
self._public_keys = public_keys
self._addresses = addresses
self._ledger_apis = ledger_apis
self._is_connected = is_connected
self._outbox = outbox
self._decision_maker_message_queue = decision_maker_message_queue
self._ownership_state = ownership_state
Expand Down Expand Up @@ -86,6 +89,11 @@ def public_key(self) -> str:
"""Get the default public key."""
return self._public_keys['default']

@property
def is_connected(self) -> bool:
"""Get connection status."""
return self._is_connected

@property
def outbox(self) -> OutBox:
"""Get outbox."""
Expand Down
5 changes: 5 additions & 0 deletions aea/skills/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def agent_address(self) -> str:
"""Get address."""
return self._agent_context.address

@property
def is_connected(self) -> bool:
"""Get connection status."""
return self._agent_context.is_connected

@property
def outbox(self) -> OutBox:
"""Get outbox."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def test_initialise_AEA():
ledger_apis = LedgerApis({})
my_AEA = AEA("Agent0", mailbox1, wallet, ledger_apis, resources=Resources(str(Path(CUR_PATH, "aea"))))
assert my_AEA.context == my_AEA._context, "Cannot access the Agent's Context"
assert not my_AEA.context.is_connected, "AEA should not be connected."
my_AEA.setup()
assert my_AEA.resources is not None,\
"Resources must not be None after setup"
Expand Down