Skip to content

Commit

Permalink
Merge pull request #1784 from fetchai/develop
Browse files Browse the repository at this point in the history
Release v0.6.2
  • Loading branch information
DavidMinarsch authored Oct 1, 2020
2 parents ce418be + 343241c commit fadf792
Show file tree
Hide file tree
Showing 576 changed files with 9,258 additions and 5,171 deletions.
1 change: 1 addition & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
- name: Code style check
run: |
tox -e black-check
tox -e isort-check
tox -e flake8
- name: Unused code check
run: tox -e vulture
Expand Down
9 changes: 6 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
ignore-patterns=serialization.py,message.py,__main__.py,.*_pb2.py

[MESSAGES CONTROL]
disable=C0103,C0201,C0301,C0302,C0330,W0105,W0107,W1202,W1203,R0902,R0913,R0914,R0801,R0904,R0903,R0911,R0912,R0901,R0916,R1702,R0915
disable=C0103,C0201,C0301,C0302,C0330,W0105,W0107,W0707,W1202,W1203,R0902,R0913,R0914,R0801,R0911,R0912,R0901,R0916,R1702,R0915

## Eventually resolve these:
# W0707: raise-missing-from
# R0902: too-many-instance-attributes
# R0913: too-many-arguments
# R0914: too-many-locals
# R0904: too-many-public-methods
# R0903: too-few-public-methods
# R0911: too-many-return-statements
# R0912: too-many-branches
# R0901: too-many-ancestors
Expand All @@ -32,3 +31,7 @@ disable=C0103,C0201,C0301,C0302,C0330,W0105,W0107,W1202,W1203,R0902,R0913,R0914,

[IMPORTS]
ignored-modules=aiohttp,defusedxml,gym,fetch,matplotlib,memory_profiler,numpy,oef,openapi_core,psutil,tensorflow,temper,skimage,vyper,web3

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

## 0.6.2 (2020-10-01)

- Adds MultiAgentManager to manage multiple agent projects programmatically
- Improves SOEF connection reliability on unregister
- Extends configuration classes to handle overriding configurations programmatically
- Improves configuration schemas and validations
- Fixes Multiplexer termination errors
- Allow finer-grained override of component configurations from aea-config
- Fixes tac controller to work with Ethereum contracts again
- Fixes multiple deploy and development scripts
- Introduces isort to development dependencies for automated import sorting
- Adds reset password command to CLI
- Adds support for abbreviated public ids (latest) to CLI and configurations
- Adds additional docstring linters for improved api documentation checks
- Multiple docs updates including additional explanations of ACN architecture
- Multiple additional tests and test stability fixes

## 0.6.1 (2020-09-17)

- Adds a standalone script to deploy an ACN node
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 *.md
recursive-include aea *.json *.yaml *.proto *.ico *png *.html *.js *.css *.md *.cfg
recursive-include docs *
recursive-include examples *
recursive-include packages *
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ clean-test:
.PHONY: lint
lint:
black aea benchmark examples packages scripts tests
isort aea benchmark examples packages scripts tests
flake8 aea benchmark examples packages scripts tests
vulture aea scripts/whitelist.py --exclude "*_pb2.py"

Expand Down
5 changes: 3 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ flake8 = "==3.7.9"
flake8-bugbear = "==20.1.4"
flake8-docstrings = "==1.5.0"
flake8-eradicate = "==0.4.0"
flake8-import-order = "==0.18.1"
flake8-isort = "==4.0.0"
gym = "==0.15.6"
ipfshttpclient = "==0.6.1"
liccheck = "==0.4.3"
Expand All @@ -40,7 +40,7 @@ pexpect = "==4.8.0"
psutil = "==5.7.0"
pydocstyle = "==3.0.0"
pygments = "==2.5.2"
pylint = "==2.5.2"
pylint = "==2.6.0"
pymdown-extensions = "==6.3"
pynacl = "==1.3.0"
pytest = "==5.4.3"
Expand All @@ -54,6 +54,7 @@ sqlalchemy = "==1.3.17"
tox = "==3.15.1"
vulture = "==2.1"
vyper = "==0.1.0b12"
isort = "==5.5.2"

[packages]
# we don't specify dependencies for the library here for intallation as per: https://pipenv-fork.readthedocs.io/en/latest/advanced.html#pipfile-vs-setuppy
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ The following steps are **only relevant if you intend to contribute** to the rep

tox -e black

- To run isort code formatter:

tox -e isort

- To run bandit security checks:

tox -e bandit
Expand Down
12 changes: 10 additions & 2 deletions aea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@

import inspect
import os

import aea.crypto # triggers registry population
from aea.__version__ import (
__author__,
__copyright__,
__description__,
__license__,
__title__,
__url__,
__version__,
)

from aea.__version__ import __title__, __description__, __url__, __version__
from aea.__version__ import __author__, __license__, __copyright__

AEA_DIR = os.path.dirname(inspect.getfile(inspect.currentframe())) # type: ignore
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.1"
__version__ = "0.6.2"
__author__ = "Fetch.AI Limited"
__license__ = "Apache-2.0"
__copyright__ = "2019 Fetch.AI Limited"
14 changes: 8 additions & 6 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from aea.protocols.default.message import DefaultMessage
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

