Skip to content

Commit

Permalink
Merge latest develop
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMinarsch committed Mar 18, 2021
2 parents 2e19a8b + 77c591c commit e8aa088
Show file tree
Hide file tree
Showing 400 changed files with 6,018 additions and 3,219 deletions.
3 changes: 0 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ omit =
packages/fetchai/contracts/*
packages/fetchai/skills/aries_alice/*
packages/fetchai/skills/aries_faber/*
packages/fetchai/skills/carpark_detection/*
packages/fetchai/skills/echo/*
packages/fetchai/skills/erc1155_client/*
packages/fetchai/skills/erc1155_deploy/*
packages/fetchai/skills/gym/*
packages/fetchai/skills/http_echo/*
packages/fetchai/skills/registration_aw1/*
packages/fetchai/skills/thermometer/*
packages/fetchai/skills/weather_station/*
plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py
13 changes: 10 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,20 @@ jobs:

dependencies_checks:
continue-on-error: False
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python_version: [3.6]
timeout-minutes: 10
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@master
with:
python-version: 3.6
python-version: ${{ matrix.python_version }}
- name: Install tox
run : |
pip install tox
- name: Check Pipfile and tox.ini consistency
run : |
python ./scripts/check_pipfile_and_toxini.py
Expand All @@ -199,7 +206,7 @@ jobs:
pip install -e .[all]
- name: Check aea dependenices and imports
run: |
python ./scripts/check_imports_and_dependencies.py
tox -e dependencies_check
protolint:
continue-on-error: False
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ max-locals=31
max-statements=80
max-parents=11
max-branches=24
max-attributes=32
max-attributes=36

[REFACTORING]
max-nested-blocks=6
16 changes: 16 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Release History

## 0.11.2 (2020-03-17)

- Fixes a package import issue
- Fixes an issue where `AgentLoop` did not teardown properly under certain conditions
- Fixes a bug in testing tools
- Fixes a bug where plugins are not loaded after installation in `MultiAgentManager`
- Adds unit tests for weather, thermometer and car park skills
- Fixes a missing dependency in Windows
- Improves SOEF connections' error handling
- Fixes bug in ML skills and adds unit tests
- Adds script to bump plugin versions
- Adds gas price strategy support in `aea-ledger-ethereum` plugin
- Adds CLI plugin for IPFS interactions (add/get)
- Adds support for CLI plugins to framework
- Multiple additional tests and test stability fixes

## 0.11.1 (2020-03-06)

- Bumps `aiohttp` to `>=3.7.4` to address a CVE affecting `http_server`, `http_client` and `webhook` connections
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,21 @@ lint:

.PHONY: pylint
pylint:
pylint -j4 aea benchmark packages scripts plugins/aea-ledger-fetchai/aea_ledger_fetchai plugins/aea-ledger-ethereum/aea_ledger_ethereum plugins/aea-ledger-cosmos/aea_ledger_cosmos examples/*
pylint -j4 aea benchmark packages scripts plugins/aea-ledger-fetchai/aea_ledger_fetchai plugins/aea-ledger-ethereum/aea_ledger_ethereum plugins/aea-ledger-cosmos/aea_ledger_cosmos plugins/aea-cli-ipfs/aea_cli_ipfs examples/*

.PHONY: security
security:
bandit -r aea benchmark examples packages \
plugins/aea-ledger-fetchai/aea_ledger_fetchai \
plugins/aea-ledger-ethereum/aea_ledger_ethereum \
plugins/aea-ledger-cosmos/aea_ledger_cosmos
bandit -s B101 -r tests scripts \
plugins/aea-ledger-fetchai/tests \
plugins/aea-ledger-ethereum/tests \
plugins/aea-ledger-cosmos/tests
plugins/aea-ledger-cosmos/aea_ledger_cosmos \
plugins/aea-cli-ipfs/aea_cli_ipfs
bandit -s B101 -r tests scripts
safety check -i 37524 -i 38038 -i 37776 -i 38039 -i 39621

.PHONY: static
static:
mypy aea benchmark examples packages plugins/aea-ledger-fetchai/aea_ledger_fetchai plugins/aea-ledger-ethereum/aea_ledger_ethereum plugins/aea-ledger-cosmos/aea_ledger_cosmos scripts --disallow-untyped-defs
mypy aea benchmark examples packages plugins/aea-ledger-fetchai/aea_ledger_fetchai plugins/aea-ledger-ethereum/aea_ledger_ethereum plugins/aea-ledger-cosmos/aea_ledger_cosmos plugins/aea-cli-ipfs/aea_cli_ipfs scripts --disallow-untyped-defs
mypy tests

.PHONY: package_checks
Expand All @@ -84,6 +82,7 @@ test:
pytest -rfE plugins/aea-ledger-fetchai/tests --cov=aea_ledger_fetchai --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE plugins/aea-ledger-ethereum/tests --cov=aea_ledger_ethereum --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE plugins/aea-ledger-cosmos/tests --cov=aea_ledger_cosmos --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE plugins/aea-cli-ipfs/tests --cov=aea_cli_ipfs --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
pytest -rfE --doctest-modules aea packages/fetchai/protocols packages/fetchai/connections packages/fetchai/skills tests/ --cov=aea --cov=packages/fetchai/connections --cov=packages/fetchai/contracts --cov=packages/fetchai/protocols --cov=packages/fetchai/skills --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 --cov-config=.coveragerc
find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \;

Expand Down Expand Up @@ -137,6 +136,7 @@ new_env: clean
pipenv run pip install --no-deps file:plugins/aea-ledger-ethereum;\
pipenv run pip install --no-deps file:plugins/aea-ledger-cosmos;\
pipenv run pip install --no-deps file:plugins/aea-ledger-fetchai;\
pipenv run pip install --no-deps file:plugins/aea-cli-ipfs;\
echo "Enter virtual environment with all development dependencies now: 'pipenv shell'.";\
else\
echo "In a virtual environment! Exit first: 'exit'.";\
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.11.1"
__version__ = "1.0.0rc1"
__author__ = "Fetch.AI Limited"
__license__ = "Apache-2.0"
__copyright__ = "2019 Fetch.AI Limited"
16 changes: 11 additions & 5 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def __init__(
execution_timeout: float = 0,
max_reactions: int = 20,
error_handler_class: Optional[Type[AbstractErrorHandler]] = None,
error_handler_config: Optional[Dict[str, Any]] = None,
decision_maker_handler_class: Optional[Type[DecisionMakerHandler]] = None,
decision_maker_handler_config: Optional[Dict[str, Any]] = None,
skill_exception_policy: ExceptionPolicyEnum = ExceptionPolicyEnum.propagate,
connection_exception_policy: ExceptionPolicyEnum = ExceptionPolicyEnum.propagate,
loop_mode: Optional[str] = None,
Expand Down Expand Up @@ -177,14 +179,18 @@ def __init__(
)

decision_maker_handler_class = DefaultDecisionMakerHandler
if decision_maker_handler_config is None:
decision_maker_handler_config = {}
decision_maker_handler = decision_maker_handler_class(
identity=identity, wallet=wallet
identity=identity, wallet=wallet, config=decision_maker_handler_config
)
self.runtime.set_decision_maker(decision_maker_handler)

if error_handler_class is None:
error_handler_class = DefaultErrorHandler
self._error_handler_class = error_handler_class
if error_handler_config is None:
error_handler_config = {}
self._error_handler = error_handler_class(**error_handler_config)
default_ledger_id = (
default_ledger
if default_ledger is not None
Expand Down Expand Up @@ -271,9 +277,9 @@ def act(self) -> None:
"""
self.filter.handle_new_handlers_and_behaviours()

def _get_error_handler(self) -> Type[AbstractErrorHandler]:
def _get_error_handler(self) -> AbstractErrorHandler:
"""Get error handler."""
return self._error_handler_class
return self._error_handler

def _get_msg_and_handlers_for_envelope(
self, envelope: Envelope
Expand All @@ -297,7 +303,7 @@ def _handle_decoding(
self,
envelope: Envelope,
protocol: Protocol,
error_handler: Type[AbstractErrorHandler],
error_handler: AbstractErrorHandler,
) -> Tuple[Optional[Message], List[Handler]]:

handlers = self.filter.get_active_handlers(
Expand Down
102 changes: 81 additions & 21 deletions aea/aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ def _reset(self, is_full_reset: bool = False) -> None:
self._decision_maker_handler_class: Optional[Type[DecisionMakerHandler]] = None
self._decision_maker_handler_dotted_path: Optional[str] = None
self._decision_maker_handler_file_path: Optional[str] = None
self._decision_maker_handler_config: Optional[Dict[str, Any]] = None
self._error_handler_class: Optional[Type[AbstractErrorHandler]] = None
self._error_handler_dotted_path: Optional[str] = None
self._error_handler_file_path: Optional[str] = None
self._error_handler_config: Optional[Dict[str, Any]] = None
self._skill_exception_policy: Optional[ExceptionPolicyEnum] = None
self._connection_exception_policy: Optional[ExceptionPolicyEnum] = None
self._default_routing: Dict[PublicId, PublicId] = {}
Expand Down Expand Up @@ -436,19 +440,24 @@ def set_max_reactions(self, max_reactions: Optional[int]) -> "AEABuilder":
self._max_reactions = max_reactions
return self

def set_decision_maker_handler_paths(
self, decision_maker_handler_dotted_path: str, file_path: Optional[str]
def set_decision_maker_handler_details(
self,
decision_maker_handler_dotted_path: str,
file_path: str,
config: Dict[str, Any],
) -> "AEABuilder":
"""
Set decision maker handler class.
Set error handler details.
:param decision_maker_handler_dotted_path: the dotted path to the decision maker handler
:param file_path: the file path to the file which contains the decision maker handler
:param config: the configuration passed to the decision maker handler on instantiation
:return: self
"""
self._decision_maker_handler_dotted_path = decision_maker_handler_dotted_path
self._decision_maker_handler_file_path = file_path
self._decision_maker_handler_config = config
return self

def _load_decision_maker_handler_class(
Expand Down Expand Up @@ -484,7 +493,7 @@ def _load_decision_maker_handler_class(
dotted_path, self._decision_maker_handler_file_path, e
)
)
raise # log and re-raise because we should not build an agent from an. invalid configuration
raise # log and re-raise because we should not build an agent from an invalid configuration

try:
_class = getattr(module, class_name)
Expand All @@ -494,37 +503,68 @@ def _load_decision_maker_handler_class(
dotted_path, class_name, self._decision_maker_handler_file_path, e
)
)
raise # log and re-raise because we should not build an agent from an. invalid configuration
raise # log and re-raise because we should not build an agent from an invalid configuration

return _class

def set_error_handler(
self, error_handler_dotted_path: str, file_path: Path
) -> "AEABuilder":
def _load_error_handler_class(self,) -> Optional[Type[AbstractErrorHandler]]:
"""
Set error handler class.
:param error_handler_dotted_path: the dotted path to the error handler
:param file_path: the file path to the file which contains the error handler
Load error handler class.
:return: self
:return: error handler class
"""
dotted_path, class_name = error_handler_dotted_path.split(
_class = self._get_error_handler_class()
if _class is not None and self._error_handler_dotted_path is not None:
raise ValueError( # pragma: nocover
"ErrorHandler class and dotted path set: can only set one!"
)
if _class is not None:
return _class # pragma: nocover
if self._error_handler_dotted_path is None:
return None
dotted_path, class_name = self._error_handler_dotted_path.split(
DOTTED_PATH_MODULE_ELEMENT_SEPARATOR
)
module = load_module(dotted_path, file_path)
try:
if self._error_handler_file_path is None:
module = import_module(dotted_path)
else:
module = load_module(dotted_path, Path(self._error_handler_file_path))
except Exception as e: # pragma: nocover
self.logger.error(
"Could not locate error handler for dotted path '{}' and file path '{}'. Error message: {}".format(
dotted_path, self._error_handler_file_path, e
)
)
raise # log and re-raise because we should not build an agent from an invalid configuration

try:
_class = getattr(module, class_name)
self._error_handler_class = _class
except Exception as e: # pragma: nocover
self.logger.error(
"Could not locate error handler for dotted path '{}', class name '{}' and file path '{}'. Error message: {}".format(
dotted_path, class_name, file_path, e
dotted_path, class_name, self._error_handler_file_path, e
)
)
raise # log and re-raise because we should not build an agent from an. invalid configuration
raise # log and re-raise because we should not build an agent from an invalid configuration

return _class

def set_error_handler_details(
self, error_handler_dotted_path: str, file_path: str, config: Dict[str, Any]
) -> "AEABuilder":
"""
Set error handler details.
:param error_handler_dotted_path: the dotted path to the error handler
:param file_path: the file path to the file which contains the error handler
:param config: the configuration passed to the error handler on instantiation
:return: self
"""
self._error_handler_dotted_path = error_handler_dotted_path
self._error_handler_file_path = file_path
self._error_handler_config = config
return self

def set_skill_exception_policy(
Expand Down Expand Up @@ -1272,8 +1312,10 @@ def build(
period=self._get_agent_act_period(),
execution_timeout=self._get_execution_timeout(),
max_reactions=self._get_max_reactions(),
error_handler_class=self._get_error_handler_class(),
error_handler_class=self._load_error_handler_class(),
error_handler_config=self._get_error_handler_config(),
decision_maker_handler_class=self._load_decision_maker_handler_class(),
decision_maker_handler_config=self._get_decision_maker_handler_config(),
skill_exception_policy=self._get_skill_exception_policy(),
connection_exception_policy=self._get_connection_exception_policy(),
currency_denominations=self._get_currency_denominations(),
Expand Down Expand Up @@ -1340,6 +1382,14 @@ def _get_error_handler_class(self,) -> Optional[Type]:
"""
return self._error_handler_class

def _get_error_handler_config(self,) -> Optional[Dict[str, Any]]:
"""
Return the error handler config.
:return: error handler config
"""
return self._error_handler_config

def _get_decision_maker_handler_class(
self,
) -> Optional[Type[DecisionMakerHandler]]:
Expand All @@ -1350,6 +1400,14 @@ def _get_decision_maker_handler_class(
"""
return self._decision_maker_handler_class

def _get_decision_maker_handler_config(self,) -> Optional[Dict[str, Any]]:
"""
Return the decision maker handler config.
:return: decision maker handler config
"""
return self._decision_maker_handler_config

def _get_skill_exception_policy(self) -> ExceptionPolicyEnum:
"""
Return the skill exception policy.
Expand Down Expand Up @@ -1599,11 +1657,13 @@ def set_from_configuration(
if agent_configuration.decision_maker_handler != {}:
dotted_path = agent_configuration.decision_maker_handler["dotted_path"]
file_path = agent_configuration.decision_maker_handler["file_path"]
self.set_decision_maker_handler_paths(dotted_path, file_path)
config = agent_configuration.error_handler["config"]
self.set_decision_maker_handler_details(dotted_path, file_path, config)
if agent_configuration.error_handler != {}:
dotted_path = agent_configuration.error_handler["dotted_path"]
file_path = agent_configuration.error_handler["file_path"]
self.set_error_handler(dotted_path, file_path)
config = agent_configuration.error_handler["config"]
self.set_error_handler_details(dotted_path, file_path, config)
if agent_configuration.skill_exception_policy is not None:
self.set_skill_exception_policy(
ExceptionPolicyEnum(agent_configuration.skill_exception_policy)
Expand Down
Loading

0 comments on commit e8aa088

Please sign in to comment.