Skip to content

Commit

Permalink
Merge pull request #188 from fetchai/develop
Browse files Browse the repository at this point in the history
Release v0.1.6
  • Loading branch information
DavidMinarsch authored Oct 7, 2019
2 parents dca2fe9 + 438293f commit e26b0ae
Show file tree
Hide file tree
Showing 162 changed files with 7,084 additions and 674 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ venv.bak/
*/.DS_Store

data/*
temp_private_key.pem

.idea/

8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ Release History
- Extended docs
- Increased test coverage
- Multiple additional minor fixes and changes

0.1.6 (2019-10-04)
-------------------

- Adds several new skills
- Extended docs on framework and skills
- Introduces core framework components like decision maker and shared classes
- Multiple additional minor fixes and changes
129 changes: 65 additions & 64 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
from aea.__version__ import __title__, __description__, __url__, __version__
from aea.__version__ import __author__, __license__, __copyright__

AEA_DIR = os.path.dirname(inspect.getfile(inspect.currentframe()))
AEA_DIR = os.path.dirname(inspect.getfile(inspect.currentframe())) # type: ignore
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.5'
__version__ = '0.1.6'
__author__ = 'Fetch.AI Limited'
__license__ = 'Apache 2.0'
__copyright__ = '2019 Fetch.AI Limited'
24 changes: 20 additions & 4 deletions aea/aea.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
from typing import Optional, cast

from aea.agent import Agent
from aea.context.base import AgentContext
from aea.decision_maker.base import DecisionMaker
from aea.mail.base import Envelope, MailBox
from aea.registries.base import Resources
from aea.skills.base import AgentContext
from aea.skills.error.handler import ErrorHandler
from aea.skills.error.handlers import ErrorHandler

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,9 +62,21 @@ def __init__(self, name: str,
self._directory = directory if directory else str(Path(".").absolute())

self.mailbox = mailbox
self._context = AgentContext(self.name, self.crypto.public_key, self.outbox)
self._decision_maker = DecisionMaker(self.max_reactions, self.outbox)
self._context = AgentContext(self.name,
self.crypto.public_key,
self.outbox,
self.decision_maker.message_queue,
self.decision_maker.ownership_state,
self.decision_maker.preferences,
self.decision_maker.is_ready_to_pursuit_goals)
self._resources = None # type: Optional[Resources]

@property
def decision_maker(self) -> DecisionMaker:
"""Get decision maker."""
return self._decision_maker

@property
def context(self) -> AgentContext:
"""Get context."""
Expand All @@ -82,6 +95,8 @@ def setup(self) -> None:
:return: None
"""
self._resources = Resources.from_resource_dir(self._directory, self.context)
assert self._resources is not None, "No resources initialized. Error in setup."
self._resources.setup()

def act(self) -> None:
"""
Expand Down Expand Up @@ -115,8 +130,8 @@ def handle(self, envelope: Envelope) -> None:
protocol = self.resources.protocol_registry.fetch(envelope.protocol_id)

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)
assert error_handler is not None, "ErrorHandler not initialized"

if protocol is None:
error_handler.send_unsupported_protocol(envelope)
Expand Down Expand Up @@ -149,6 +164,7 @@ def update(self) -> None:
"""
for task in self.resources.task_registry.fetch_all():
task.execute()
self.decision_maker.execute()

def teardown(self) -> None:
"""
Expand Down
11 changes: 10 additions & 1 deletion aea/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import aea
from aea.cli.add import connection, add, skill
from aea.cli.common import Context, pass_ctx, logger
from aea.cli.common import Context, pass_ctx, logger, _try_to_load_agent_config
from aea.cli.remove import remove
from aea.cli.run import run
from aea.cli.scaffold import scaffold
Expand Down Expand Up @@ -110,6 +110,15 @@ def delete(ctx: Context, agent_name):
exit(-1)


@cli.command()
@pass_ctx
def freeze(ctx: Context):
"""Get the dependencies."""
_try_to_load_agent_config(ctx)
for d in ctx.get_dependencies():
print(d)


cli.add_command(add)
cli.add_command(scaffold)
cli.add_command(remove)
Expand Down
25 changes: 13 additions & 12 deletions aea/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ def protocol(click_context, protocol_name):
logger.error("Cannot find protocol: '{}'.".format(protocol_name))
exit(-1)

# # try to load the connection configuration file
# try:
# connection_configuration = ctx.connection_loader.load(open(str(connection_configuration_filepath)))
# logger.info("Connection supports the following protocols: {}".format(connection_configuration.supported_protocols))
# except ValidationError as e:
# logger.error("Connection configuration file not valid: {}".format(str(e)))
# exit(-1)
# return
# try to load the protocol configuration file
try:
protocol_configuration = ctx.protocol_loader.load(open(str(protocol_configuration_filepath)))
logger.info("Protocol available: {}".format(protocol_configuration.name))
except ValidationError as e:
logger.error("Protocol configuration file not valid: {}".format(str(e)))
exit(-1)
return

# copy the connection package into the agent's supported connections.
# copy the protocol package into the agent's supported connections.
src = str(Path(os.path.join(registry_path, "protocols", protocol_name)).absolute())
dest = os.path.join(ctx.cwd, "protocols", protocol_name)
logger.info("Copying protocol modules. src={} dst={}".format(src, dest))
Expand Down Expand Up @@ -202,9 +202,10 @@ def skill(click_context, skill_name):
Path(skills_init_module).touch(exist_ok=True)

# check for not supported protocol, and add it.
if skill_configuration.protocol not in ctx.agent_config.protocols:
logger.info("Adding protocol '{}' to the agent...".format(skill_configuration.protocol))
click_context.invoke(protocol, protocol_name=skill_configuration.protocol)
for protocol_name in skill_configuration.protocols:
if protocol_name not in ctx.agent_config.protocols:
logger.info("Adding protocol '{}' to the agent...".format(protocol_name))
click_context.invoke(protocol, protocol_name=protocol_name)

# add the skill to the configurations.
logger.debug("Registering the skill into {}".format(DEFAULT_AEA_CONFIG_FILE))
Expand Down
Loading

0 comments on commit e26b0ae

Please sign in to comment.