Skip to content

Commit

Permalink
Merge pull request #110 from fetchai/develop
Browse files Browse the repository at this point in the history
Release 0.1.5
  • Loading branch information
DavidMinarsch authored Sep 26, 2019
2 parents bd47b2f + d681feb commit dca2fe9
Show file tree
Hide file tree
Showing 173 changed files with 6,386 additions and 1,472 deletions.
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ Release History

- Adds cli functionality to add connections
- Multiple additional minor fixes and changes

0.1.5 (2019-09-26)
-------------------

- Adds scaffolding command to the CLI tool
- Extended docs
- Increased test coverage
- Multiple additional minor fixes and changes
16 changes: 9 additions & 7 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@ verify_ssl = true
name = "test-pypi"

[dev-packages]
flake8 = "*"
pytest = "*"
tox = "==3.7.0"
tox-pipenv = "==1.9.0"
pytest-cov = "*"
flake8 = "*"
flake8-docstrings = "*"
pygments = "*"
docker = "*"
pydocstyle = "==3.0.0"
pytest = "*"
pytest-cov = "*"
mypy = "*"
mkdocs = "*"
mkdocs-material = "*"
pymdown-extensions = "*"
pygments = "*"

[packages]
cryptography = "*"
base58 = "*"
docker = "*"
click = "*"
pyyaml = "*"
pyyaml = ">=4.2b1"
click-log = "*"
oef = {index = "test-pypi",version = "==0.6.10"}
colorlog = "*"
jsonschema = "*"
protobuf = "*"
mkdocs = "*"

