Skip to content

Commit

Permalink
Merge pull request #102 from fetchai/develop
Browse files Browse the repository at this point in the history
Release 0.1.4
  • Loading branch information
DavidMinarsch authored Sep 20, 2019
2 parents a8368de + a0c05fa commit bd47b2f
Show file tree
Hide file tree
Showing 56 changed files with 622 additions and 257 deletions.
24 changes: 0 additions & 24 deletions .github/PULL_REQUEST_TEMPLATE/new_release.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,32 @@ _Put an `x` in the boxes that apply._
## Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...


DELETE INCLUSIVE THIS AND BELOW FOR STANDARD PR
------

## Release summary

Version number: [e.g. 1.0.1]

## Release details

Describe in short the main changes with the new release.

## Checklist

_Put an `x` in the boxes that apply._

- [ ] I have read the [CONTRIBUTING](../master/CONTRIBUTING.rst) doc
- [ ] I am making a pull request against the `master` branch (left side), from `develop`
- [ ] Lint and unit tests pass locally
- [ ] I built the documentation and updated it with the latest changes
- [ ] I've added an item in `HISTORY.rst` for this release
- [ ] I bumped the version number in the `aea/__version__.py` file.
- [ ] I bumped the version number in every Docker image of the repo and published it. Also, I built and published them with tag `latest`
- [ ] I have checked that the documentation about the `aea cli` tool works

## Further comments

Write here any other comment about the release, if any.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ Release History
- Adds first two working skills and fixes gym examples
- Adds docs
- Multiple additional minor fixes and changes

0.1.4 (2019-09-20)
-------------------

- Adds cli functionality to add connections
- Multiple additional minor fixes and changes
14 changes: 11 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ pipeline {

} // static type check

stage('Unit Tests: Python 3.6') {
stage('Docs') {

steps {
sh 'tox -e py36 -- --no-integration-tests'
sh 'tox -e docs'
}

} // unit tests: python 3.6
} // docs

// stage('Unit Tests: Python 3.6') {
//
// steps {
// sh 'tox -e py36 -- --no-integration-tests'
// }
//
// } // unit tests: python 3.6

