Skip to content

Commit

Permalink
Merge pull request #2808 from fetchai/develop
Browse files Browse the repository at this point in the history
release 1.2.3
  • Loading branch information
solarw authored Nov 8, 2022
2 parents 813bd60 + 65c9509 commit fb077f9
Show file tree
Hide file tree
Showing 592 changed files with 11,083 additions and 12,994 deletions.
587 changes: 287 additions & 300 deletions .github/workflows/workflow.yml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ignore-patterns=__main__.py,.*_pb2.py,tac.sh,tac_local.sh

[MESSAGES CONTROL]
disable=C0103,C0201,C0301,C0302,W0105,W0707,W1202,W1203,R0801
disable=C0103,C0201,C0301,C0302,W0105,W0707,W1202,W1203,R0801,C0209,R1735

# See here for more options: https://www.codeac.io/documentation/pylint-configuration.html
## Eventually resolve these:
Expand All @@ -19,6 +19,8 @@ disable=C0103,C0201,C0301,C0302,W0105,W0707,W1202,W1203,R0801
# C0302: http://pylint-messages.wikidot.com/messages:c0302 > Too many lines in module (%s) , # kept as no harm
# W0105: pointless-string-statement, # kept as no harm
# R0801: similar lines, # too granular
# C0209: Formatting a regular string which could be a f-string (consider-using-f-string) # to many usage atm
# R1735: Consider using {} instead of dict() (use-dict-literal)