[requires]
python_version = "3.7"
309 changes: 170 additions & 139 deletions Pipfile.lock

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ First, install the package from [pypi](https://pypi.org/project/aea/):
pip install aea
`

Then, build your agent as described in the [AEA CLI readme](../master/aea/cli/README.md)
Then, build your agent as described in the [AEA CLI readme](../master/aea/cli/README.md) or in the [examples](../master/examples).

## Dependencies
## Install from Source

## Cloning

This repository contains submodules. Clone with recursive strategy:

git clone git@github.com:fetchai/agents-aea.git --recursive && cd agents-aea

### Dependencies

All python specific dependencies are specified in the Pipfile (and installed via the commands specified in 'Preliminaries').

Or, you can have more control on the installed dependencies by leveraging the setuptools' extras mechanism (more details later).

## Preliminaries
### Preliminaries

- Create and launch a virtual environment:

Expand All @@ -27,9 +35,9 @@ Or, you can have more control on the installed dependencies by leveraging the se

pip install .[all]

- To install only specific extra dependencies, e.g. `cli` and `oef-protocol`:
- To install only specific extra dependencies, e.g. `cli`:

pip install .[cli,oef-channel]
pip install .[cli]

## Contribute

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__ = 'aea'
__description__ = 'Autonomous Economic Agent framework'
__url__ = 'https://github.com/fetchai/agents-aea.git'
__version__ = '0.1.4'
__version__ = '0.1.5'
__author__ = 'Fetch.AI Limited'
__license__ = 'Apache 2.0'
__copyright__ = '2019 Fetch.AI Limited'
30 changes: 14 additions & 16 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

from aea.agent import Agent
from aea.mail.base import Envelope, MailBox
from aea.skills.base import AgentContext, Resources
from aea.skills.default.handler import DefaultHandler
from aea.registries.base import Resources
from aea.skills.base import AgentContext
from aea.skills.error.handler import ErrorHandler

logger = logging.getLogger(__name__)

Expand All @@ -36,7 +37,7 @@ class AEA(Agent):
def __init__(self, name: str,
mailbox: MailBox,
private_key_pem_path: Optional[str] = None,
timeout: float = 0.0, # TODO we might want to set this to 0 for the aea and let the skills take care of slowing things down on a skill level
timeout: float = 0.0,
debug: bool = False,
max_reactions: int = 20,
directory: str = '') -> None:
Expand Down Expand Up @@ -113,31 +114,28 @@ def handle(self, envelope: Envelope) -> None:
"""
protocol = self.resources.protocol_registry.fetch(envelope.protocol_id)

# fetch the handler of the "default" protocol for error handling. TODO: change with the handler of "error" protocol.
default_handler = self.resources.handler_registry.fetch("default")
default_handler = cast(DefaultHandler, default_handler)
error_handler = self.resources.handler_registry.fetch_by_skill("default", "error")
assert error_handler is not None, "ErrorHandler not initialized"
error_handler = cast(ErrorHandler, error_handler)

if protocol is None:
if default_handler is not None:
default_handler.send_unsupported_protocol(envelope)
error_handler.send_unsupported_protocol(envelope)
return

try:
msg = protocol.serializer.decode(envelope.message)
except Exception:
if default_handler is not None:
default_handler.send_decoding_error(envelope)
error_handler.send_decoding_error(envelope)
return

if not protocol.check(msg):
if default_handler is not None:
default_handler.send_invalid_message(envelope)
return
if not protocol.check(msg): # pragma: no cover
error_handler.send_invalid_message(envelope) # pragma: no cover
return # pragma: no cover

handlers = self.resources.handler_registry.fetch(protocol.id)
if handlers is None:
if default_handler is not None:
default_handler.send_unsupported_skill(envelope, protocol)
if error_handler is not None:
error_handler.send_unsupported_skill(envelope, protocol)
return

# each handler independently acts on the message
Expand Down
2 changes: 1 addition & 1 deletion aea/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def agent_state(self) -> AgentState:
elif self.mailbox.is_connected and not self.liveness.is_stopped:
return AgentState.RUNNING
else:
raise ValueError("Agent state not recognized.")
raise ValueError("Agent state not recognized.") # pragma: no cover

def start(self) -> None:
"""
Expand Down
19 changes: 13 additions & 6 deletions aea/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
from jsonschema import ValidationError

import aea
from aea.cli.add import connection, add
from aea.cli.add import connection, add, skill
from aea.cli.common import Context, pass_ctx, logger
from aea.cli.remove import remove
from aea.cli.run import run
from aea.cli.scaffold import scaffold
from aea.configurations.base import DEFAULT_AEA_CONFIG_FILE, AgentConfig

DEFAULT_CONNECTION = "oef"
DEFAULT_SKILL = "error"


@click.group()
Expand All @@ -64,16 +66,20 @@ def create(click_context, agent_name):

# create a config file inside it
config_file = open(os.path.join(agent_name, DEFAULT_AEA_CONFIG_FILE), "w")
agent_config = AgentConfig(agent_name=agent_name, aea_version=aea.__version__, authors="", version="v1", license="", url="", private_key_pem_path="")
agent_config = AgentConfig(agent_name=agent_name, aea_version=aea.__version__, authors="", version="v1", license="", url="", registry_path="../packages", private_key_pem_path="")
agent_config.default_connection = DEFAULT_CONNECTION
ctx.agent_loader.dump(agent_config, config_file)
logger.info("Created config file {}".format(DEFAULT_AEA_CONFIG_FILE))

logger.info("Adding default connection '{}' to the agent...".format(DEFAULT_CONNECTION))
# next commands must be done from the agent's directory -> overwrite ctx.cwd
ctx.agent_config = agent_config
# next command must be done from the agent's directory -> overwrite ctx.cwd
ctx.cwd = agent_config.agent_name
click_context.invoke(connection, dirpath=os.path.join(aea.AEA_DIR, "channels", DEFAULT_CONNECTION))

logger.info("Adding default connection '{}' to the agent...".format(DEFAULT_CONNECTION))
click_context.invoke(connection, connection_name=DEFAULT_CONNECTION)

logger.info("Adding default skill '{}' to the agent...".format(DEFAULT_SKILL))
click_context.invoke(skill, skill_name=DEFAULT_SKILL)

except OSError:
logger.error("Directory already exist. Aborting...")
Expand Down Expand Up @@ -105,8 +111,9 @@ def delete(ctx: Context, agent_name):


cli.add_command(add)
cli.add_command(scaffold)
cli.add_command(remove)
cli.add_command(run)

if __name__ == '__main__':
cli()
cli() # pragma: no cover
Loading

0 comments on commit dca2fe9

Please sign in to comment.