Skip to content

Commit

Permalink
Merge pull request #273 from valory-xyz/cli-aea-test
Browse files Browse the repository at this point in the history
Add `aea test`
  • Loading branch information
DavidMinarsch authored Sep 4, 2022
2 parents 6eeb8d4 + 35b9f1c commit 53216cc
Show file tree
Hide file tree
Showing 214 changed files with 3,564 additions and 1,302 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ disable=C0103,C0201,C0301,C0302,W0105,W0707,W1202,W1203,R0801,E1136
# W0212: protected-access

[IMPORTS]
ignored-modules=bech32,ecdsa,lru,eth_typing,eth_keys,eth_account,ipfshttpclient,werkzeug,openapi_spec_validator,aiohttp,multidict,yoti_python_sdk,defusedxml,gym,fetch,matplotlib,memory_profiler,numpy,oef,openapi_core,psutil,tensorflow,temper,skimage,web3,aioprometheus,pyaes,Crypto,asn1crypto,cosmpy,google
ignored-modules=bech32,ecdsa,lru,eth_typing,eth_keys,eth_account,ipfshttpclient,werkzeug,openapi_spec_validator,aiohttp,multidict,yoti_python_sdk,defusedxml,gym,fetch,matplotlib,memory_profiler,numpy,oef,openapi_core,psutil,tensorflow,temper,skimage,web3,aioprometheus,pyaes,Crypto,asn1crypto,cosmpy,google,coverage

[DESIGN]
min-public-methods=1
Expand Down
42 changes: 41 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
# Release History - open AEA

## 1.18.0 (2022-09-04)

## 1.17.0
AEA:
- Fixes protocol header string regex.
- Adds `FIELDS_WITH_NESTED_FIELDS` and `NESTED_FIELDS_ALLOWED_TO_UPDATE` in the base config class.
- Introduces `aea test` command group:
- `aea test item_type public_id`: Run all tests of the AEA package specified by `item_type` and `public_id`
- `aea test by-path package_dir`: Run all the tests of the AEA package located at `package_dir`
- `aea test packages`: Runs all tests in the `packages` (local registry) folder.
- `aea test`: Runs tests in the `tests` folder, if present in the agent folder.

Tests:
- Ports tests for the following packages into their respective package folders
- `packages/valory/protocols/acn`
- `packages/valory/protocols/tendermint`
- `packages/valory/connections/p2p_libp2p/libp2p_node/dht/dhttests`
- `packages/open_aea/protocols/signing`
- `packages/fetchai/skills/generic_seller`
- `packages/fetchai/skills/http_echo`
- `packages/fetchai/skills/echo`
- `packages/fetchai/skills/erc1155_client`
- `packages/fetchai/skills/gym`
- `packages/fetchai/skills/erc1155_deploy`
- `packages/fetchai/skills/generic_buyer`
- `packages/fetchai/protocols/http`
- `packages/fetchai/protocols/fipa`
- `packages/fetchai/protocols/default`
- `packages/fetchai/protocols/state_update`
- `packages/fetchai/protocols/ledger_api`
- `packages/fetchai/protocols/oef_search`
- `packages/fetchai/protocols/contract_api`
- `packages/fetchai/protocols/gym`
- `packages/fetchai/protocols/tac`
- `packages/fetchai/connections/ledger`
- `packages/fetchai/connections/http_server`
- `packages/fetchai/connections/local`
- `packages/fetchai/connections/stub`
- `packages/fetchai/connections/gym`
- `packages/fetchai/connections/http_client`
- `packages/fetchai/contracts/erc1155`

## 1.17.0 (2022-08-26)

AEA:
- Updates the deploy image Dockerfile to use Python 3.10
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,18 @@ security:
# update copyright headers
.PHONY: generators
generators:
rm -rf packages/fetchai/connections/stub/input_file
tox -e fix-copyright
python -m aea.cli generate-all-protocols
python -m aea.cli generate-all-protocols tests/data/packages
python -m aea.cli hash all
python -m aea.cli hash all --packages-dir=./tests/data/packages
python -m aea.cli generate-all-protocols
python -m aea.cli generate-all-protocols tests/data/packages
tox -e generate-api-documentation
tox -e fix-doc-hashes

.PHONY: common-checks-1
common-checks:
tox -p -e check-copyright -e hash_check -e package-dependencies-checks
tox -p -e check-copyright -e hash-check -e package-dependencies-checks

.PHONY: common-checks-2
common-checks-2:
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ The following table shows which versions of `open-aea` are currently being suppo

| Version | Supported |
| --------- | ------------------ |
| `1.17.x` | :white_check_mark: |
| `< 1.17.0` | :x: |
| `1.18.x` | :white_check_mark: |
| `< 1.18.0` | :x: |