stage('Unit Tests: Python 3.7') {

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
clean: clean-build clean-pyc clean-test
clean: clean-build clean-pyc clean-test clean-docs

clean-build:
rm -fr build/
Expand All @@ -7,6 +7,9 @@ clean-build:
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -fr {} +

clean-docs:
rm -fr site/

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ A framework for autonomous economic agent (AEA) development

## Get started

First, install the package from [test-pypi](https://test.pypi.org/project/aea/):
First, install the package from [pypi](https://pypi.org/project/aea/):

`
pip install cryptography base58
`

`
pip install -i https://test.pypi.org/simple/ aea
pip install aea
`

Then, build your agent as described in the [AEA CLI readme](../master/aea/cli/README.md)
Expand Down
4 changes: 4 additions & 0 deletions aea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
# ------------------------------------------------------------------------------

"""Contains the AEA package."""
import inspect
import os

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

AEA_DIR = os.path.dirname(inspect.getfile(inspect.currentframe()))
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.3'
__version__ = '0.1.4'
__author__ = 'Fetch.AI Limited'
__license__ = 'Apache 2.0'
__copyright__ = '2019 Fetch.AI Limited'
2 changes: 1 addition & 1 deletion aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

logger = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion aea/skills/base/__init__.py → aea/channels/gym/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

# ------------------------------------------------------------------------------
#
# Copyright 2018-2019 Fetch.AI Limited
Expand All @@ -17,4 +18,4 @@
#
# ------------------------------------------------------------------------------

"""This module contains the base components for the skills."""
"""Implementation of the Gym connection."""
17 changes: 16 additions & 1 deletion aea/channels/gym.py → aea/channels/gym/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import threading
from queue import Queue
from threading import Thread
from typing import Dict, Optional
from typing import Dict, Optional, cast

import gym

from aea.helpers.base import locate
from aea.mail.base import Envelope, Channel, Connection
from aea.protocols.gym.message import GymMessage
from aea.protocols.gym.serialization import GymSerializer
from aea.configurations.base import ConnectionConfig

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -228,3 +230,16 @@ def stop(self) -> None:
:return: None
"""
self._connection = None

@classmethod
def from_config(cls, public_key: str, connection_configuration: ConnectionConfig) -> 'Connection':
"""
Get the Gym connection from the connection configuration.
:param public_key: the public key of the agent.
:param connection_configuration: the connection configuration object.
:return: the connection object
"""
gym_env_package = cast(str, connection_configuration.config.get('env'))
gym_env = locate(gym_env_package)
return GymConnection(public_key, gym_env())
9 changes: 9 additions & 0 deletions aea/channels/gym/connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: gym
authors: Fetch.AI Limited
version: 0.1.0
license: Apache 2.0
url: ""
class_name: GymConnection
supported_protocols: ["gym"]
config:
env: '' # put here the dotted path to your Gym Environment class.
21 changes: 21 additions & 0 deletions aea/channels/local/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

# ------------------------------------------------------------------------------
#
# Copyright 2018-2019 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""Implementation of the Local OEF connection."""
13 changes: 12 additions & 1 deletion aea/channels/local.py → aea/channels/local/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from aea.protocols.oef.message import OEFMessage
from aea.protocols.oef.models import Description, Query
from aea.protocols.oef.serialization import OEFSerializer, DEFAULT_OEF
from aea.configurations.base import ConnectionConfig

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -282,7 +283,6 @@ def __init__(self, public_key: str, local_node: LocalNode):
:param public_key: the public key used in the protocols.
:param local_node: the Local OEF Node object. This reference must be the same across the agents of interest.
:param loop: the event loop.
"""
super().__init__()
self.public_key = public_key
Expand Down Expand Up @@ -351,3 +351,14 @@ def send(self, envelope: Envelope):
def stop(self):
"""Tear down the connection."""
self._connection = None

@classmethod
def from_config(cls, public_key: str, connection_configuration: ConnectionConfig) -> 'Connection':
"""Get the Local OEF connection from the connection configuration.
:param public_key: the public key of the agent.
:param connection_configuration: the connection configuration object.
:return: the connection object
"""
local_node = LocalNode()
return OEFLocalConnection(public_key, local_node)
8 changes: 8 additions & 0 deletions aea/channels/local/connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: local
authors: Fetch.AI Limited
version: 0.1.0
license: Apache 2.0
url: ""
class_name: OEFLocalConnection
supported_protocols: ["oef"]
config: {}
21 changes: 21 additions & 0 deletions aea/channels/oef/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

# ------------------------------------------------------------------------------
#
# Copyright 2018-2019 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""Implementation of the OEF connection."""
14 changes: 14 additions & 0 deletions aea/channels/oef.py → aea/channels/oef/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from aea.protocols.oef.message import OEFMessage
from aea.protocols.oef.models import Description, Attribute, DataModel, Query, ConstraintExpr, And, Or, Not, Constraint
from aea.protocols.oef.serialization import OEFSerializer, DEFAULT_OEF
from aea.configurations.base import ConnectionConfig

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -510,6 +511,19 @@ def send(self, envelope: Envelope):
if self._connected:
self.channel.send(envelope)

@classmethod
def from_config(cls, public_key: str, connection_configuration: ConnectionConfig) -> 'Connection':
"""
Get the OEF connection from the connection configuration.
:param public_key: the public key of the agent.
:param connection_configuration: the connection configuration object.
:return: the connection object
"""
oef_addr = cast(str, connection_configuration.config.get("addr"))
oef_port = cast(int, connection_configuration.config.get("port"))
return OEFConnection(public_key, oef_addr, oef_port)


class OEFMailBox(MailBox):
"""The OEF mail box."""
Expand Down
10 changes: 10 additions & 0 deletions aea/channels/oef/connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: oef
authors: Fetch.AI Limited
version: 0.1.0
license: Apache 2.0
url: ""
class_name: OEFConnection
supported_protocols: ["oef"]
config:
addr: 127.0.0.1
port: 10000
28 changes: 17 additions & 11 deletions aea/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@
import os
import shutil
from pathlib import Path
from typing import cast

import click
import click_log
from click import pass_context
from jsonschema import ValidationError

import aea
from aea.cli.add import add
from aea.cli.add import connection, add
from aea.cli.common import Context, pass_ctx, logger
from aea.skills.base.config import DEFAULT_AEA_CONFIG_FILE, ConnectionConfig, AgentConfig
from aea.cli.remove import remove
from aea.cli.run import run
from aea.configurations.base import DEFAULT_AEA_CONFIG_FILE, AgentConfig

DEFAULT_CONNECTION = "oef"


@click.group()
Expand All @@ -47,9 +51,10 @@ def cli(ctx) -> None:

@cli.command()
@click.argument('agent_name', type=str, required=True)
@pass_ctx
def create(ctx: Context, agent_name):
@pass_context
def create(click_context, agent_name):
"""Create an agent."""
ctx = cast(Context, click_context.obj)
path = Path(agent_name)
logger.info("Creating agent's directory in '{}'".format(path))

Expand All @@ -59,16 +64,17 @@ def create(ctx: 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__, private_key_pem_path="")
agent_config.set_default_connection(ConnectionConfig(
name="default-oef",
type="oef",
addr="127.0.0.1",
port=10000
))
agent_config = AgentConfig(agent_name=agent_name, aea_version=aea.__version__, authors="", version="v1", license="", url="", 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))
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))

except OSError:
logger.error("Directory already exist. Aborting...")
exit(-1)
Expand Down
Loading

0 comments on commit bd47b2f

Please sign in to comment.