Expand Down Expand Up @@ -241,8 +242,8 @@ def _get_msg_and_handlers_for_envelope(

if error_handler is None:
self.logger.warning("ErrorHandler not initialized. Stopping AEA!")
self.stop()
return None, []
raise _StopRuntime()

error_handler = cast(ErrorHandler, error_handler)

if protocol is None:
Expand Down Expand Up @@ -341,7 +342,7 @@ def get_message_handlers(self) -> List[Tuple[Callable[[Any], None], Callable]]:
:return: List of tuples of callables: handler and coroutine to get a message
"""
return super(AEA, self).get_message_handlers() + [
return super().get_message_handlers() + [
(self.filter.handle_internal_message, self.filter.get_internal_message,),
]

Expand All @@ -363,9 +364,10 @@ def log_exception(e, fn):

if self._skills_exception_policy == ExceptionPolicyEnum.stop_and_exit:
log_exception(exception, function)
self.stop()
raise AEAException(
f"AEA was terminated cause exception `{exception}` in skills {function}! Please check logs."
raise _StopRuntime(
AEAException(
f"AEA was terminated cause exception `{exception}` in skills {function}! Please check logs."
)
)

if self._skills_exception_policy == ExceptionPolicyEnum.just_log:
Expand Down
75 changes: 59 additions & 16 deletions aea/aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
)

import jsonschema

from packaging.specifiers import SpecifierSet

from aea import AEA_DIR
Expand Down Expand Up @@ -84,6 +83,7 @@
from aea.identity.base import Identity
from aea.registries.resources import Resources


PathLike = Union[os.PathLike, Path, str]

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -292,6 +292,8 @@ class AEABuilder:
DEFAULT_RUNTIME_MODE = "threaded"
DEFAULT_SEARCH_SERVICE_ADDRESS = "fetchai/soef:*"

loader = ConfigLoader.from_configuration_type(PackageType.AGENT)

# pylint: disable=attribute-defined-outside-init

def __init__(self, with_default_packages: bool = True):
Expand Down Expand Up @@ -1336,16 +1338,46 @@ def from_aea_project(
builder = AEABuilder(with_default_packages=False)

# load agent configuration file
configuration_file = aea_project_path / DEFAULT_AEA_CONFIG_FILE
configuration_file = cls.get_configuration_file_path(aea_project_path)
agent_configuration = cls.loader.load(configuration_file.open())

builder.set_from_configuration(
agent_configuration, aea_project_path, skip_consistency_check
)
return builder

@classmethod
def from_config_json(
cls,
json_data: List[Dict],
aea_project_path: PathLike,
skip_consistency_check: bool = False,
) -> "AEABuilder":
"""
Load agent configuration for alreaady provided json data.
:param json_data: list of dicts with agent configuration
:param aea_project_path: path to project root
:param skip_consistency_check: skip consistency check on configs load.
:return: AEABuilder instance
"""
aea_project_path = Path(aea_project_path)
builder = AEABuilder(with_default_packages=False)

loader = ConfigLoader.from_configuration_type(PackageType.AGENT)
agent_configuration = loader.load(configuration_file.open())
# load agent configuration file
agent_configuration = cls.loader.load_agent_config_from_json(json_data)

builder.set_from_configuration(
agent_configuration, aea_project_path, skip_consistency_check
)
return builder

@staticmethod
def get_configuration_file_path(aea_project_path: Union[Path, str]) -> Path:
"""Return path to aea-config file for the given aea project path."""
return Path(aea_project_path) / DEFAULT_AEA_CONFIG_FILE

def _load_and_add_components(
self,
component_type: ComponentType,
Expand All @@ -1365,26 +1397,20 @@ def _load_and_add_components(
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]
if configuration.component_type != ComponentType.SKILL:
component.logger = cast(
logging.Logger, make_logger(configuration, agent_name)
)
else:
configuration = deepcopy(configuration)
configuration.update(
self._custom_component_configurations.get(
configuration.component_id, {}
)
)
_logger = make_logger(configuration, agent_name)
new_configuration = self._overwrite_custom_configuration(configuration)
if new_configuration.is_abstract_component:
load_aea_package(configuration)
continue
_logger = make_logger(new_configuration, agent_name)
component = load_component_from_config(
configuration, logger=_logger, **kwargs
new_configuration, logger=_logger, **kwargs
)

resources.add_component(component)
Expand All @@ -1398,6 +1424,23 @@ def _check_we_can_build(self):
"Please call 'reset() if you want to build another agent."
)

def _overwrite_custom_configuration(self, configuration: ComponentConfiguration):
"""
Overwrite custom configurations.
It deep-copies the configuration, to avoid undesired side-effects.
:param configuration: the configuration object.
:param custom_config: the configurations to apply.
:return: the new configuration instance.
"""
new_configuration = deepcopy(configuration)
custom_config = self._custom_component_configurations.get(
new_configuration.component_id, {}
)
new_configuration.update(custom_config)
return new_configuration


def make_logger(
configuration: ComponentConfiguration, agent_name: str,
Expand Down
10 changes: 9 additions & 1 deletion aea/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the implementation of a generic agent."""
import datetime
import logging
Expand All @@ -24,6 +25,7 @@

from aea.abstract_agent import AbstractAgent
from aea.connections.base import Connection
from aea.exceptions import AEAException
from aea.identity.base import Identity
from aea.mail.base import Envelope
from aea.multiplexer import InBox, OutBox
Expand Down Expand Up @@ -191,7 +193,12 @@ def start(self) -> None:
:return: None
"""
self.runtime.start()
was_started = self.runtime.start()

if was_started:
self.runtime.wait_completed(sync=True)
else:
raise AEAException("Failed to start runtime! Was it already started?")

def stop(self) -> None:
"""
Expand All @@ -206,6 +213,7 @@ def stop(self) -> None:
:return: None
"""
self.runtime.stop()
self.runtime.wait_completed(sync=True)

@property
def state(self) -> RuntimeStates:
Expand Down
Loading

0 comments on commit fadf792

Please sign in to comment.