## Reporting a Vulnerability

Expand Down
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__ = "open-aea"
__description__ = "Open Autonomous Economic Agent framework (without vendor lock-in)"
__url__ = "https://github.com/valory-xyz/open-aea.git"
__version__ = "1.17.0"
__version__ = "1.18.0"
__author__ = "Valory AG"
__license__ = "Apache-2.0"
__copyright__ = "2021 Valory AG, 2019 Fetch.AI Limited"
2 changes: 2 additions & 0 deletions aea/cli/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
from aea.cli.run import run
from aea.cli.scaffold import scaffold
from aea.cli.search import search
from aea.cli.test import test
from aea.cli.transfer import transfer
from aea.cli.upgrade import upgrade
from aea.cli.utils.click_utils import registry_path_option
Expand Down Expand Up @@ -140,6 +141,7 @@ def cli(
cli.add_command(scaffold)
cli.add_command(search)
cli.add_command(local_registry_sync)
cli.add_command(test)
cli.add_command(transfer)
cli.add_command(upgrade)
cli.add_command(hash_group)
Expand Down
35 changes: 4 additions & 31 deletions aea/cli/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
#
# ------------------------------------------------------------------------------
"""Implementation of the 'aea add' subcommand."""
import os
from pathlib import Path
from typing import Dict, Optional, Union, cast

import click

from aea.cli.utils.click_utils import PublicIdParameter
from aea.cli.utils.click_utils import (
PublicIdParameter,
determine_package_type_for_directory,
)
from aea.cli.utils.context import Context
from aea.cli.utils.decorators import check_aea_project, pass_ctx
from aea.configurations.base import (
Expand Down Expand Up @@ -137,35 +139,6 @@ def fingerprint_package_by_path(
)


def determine_package_type_for_directory(package_dir: Path) -> PackageType:
"""
Find package type for the package directory by checking config file names.
:param package_dir: package dir to determine package type:
:return: PackageType
"""
config_files = list(
set(os.listdir(str(package_dir))).intersection(
set(CONFIG_FILE_TO_PACKAGE_TYPE.keys())
)
)

if len(config_files) > 1:
raise ValueError(
f"Too many config files in the directory, only one has to present!: {', '.join(config_files)}"
)
if len(config_files) == 0:
raise ValueError(
f"No package config file found in `{str(package_dir)}`. Incorrect directory?"
)

config_file = config_files[0]
package_type = PackageType(CONFIG_FILE_TO_PACKAGE_TYPE[config_file])

return package_type


def fingerprint_package(
package_dir: Path,
package_type: Union[str, PackageType],
Expand Down
10 changes: 9 additions & 1 deletion aea/cli/generate_all_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from aea.common import JSONLike
from aea.configurations.base import ComponentType, ProtocolConfig
from aea.configurations.constants import (
AEA_TEST_DIRNAME,
DEFAULT_PROTOCOL_CONFIG_FILE,
DEFAULT_README_FILE,
PROTOCOLS,
Expand Down Expand Up @@ -157,9 +158,9 @@ def _fix_generated_protocol(package_path: Path) -> None:
:param package_path: path to the protocol package. Used also to recover the protocol name.
"""
log(f"Restore original custom types in {package_path}")
custom_types_module = package_path / CUSTOM_TYPE_MODULE_NAME
if custom_types_module.exists():
log(f"Restore original custom types in {package_path}")
file_to_replace = Path(PROTOCOLS, package_path.name, CUSTOM_TYPE_MODULE_NAME)
file_to_replace.write_text(custom_types_module.read_text())

Expand All @@ -171,6 +172,13 @@ def _fix_generated_protocol(package_path: Path) -> None:
Path(PROTOCOLS, package_path.name, DEFAULT_README_FILE),
)

tests_module = package_path / AEA_TEST_DIRNAME
if tests_module.is_dir():
log(f"Restore original `tests` directory in {package_path}")
shutil.copytree(
tests_module, Path(PROTOCOLS, package_path.name, AEA_TEST_DIRNAME)
)


def _update_original_protocol(package_path: Path) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion aea/cli/local_registry_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

import click

from aea.cli.fingerprint import determine_package_type_for_directory
from aea.cli.registry.add import fetch_package
from aea.cli.registry.utils import get_package_meta
from aea.cli.utils.click_utils import determine_package_type_for_directory
from aea.cli.utils.context import Context
from aea.cli.utils.decorators import pass_ctx
from aea.cli.utils.loggers import logger
Expand Down
Loading

0 comments on commit 53216cc

Please sign in to comment.