Skip to content

Commit

Permalink
Merge pull request #1493 from fetchai/develop
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
DavidMinarsch authored Jul 15, 2020
2 parents cc707c2 + ef7177c commit b59aa24
Show file tree
Hide file tree
Showing 295 changed files with 5,227 additions and 2,795 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
sudo apt-get install -y protobuf-compiler
- name: Integrational tests and coverage
run: |
tox -e py3.8 -- --aea-loop sync -m 'integration and not unstable and not ethereum'
tox -e py3.8 -- --aea-loop sync -m 'integration and not unstable and not ledger'
common_checks:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -102,10 +102,12 @@ jobs:
- name: Golang code style check
uses: golangci/golangci-lint-action@v1
with:
version: v1.26
version: v1.28
working-directory: packages/fetchai/connections/p2p_libp2p/
- name: Check package versions in documentation
run: tox -e package_version_checks
- name: Check package dependencies
run: tox -e package_dependencies_checks
- name: Generate Documentation
run: tox -e docs

Expand All @@ -128,9 +130,9 @@ jobs:
pip install pipenv
pip install tox
- name: Integration tests
run: tox -e py3.7 -- -m 'integration and not unstable and not ethereum'
run: tox -e py3.7 -- -m 'integration and not unstable and not ledger'

integration_checks_eth:
integration_checks_ledger:
continue-on-error: True
runs-on: ubuntu-latest

Expand All @@ -149,7 +151,7 @@ jobs:
pip install pipenv
pip install tox
- name: Integration tests
run: tox -e py3.7 -- -m 'integration and not unstable and ethereum'
run: tox -e py3.7 -- -m 'integration and not unstable and ledger'
continue-on-error: true
- name: Force green exit
run: exit 0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ output_file
!packages/fetchai/contracts/erc1155/build
packages/fetchai/connections/p2p_libp2p/libp2p_node

!tests/data/dummy_contract/build
12 changes: 12 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Release History

## 0.5.1 (2020-07-14)

- Adds support for agent name being appended to all log statements
- Adds redesigned GUI
- Extends dialogue api for easier dialogue maintenance
- Resolves blocking logic in oef and gym connections
- Adds full test coverage on aea modules configurations, components and mail
- Adds ping background task for soef connection
- Adds full test coverage for all connection packages
- Multiple docs updates
- Multiple additional tests and test stability fixes

## 0.5.0 (2020-07-06)

- Refactors all connections to be fully async friendly
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.0"
__version__ = "0.5.1"
__author__ = "Fetch.AI Limited"
__license__ = "Apache-2.0"
__copyright__ = "2019 Fetch.AI Limited"
18 changes: 18 additions & 0 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +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.identity.base import Identity
from aea.mail.base import Envelope
from aea.protocols.base import Message
Expand Down Expand Up @@ -135,6 +136,8 @@ def __init__(

self._skills_exception_policy = skill_exception_policy

self._setup_loggers()

@property
def decision_maker(self) -> DecisionMaker:
"""Get decision maker."""
Expand Down Expand Up @@ -383,3 +386,18 @@ def teardown(self) -> None:
self.task_manager.stop()
self.resources.teardown()
ExecTimeoutThreadGuard.stop()

def _setup_loggers(self):
"""Setup logger with agent name. """
for element in [
self.main_loop,
self.multiplexer,
self.task_manager,
self.resources.component_registry,
self.resources.behaviour_registry,
self.resources.handler_registry,
self.resources.model_registry,
]:
element.logger = AgentLoggerAdapter(
element.logger, agent_name=self._identity.name
)
45 changes: 37 additions & 8 deletions aea/aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
from aea.exceptions import AEAException
from aea.helpers.base import load_aea_package, load_module
from aea.helpers.exception_policy import ExceptionPolicyEnum
from aea.helpers.logging import AgentLoggerAdapter
from aea.helpers.pypi import is_satisfiable
from aea.helpers.pypi import merge_dependencies
from aea.identity.base import Identity
Expand Down Expand Up @@ -879,11 +880,12 @@ def build(self, connection_ids: Optional[Collection[PublicId]] = None,) -> AEA:
copy(self.private_key_paths), copy(self.connection_private_key_paths)
)
identity = self._build_identity_from_wallet(wallet)
self._load_and_add_components(ComponentType.PROTOCOL, resources)
self._load_and_add_components(ComponentType.CONTRACT, resources)
self._load_and_add_components(ComponentType.PROTOCOL, resources, identity.name)
self._load_and_add_components(ComponentType.CONTRACT, resources, identity.name)
self._load_and_add_components(
ComponentType.CONNECTION,
resources,
identity.name,
identity=identity,
crypto_store=wallet.connection_cryptos,
)
Expand All @@ -908,7 +910,7 @@ def build(self, connection_ids: Optional[Collection[PublicId]] = None,) -> AEA:
**deepcopy(self._context_namespace),
)
self._load_and_add_components(
ComponentType.SKILL, resources, agent_context=aea.context
ComponentType.SKILL, resources, identity.name, agent_context=aea.context
)
self._build_called = True
self._populate_contract_registry()
Expand Down Expand Up @@ -1346,28 +1348,36 @@ def from_aea_project(
return builder

def _load_and_add_components(
self, component_type: ComponentType, resources: Resources, **kwargs
self,
component_type: ComponentType,
resources: Resources,
agent_name: str,
**kwargs,
) -> None:
"""
Load and add components added to the builder to a Resources instance.
:param component_type: the component type for which
:param resources: the resources object to populate.
:param agent_name: the AEA name for logging purposes.
:param kwargs: keyword argument to forward to the component loader.
:return: None
"""
for configuration in self._package_dependency_manager.get_components_by_type(
component_type
).values():
if configuration.is_abstract_component:
load_aea_package(configuration)
continue

if configuration in self._component_instances[component_type].keys():
component = self._component_instances[component_type][configuration]
resources.add_component(component)
elif configuration.is_abstract_component:
load_aea_package(configuration)
else:
configuration = deepcopy(configuration)
component = load_component_from_config(configuration, **kwargs)
resources.add_component(component)

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

def _populate_contract_registry(self):
"""Populate contract registry."""
Expand Down Expand Up @@ -1413,6 +1423,25 @@ def _check_we_can_build(self):
)