[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
Expand Down
17 changes: 16 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# Release History


## 1.2.1 (2022-10-17)
## 1.2.3(2022-11-03)

AEA:
- core and development are dependencies updated.
- ci improvements
- cosmpy updated to 0.6.0
- Small code format improvements and better linting

Plugins:
- Small code format improvements
- cosmpy updated to 0.6.0

Packages:
- Small code format improvements

## 1.2.2 (2022-10-17)

AEA:
- Dependency management switched from pipenv to poetry.
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__ = "1.2.2"
__version__ = "1.2.3"
__author__ = "Fetch.AI Limited"
__license__ = "Apache-2.0"
__copyright__ = "2022 Fetch.AI Limited"
8 changes: 5 additions & 3 deletions aea/abstract_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# ------------------------------------------------------------------------------
"""This module contains the interface definition of the abstract agent."""
import datetime
from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from typing import Any, Callable, Dict, List, Optional, Tuple

from aea.mail.base import Envelope
Expand All @@ -27,11 +27,13 @@
class AbstractAgent(ABC):
"""This class provides an abstract base interface for an agent."""

@abstractproperty
@property
@abstractmethod
def name(self) -> str:
"""Get agent's name."""

@abstractproperty
@property
@abstractmethod
def storage_uri(self) -> Optional[str]:
"""Return storage uri."""

Expand Down
6 changes: 5 additions & 1 deletion aea/aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,11 @@ def _reset(self, is_full_reset: bool = False) -> None:

def _remove_components_from_dependency_manager(self) -> None:
"""Remove components added via 'add_component' from the dependency manager."""
for component_type in self._component_instances.keys():
for (
component_type
) in (
self._component_instances.keys()
): # pylint: disable=consider-using-dict-items
for component_config in self._component_instances[component_type].keys():
self._package_dependency_manager.remove_component(
component_config.component_id
Expand Down
2 changes: 1 addition & 1 deletion aea/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def start(self) -> None:

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

def handle_envelope(self, envelope: Envelope) -> None:
Expand Down
9 changes: 5 additions & 4 deletions aea/agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ def set_loop(self, loop: AbstractEventLoop) -> None:
"""Set event loop and all event loop related objects."""
self._loop: AbstractEventLoop = loop

def _setup(self) -> None: # pylint: disable=no-self-use
def _setup(self) -> None:
"""Set up agent loop before started."""
# start and stop methods are classmethods cause one instance shared across multiple threads
ExecTimeoutThreadGuard.start()

def _teardown(self) -> None: # pylint: disable=no-self-use
def _teardown(self) -> None:
"""Tear down loop on stop."""
# start and stop methods are classmethods cause one instance shared across multiple threads
ExecTimeoutThreadGuard.stop()
Expand Down Expand Up @@ -295,10 +295,11 @@ def _execution_control(
if self.agent.exception_handler(e, fn) is True:
self._state.set(AgentLoopStates.error)
raise
except Exception as e:
except Exception as e2:
self._state.set(AgentLoopStates.error)
self._exceptions.append(e)
self._exceptions.append(e2)
raise
return None

def _register_periodic_task(
self,
Expand Down
4 changes: 2 additions & 2 deletions aea/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get(ctx: Context, json_path: str) -> None:
agent_config_manager = AgentConfigManager.load(ctx.cwd)
value = agent_config_manager.get_variable(json_path)
except (ValueError, AEAException) as e:
raise ClickException(*e.args)
raise ClickException(str(e.args[0]))

if isinstance(value, dict):
# turn it to json compatible string, not dict str representation
Expand Down Expand Up @@ -101,4 +101,4 @@ def set_command(
except ExtraPropertiesError as e: # pragma: nocover
raise ClickException(f"Attribute `{e.args[0][0]}` is not allowed to change!")
except (ValueError, AEAException) as e:
raise ClickException(*e.args)
raise ClickException(str(e.args[0]))
4 changes: 2 additions & 2 deletions aea/cli/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# ------------------------------------------------------------------------------
"""Implementation of the 'aea fetch' subcommand."""
import os
from distutils.dir_util import copy_tree
from pathlib import Path
from shutil import copytree as copy_tree
from typing import Optional, cast

import click
Expand Down Expand Up @@ -169,7 +169,7 @@ def fetch_agent_locally(
os.makedirs(target_path) # pragma: nocover

ctx.clean_paths.append(target_path)
copy_tree(source_path, target_path)
copy_tree(source_path, target_path, dirs_exist_ok=True) # type: ignore

ctx.cwd = target_path
try_to_load_agent_config(ctx)
Expand Down
8 changes: 5 additions & 3 deletions aea/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@
@click.command()
@click.option("--author", type=str, required=False)
@click.option("--reset", is_flag=True, help="To reset the initialization.")
@click.option("--local", is_flag=True, help="For init AEA locally.")
@click.option(
"--register", is_flag=True, help="To register the author in the AEA registry."
)
@click.option("--no-subscribe", is_flag=True, help="For developers subscription.")
@pass_ctx
def init( # pylint: disable=unused-argument
ctx: Context, author: str, reset: bool, local: bool, no_subscribe: bool
ctx: Context, author: str, reset: bool, register: bool, no_subscribe: bool
) -> None:
"""Initialize your AEA configurations."""
do_init(author, reset, not local, no_subscribe)
do_init(author, reset, register, no_subscribe)


def do_init(author: str, reset: bool, registry: bool, no_subscribe: bool) -> None:
Expand Down
6 changes: 4 additions & 2 deletions aea/cli/registry/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ def publish_agent(ctx: Context) -> None:

files = {}
try:
files["file"] = open(output_tar, "rb")
files["file"] = open(output_tar, "rb") # pylint: disable=consider-using-with
if is_readme_present(readme_source_path):
files["readme"] = open(readme_source_path, "rb")
files["readme"] = open( # pylint: disable=consider-using-with
readme_source_path, "rb"
)
path = "/agents/create"
logger.debug("Publishing agent {} to Registry ...".format(name))
resp = cast(
Expand Down
8 changes: 6 additions & 2 deletions aea/cli/registry/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ def push_item(ctx: Context, item_type: str, item_id: PublicId) -> None:
click.echo(f"Error: Cannot find {package_type} {package_id} in registry!")
raise click.ClickException("Found missing dependencies! Push canceled!")
try:
files = {"file": open(output_filepath, "rb")}
files = {
"file": open(output_filepath, "rb") # pylint: disable=consider-using-with
}
readme_path = os.path.join(item_path, DEFAULT_README_FILE)
if is_readme_present(readme_path):
files["readme"] = open(readme_path, "rb")
files["readme"] = open( # pylint: disable=consider-using-with
readme_path, "rb"
)

path = "/{}/create".format(item_type_plural)
logger.debug("Pushing {} {} to Registry ...".format(item_id.name, item_type))
Expand Down
4 changes: 2 additions & 2 deletions aea/cli/registry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def request_api(
logger.debug("Successfully created!")
elif resp.status_code == 403:
raise click.ClickException(
"You are not authenticated. " 'Please sign in with "aea login" command.'
"""You are not authenticated. 'Please sign in with "aea login" command."""
)
elif resp.status_code == 500:
raise click.ClickException(
Expand Down Expand Up @@ -182,7 +182,7 @@ def extract(source: str, target: str) -> None:
:param target: str path to target directory.
"""
if source.endswith("tar.gz"):
tar = tarfile.open(source, "r:gz")
tar = tarfile.open(source, "r:gz") # pylint: disable=consider-using-with
tar.extractall(path=target)
tar.close()
else:
Expand Down
2 changes: 1 addition & 1 deletion aea/cli/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def check_remove(
item, package_id
)
can_be_removed = set()
can_not_be_removed = dict()
can_not_be_removed = {}

for dep_key, deps in item_deps.items():
if agent_deps[dep_key] == deps:
Expand Down
2 changes: 1 addition & 1 deletion aea/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _profiling_context(period: int) -> Generator:
import os # pylint: disable=import-outside-toplevel
import sys # pylint: disable=import-outside-toplevel

sys.stderr = open(os.devnull, "w")
sys.stderr = open(os.devnull, "w", encoding="utf-8")


def run_aea(
Expand Down
12 changes: 9 additions & 3 deletions aea/cli/scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ def scaffold_item(ctx: Context, item_type: str, item_name: str) -> None:
if not file_path.exists():
continue
py_file = Path(file_path)
py_file.write_text(
re.sub(SCAFFOLD_PUBLIC_ID, str(new_public_id), py_file.read_text())
py_file.write_text( # pylint: disable=unspecified-encoding
re.sub(
SCAFFOLD_PUBLIC_ID,
str(new_public_id),
py_file.read_text(), # pylint: disable=unspecified-encoding
)
)

# fingerprint item.
Expand Down Expand Up @@ -274,7 +278,9 @@ def _scaffold_non_package_item(
)
ctx.agent_loader.dump(
ctx.agent_config,
open_file(os.path.join(ctx.cwd, DEFAULT_AEA_CONFIG_FILE), "w"),
open_file(
os.path.join(ctx.cwd, DEFAULT_AEA_CONFIG_FILE), "w", encoding="utf-8"
),
)

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion aea/cli/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ def _compute_replacements(
"""Compute replacements from old component ids to new components ids."""
agent_config = load_item_config(PackageType.AGENT.value, Path(ctx.cwd))
new_component_ids = list(agent_config.package_dependencies)
replacements: Dict[ComponentId, ComponentId] = dict()
replacements: Dict[ComponentId, ComponentId] = {}
for old_component_id in old_component_ids:
same_prefix = list(filter(old_component_id.same_prefix, new_component_ids))
enforce(len(same_prefix) < 2, "More than one component id found.")
Expand Down
4 changes: 3 additions & 1 deletion aea/cli/utils/click_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def get_metavar(self, param: Any) -> str:
"""Return the metavar default for this param if it provides one."""
return "PUBLIC_ID"

def convert(self, value: str, param: Any, ctx: Optional[click.Context]) -> PublicId:
def convert( # pylint: disable=inconsistent-return-statements
self, value: str, param: Any, ctx: Optional[click.Context]
) -> PublicId:
"""Convert the value. This is not invoked for values that are `None` (the missing value)."""
try:
return PublicId.from_str(value)
Expand Down
6 changes: 4 additions & 2 deletions aea/cli/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Context:

def __init__(self, cwd: str, verbosity: str, registry_path: Optional[str]) -> None:
"""Init the context."""
self.config = dict() # type: Dict
self.config = {} # type: Dict
self.cwd = cwd
self.verbosity = verbosity
self.clean_paths: List = []
Expand Down Expand Up @@ -193,5 +193,7 @@ def get_dependencies(self) -> Dependencies:

def dump_agent_config(self) -> None:
"""Dump the current agent configuration."""
with open(os.path.join(self.cwd, DEFAULT_AEA_CONFIG_FILE), "w") as f:
with open(
os.path.join(self.cwd, DEFAULT_AEA_CONFIG_FILE), "w", encoding="utf-8"
) as f:
self.agent_loader.dump(self.agent_config, f)
2 changes: 1 addition & 1 deletion aea/components/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def component_type_to_class(component_type: ComponentType) -> Type[Component]:
return type_to_class[component_type]


def load_component_from_config( # type: ignore
def load_component_from_config( # type: ignore # pylint: disable=inconsistent-return-statements #pylint mistake
configuration: ComponentConfiguration, *args, **kwargs
) -> Component:
"""
Expand Down
4 changes: 2 additions & 2 deletions aea/configurations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def _apply_params_to_instance(
if instance is None:
instance = cls(**params)
else:
instance.__init__(**params) # type: ignore
instance.__init__(**params) # type: ignore # pylint: disable=unnecessary-dunder-call

if directory and not instance.directory:
instance.directory = directory
Expand Down Expand Up @@ -930,7 +930,7 @@ def _apply_params_to_instance(
if instance is None:
instance = cls(**params)
else: # pragma: nocover
instance.__init__(**params) # type: ignore
instance.__init__(**params) # type: ignore # pylint: disable=unnecessary-dunder-call
return instance


Expand Down
1 change: 1 addition & 0 deletions aea/configurations/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def json(self) -> Dict:
"""Compute the JSON representation."""

@classmethod
@abstractmethod
def from_json(cls, obj: Dict) -> "JSONSerializable":
"""Build from a JSON object."""

Expand Down
5 changes: 4 additions & 1 deletion aea/configurations/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ def _validate(self, instance: Dict) -> None:
@staticmethod
def _build_message_from_errors(errors: List[jsonschema.ValidationError]) -> str:
"""Build an error message from validation errors."""
path = lambda error: ".".join(list(error.path)) # noqa # type: ignore

def path(error): # type: ignore
return ".".join(list(error.path))

result = [f"{path(error)}: {error.message}" for error in errors]
return "The following errors occurred during validation:\n - " + "\n - ".join(
result
Expand Down
2 changes: 1 addition & 1 deletion aea/crypto/registries/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, seq: Union["EntryPoint", str]) -> None:

if match is None:
# actual match done in base class
raise ValueError("No match found!") #  pragma: nocover
raise ValueError("No match found!") # pragma: nocover

self._import_path = match.group(1)
self._class_name = match.group(2)
Expand Down
4 changes: 2 additions & 2 deletions aea/decision_maker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def __init__(self, access_code: str) -> None:
super().__init__()
self._access_code_hash = _hash(access_code)

def put( # pylint: disable=arguments-differ
def put( # pylint: disable=arguments-differ,arguments-renamed
self,
internal_message: Optional[Message],
block: bool = True,
Expand All @@ -180,7 +180,7 @@ def put( # pylint: disable=arguments-differ
raise ValueError("Only messages are allowed!")
super().put(internal_message, block=True, timeout=None)

def put_nowait( # pylint: disable=arguments-differ
def put_nowait( # pylint: disable=arguments-differ,arguments-renamed
self, internal_message: Optional[Message]
) -> None:
"""
Expand Down
Loading

0 comments on commit fb077f9

Please sign in to comment.