def _set_logger_to_component(
component: Component, configuration: ComponentConfiguration, agent_name: str,
) -> None:
"""
Set the logger to the component.
:param component: the component instance.
:param configuration: the component configuration
:param agent_name: the agent name
:return: None
"""
if configuration.component_type == ComponentType.SKILL:
# skip because skill object already have their own logger from the skill context.
return
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."""
Expand Down
16 changes: 10 additions & 6 deletions aea/agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
PeriodicCaller,
ensure_loop,
)
from aea.helpers.logging import WithLogger
from aea.multiplexer import InBox
from aea.skills.base import Behaviour

Expand All @@ -50,7 +51,7 @@
from aea.agent import Agent # pragma: no cover


class BaseAgentLoop(ABC):
class BaseAgentLoop(WithLogger, ABC):
"""Base abstract agent loop class."""

def __init__(
Expand All @@ -61,6 +62,7 @@ def __init__(
:params agent: Agent or AEA to run.
:params loop: optional asyncio event loop. if not specified a new loop will be created.
"""
WithLogger.__init__(self, logger)
self._agent: "Agent" = agent
self.set_loop(ensure_loop(loop))
self._tasks: List[asyncio.Task] = []
Expand All @@ -77,7 +79,7 @@ def start(self) -> None:

async def run_loop(self) -> None:
"""Run agent loop."""
logger.debug("agent loop started")
self.logger.debug("agent loop started")
self._state.set(AgentLoopStates.started)
self._set_tasks()
try:
Expand Down Expand Up @@ -171,7 +173,9 @@ def _behaviour_exception_callback(self, fn: Callable, exc: Exception) -> None:
:return: None
"""
logger.exception(f"Loop: Exception: `{exc}` occured during `{fn}` processing")
self.logger.exception(
f"Loop: Exception: `{exc}` occured during `{fn}` processing"
)
self._exceptions.append(exc)
self._state.set(AgentLoopStates.error)

Expand Down Expand Up @@ -200,7 +204,7 @@ def _register_behaviour(self, behaviour: Behaviour) -> None:
)
self._behaviours_registry[behaviour] = periodic_caller
periodic_caller.start()
logger.debug(f"Behaviour {behaviour} registered.")
self.logger.debug(f"Behaviour {behaviour} registered.")

def _register_all_behaviours(self) -> None:
"""Register all AEA behaviours to run periodically."""
Expand Down Expand Up @@ -237,7 +241,7 @@ def _stop_tasks(self):
def _set_tasks(self):
"""Set run loop tasks."""
self._tasks = self._create_tasks()
logger.debug("tasks created!")
self.logger.debug("tasks created!")

def _create_tasks(self) -> List[Task]:
"""
Expand All @@ -256,7 +260,7 @@ def _create_tasks(self) -> List[Task]:
async def _task_process_inbox(self) -> None:
"""Process incoming messages."""
inbox: InBox = self._agent.inbox
logger.info("[{}]: Start processing messages...".format(self._agent.name))
self.logger.info("[{}]: Start processing messages...".format(self._agent.name))
while self.is_running:
await inbox.async_wait()

Expand Down
2 changes: 1 addition & 1 deletion aea/cli_gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def start_agent(agent_id: str, connection_id: PublicId):
) # 400 Bad request
else:
agent_process = call_aea_async(
[sys.executable, "-m", "aea.cli", "run"], agent_dir
[sys.executable, "-m", "aea.cli", "run", "--install-deps"], agent_dir
)

if agent_process is None:
Expand Down
Loading

0 comments on commit b59aa24

Please sign in to comment.