Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port HTTP server as valory package #682

Merged
merged 16 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/aev-echo-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ aea_version: '>=1.3.0, <2.0.0'
fingerprint: {}
fingerprint_ignore_patterns: []
connections:
- fetchai/http_server:0.22.0
- valory/http_server:0.22.0
contracts: []
protocols:
- fetchai/default:1.0.0
Expand All @@ -45,15 +45,15 @@ dependencies:
open-aea-ledger-ethereum: {}
default_connection: null
---
public_id: fetchai/http_server:0.22.0
public_id: valory/http_server:0.22.0
type: connection
config:
host: ${HOST:str:localhost}
port: ${PORT:int:5000}
target_skill_id: ${TARGET_SKILL:str:fetchai/http_echo:0.20.0}
```

Notice how the ```fetchai/http_server:0.22.0``` has a number of override parameters specified:
Notice how the ```valory/http_server:0.22.0``` has a number of override parameters specified:
``` yaml
host: ${HOST:str:localhost}
port: ${PORT:int:5000}
Expand Down
2 changes: 1 addition & 1 deletion docs/connect-a-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This page lays out two options for connecting a front-end to an AEA. The followi
<img src="../assets/http-integration.svg" alt="How to connect front-end to your AEA" class="center" style="display: block; margin-left: auto; margin-right: auto;width:80%;">

## Case 1
The first option is to create a `HTTP Server` connection that handles incoming requests from a REST API. In this scenario, the REST API communicates with the AEA and requests are handled by the `HTTP Server` connection package. The REST API should send CRUD requests to the `HTTP Server` connection (`fetchai/http_server:0.22.0`) which translates these into Envelopes to be consumed by the correct skill.
The first option is to create a `HTTP Server` connection that handles incoming requests from a REST API. In this scenario, the REST API communicates with the AEA and requests are handled by the `HTTP Server` connection package. The REST API should send CRUD requests to the `HTTP Server` connection (`valory/http_server:0.22.0`) which translates these into Envelopes to be consumed by the correct skill.

## Case 2
The second option is to create a front-end comprising a stand-alone `Multiplexer` with a `P2P` connection (`fetchai/p2p_libp2p:0.25.0`). In this scenario the <a href="../acn">Agent Communication Network</a> can be used to send Envelopes from the AEA to the front-end.
2 changes: 1 addition & 1 deletion docs/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The developer needs to implement four public coroutines:

- The `receive` coroutine is continuously called by the AEA framework. It either returns `None` or an envelope. The `receive` coroutine must implement the logic of data being received by the agent, and if necessary, its translation into a relevant protocol.

The framework provides a demo `stub` connection which implements an I/O reader and writer to send and receive messages between the agent and a local file. To gain inspiration and become familiar with the structure of connection packages, you may find it useful to check out `fetchai/stub:0.21.0`, `fetchai/http_server:0.22.0` or `valory/http_client:0.23.0` connections. The latter two connections are for external clients to connect with an agent, and for the agent to connect with external servers, respectively.
The framework provides a demo `stub` connection which implements an I/O reader and writer to send and receive messages between the agent and a local file. To gain inspiration and become familiar with the structure of connection packages, you may find it useful to check out `fetchai/stub:0.21.0`, `valory/http_server:0.22.0` or `valory/http_client:0.23.0` connections. The latter two connections are for external clients to connect with an agent, and for the agent to connect with external servers, respectively.

### Primary methods to develop - sync connection interface

Expand Down
6 changes: 3 additions & 3 deletions docs/http-connection-and-skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Add the http server connection package:
mkdir packages
aea create my_aea
cd my_aea
aea add connection fetchai/http_server:0.22.0:bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u --remote
aea push connection fetchai/http_server --local
aea add connection valory/http_server:0.22.0:bafybeihtkwnmohvusfjjhahb7gxbyh6yo22cumaghfe4mbunscusbcbiym --remote
aea push connection valory/http_server --local
aea add protocol fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm --remote
aea push protocol fetchai/default --local
aea add protocol valory/http:1.0.0:bafybeiejoqgv7finfxo3rcvvovrlj5ccrbgxodjq43uo26ylpowsa3llfe --remote
Expand All @@ -42,7 +42,7 @@ aea delete my_aea
Update the default connection:

``` bash
aea config set agent.default_connection fetchai/http_server:0.22.0
aea config set agent.default_connection valory/http_server:0.22.0
```

Modify the `api_spec_path`:
Expand Down
6 changes: 3 additions & 3 deletions docs/http-echo-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The easiest way to get started with the http server is to use our pre-built exam

``` bash
pipenv shell
aea fetch open_aea/http_echo:0.1.0:bafybeie6dxx5zbu6bz7at7kqj3thjvvzucj45f3tksbio5dg23ywsbb2ty --remote
aea fetch open_aea/http_echo:0.1.0:bafybeiabnmq7c7nu5lon7jvhrmdan72fn47tntzgy5b2lalrxhmochazi4 --remote
cd http_echo
aea generate-key ethereum; aea add-key ethereum
aea install
Expand All @@ -27,8 +27,8 @@ Adding protocol 'valory/http:1.0.0'...
Successfully added protocol 'valory/http:1.0.0'.
Adding protocol 'fetchai/default:1.0.0'...
Successfully added protocol 'fetchai/default:1.0.0'.
Adding connection 'fetchai/http_server:0.22.0'...
Successfully added connection 'fetchai/http_server:0.22.0'.
Adding connection 'valory/http_server:0.22.0'...
Successfully added connection 'valory/http_server:0.22.0'.
Adding skill 'fetchai/http_echo:0.20.0'...
Successfully added skill 'fetchai/http_echo:0.20.0'.
Agent http_echo successfully fetched.
Expand Down
2 changes: 1 addition & 1 deletion docs/interaction-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usually, an interaction involves three types of framework packages: <a href="../

### Example 1: AEA <> web client

In the <a href="../http-connection-and-skill">http connection guide</a> we demonstrate how an AEA with an http server connection (e.g. `fetchai/http_server`) receives http payloads from web clients, translates them to messages conforming with the `fetchai/http` protocol and passes it to a skill (e.g. `fetchai/http_echo`) to process. The `fetchai/http` protocol in this case is used for communication between the connection and the skill.
In the <a href="../http-connection-and-skill">http connection guide</a> we demonstrate how an AEA with an http server connection (e.g. `valory/http_server`) receives http payloads from web clients, translates them to messages conforming with the `fetchai/http` protocol and passes it to a skill (e.g. `fetchai/http_echo`) to process. The `fetchai/http` protocol in this case is used for communication between the connection and the skill.

### Example 2 : AEA <> 3rd party server

Expand Down
2 changes: 1 addition & 1 deletion docs/package_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| protocol/valory/contract_api/1.0.0 | `bafybeiasywsvax45qmugus5kxogejj66c5taen27h4voriodz7rgushtqa` |
| protocol/valory/http/1.0.0 | `bafybeia5bxdua2i6chw6pg47bvoljzcpuqxzy4rdrorbdmcbnwmnfdobtu` |
| protocol/valory/ledger_api/1.0.0 | `bafybeigsvceac33asd6ecbqev34meyyjwu3rangenv6xp5rkxyz4krvcby` |
| connection/fetchai/http_server/0.22.0 | `bafybeihp5umafxzx45aad5pj7s3343se2wjkgnbirt4pybrape22swm6de` |
| connection/valory/http_server/0.22.0 | `bafybeihp5umafxzx45aad5pj7s3343se2wjkgnbirt4pybrape22swm6de` |
| connection/fetchai/stub/0.21.0 | `bafybeihijtaawc2adyewb3g7kta7hw6jyhyhoi7cotkzgqilves5zz7smm` |
| connection/valory/ledger/0.19.0 | `bafybeiejc7g7ebv3cleiqb4f4h4pspcu6vtr54332szwlqiabfs3sfdh44` |
| connection/valory/p2p_libp2p/0.1.0 | `bafybeigfvt35r5blb3pp43iads6a56jolquvib5unbndkue7cgysazuxuu` |
Expand Down
4 changes: 2 additions & 2 deletions packages/open_aea/agents/http_echo/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fingerprint:
README.md: bafybeibkr6ecv5efx3hwxvxposvpmr76ugrj6kydeasb7bppo3ibynnjcu
fingerprint_ignore_patterns: []
connections:
- fetchai/http_server:0.22.0:bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u
- valory/http_server:0.22.0:bafybeihtkwnmohvusfjjhahb7gxbyh6yo22cumaghfe4mbunscusbcbiym
contracts: []
protocols:
- fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm
Expand All @@ -29,7 +29,7 @@ dependencies:
open-aea-ledger-ethereum: {}
default_connection: null
---
public_id: fetchai/http_server:0.22.0
public_id: valory/http_server:0.22.0
type: connection
config:
host: ${HOST:str:localhost}
Expand Down
4 changes: 2 additions & 2 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"protocol/valory/contract_api/1.0.0": "bafybeialhbjvwiwcnqq3ysxcyemobcbie7xza66gaofcvla5njezkvhcka",
"protocol/valory/http/1.0.0": "bafybeiejoqgv7finfxo3rcvvovrlj5ccrbgxodjq43uo26ylpowsa3llfe",
"protocol/valory/ledger_api/1.0.0": "bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru",
"connection/fetchai/http_server/0.22.0": "bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u",
"connection/fetchai/stub/0.21.0": "bafybeictgpdqbpyppmoxn2g7jkaxvulihew7zaszv4xyhgvsntq7tqs7wi",
"connection/valory/http_server/0.22.0": "bafybeihtkwnmohvusfjjhahb7gxbyh6yo22cumaghfe4mbunscusbcbiym",
"connection/valory/ledger/0.19.0": "bafybeiauyqzizmocjldnfuzvnihrqubfqzn5u2hp6ue7v3ka5kj54kd3zm",
"connection/valory/p2p_libp2p/0.1.0": "bafybeiaykya7tvir7k5scovjzuagpfcftvptxoi2od5qqqvukwglsrrtzy",
"connection/valory/p2p_libp2p_client/0.1.0": "bafybeihge56dn3xep2dzomu7rtvbgo4uc2qqh7ljl3fubqdi2lq44gs5lq",
Expand All @@ -26,7 +26,7 @@
"agent/fetchai/gym_aea/0.25.0": "bafybeif5c657r3ixuosbyihtsdzr2tqifikxgy5e6t7ur2jmhtiolina3m",
"agent/fetchai/my_first_aea/0.27.0": "bafybeicrgya4gln4lqr3ba76t2cuyik37lcgr64kzna2fkoseseobytaa4",
"agent/open_aea/gym_aea/0.1.0": "bafybeibyyl4wtnrfxeoed3kjnlftphkcikdqrgf76u34v4wbvwgsqfqrgy",
"agent/open_aea/http_echo/0.1.0": "bafybeie6dxx5zbu6bz7at7kqj3thjvvzucj45f3tksbio5dg23ywsbb2ty",
"agent/open_aea/http_echo/0.1.0": "bafybeiabnmq7c7nu5lon7jvhrmdan72fn47tntzgy5b2lalrxhmochazi4",
"agent/open_aea/my_first_aea/0.1.0": "bafybeibv7nlyxldyj5ntivsu74ylul4dltpfvkfa46k2pbveetfpkvz4jm",
"connection/fetchai/local/0.20.0": "bafybeigukufpgy2sdkv5qqde47dhigbjitxcrxwg6sl6unlpbc7wbxqyhm",
"connection/valory/http_client/0.23.0": "bafybeifgeqgryx6b3s6eseyzyezygmeitcpt3tkor2eiycozoi6clgdrny",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This connection wraps an HTTP server. It consumes requests from clients, transla

## Usage

First, add the connection to your AEA project (`aea add connection fetchai/http_server:0.22.0`). Then, update the `config` in `connection.yaml` by providing a `host` and `port` of the server. Optionally, provide a path to an [OpenAPI specification](https://swagger.io/docs/specification/about/) for request validation.
First, add the connection to your AEA project (`aea add connection valory/http_server:0.22.0`). Then, update the `config` in `connection.yaml` by providing a `host` and `port` of the server. Optionally, provide a path to an [OpenAPI specification](https://swagger.io/docs/specification/about/) for request validation.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022-2023 Valory AG
# Copyright 2018-2020 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
_default_logger = logging.getLogger("aea.packages.fetchai.connections.http_server")

RequestId = DialogueLabel
PUBLIC_ID = PublicId.from_str("fetchai/http_server:0.22.0")
PUBLIC_ID = PublicId.from_str("valory/http_server:0.22.0")


class HttpDialogues(BaseHttpDialogues):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: http_server
author: fetchai
author: valory
version: 0.22.0
type: connection
description: The HTTP server connection that wraps http server implementing a RESTful
API specification.
license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
README.md: bafybeihkuhhsdfw5qqtz2jwpfppub6yvsehzmvmaqjlxnal4v76x47mcrq
__init__.py: bafybeif5pkr5oarwd7yagdgn46miolmdmvgdyxv4kadgws2bf3iwshom24
connection.py: bafybeicrzlp4krqcf6gunbhhu2j47qp4f7adviw3qxoabt56yy5d3ksaci
tests/__init__.py: bafybeidpthyhnhsvpixejrud77klcfkb3titlmyrssovfzt4a76dn3wnpm
README.md: bafybeifepluovb4so2eem34ulpcp4svegb2dqfpmtojtofhfkb3j2xanui
__init__.py: bafybeifykou5sazojmc7hdqnsdp4mncd4zh3xys3mdgdzwks23mvhzu2ga
connection.py: bafybeidc6zysa47tppkvq3ddq4jgpind7h6zzpsl4s7vukbbj5y4ts2zxm
tests/__init__.py: bafybeifqaf7cnc4oczjkbwmv4ahrkbiqxrojwgowej3kbri3skz4lzt43i
tests/data/certs/server.crt: bafybeiev5i3xxkvn36wflf633gkumuxexsw4y2bubwbvl7edrz4igfgv34
tests/data/certs/server.csr: bafybeicvp7xdl5w3o4bzikkudpduitss3bpp6xqfwlxbw6kabdangohy5u
tests/data/certs/server.key: bafybeiabvpkpqr4fctrbssfal6pviv5otgmu32qyrfpyhcql5wgmlzjtoe
tests/data/petstore_sim.yaml: bafybeiaekkfxljlv57uviz4ug6isdqbzsnuxpsgy3dvhzh22daql3xh2i4
tests/test_http_server.py: bafybeihxrl4eqgbroqfcrnued3twwx24cfzfpuxrqkkgvirqtqhadbmxzm
tests/test_http_server.py: bafybeicixzlwx5aodces44mtkpkhxaombb5xqrsmwi4s7ksjgbolmjildq
fingerprint_ignore_patterns: []
connections: []
protocols:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2023 Valory AG
# Copyright 2018-2020 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
# Copyright 2022-2023 Valory AG
# Copyright 2018-2021 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aea_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_when_package_has_missing_dependency():
f"Missing dependencies: ['(protocol, {str(HttpMessage.protocol_id)})']"
)
with pytest.raises(AEAException, match=expected_message):
# connection "fetchai/http_server" requires
# connection "valory/http_server" requires
# "fetchai/http" protocols.
builder.add_component(
ComponentType.CONNECTION,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli/test_remove/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2021-2022 Valory AG
# Copyright 2021-2023 Valory AG
# Copyright 2018-2019 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -152,7 +152,7 @@ def load_config(self) -> AgentConfig:
# self.run_cli_command( # noqa: E800
# "add", "--local", self.ITEM_TYPE, str(self.ITEM_PUBLIC_ID) # noqa: E800
# ) # noqa: E800
# self.run_cli_command("add", "--local", "connection", "fetchai/http_server") # noqa: E800
# self.run_cli_command("add", "--local", "connection", "valory/http_server") # noqa: E800

# self.runner.invoke( # noqa: E800
# cli, # noqa: E800
Expand Down
4 changes: 2 additions & 2 deletions tests/test_docs/test_bash_yaml/md_files/bash-aev-echo-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aea_version: '>=1.3.0, <2.0.0'
fingerprint: {}
fingerprint_ignore_patterns: []
connections:
- fetchai/http_server:0.22.0
- valory/http_server:0.22.0
contracts: []
protocols:
- fetchai/default:1.0.0
Expand All @@ -30,7 +30,7 @@ dependencies:
open-aea-ledger-ethereum: {}
default_connection: null
---
public_id: fetchai/http_server:0.22.0
public_id: valory/http_server:0.22.0
type: connection
config:
host: ${HOST:str:localhost}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ aea create my_aea
cd my_aea
```
``` bash
aea add connection fetchai/http_server:0.22.0:bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u --remote
aea add connection valory/http_server:0.22.0:bafybeihtkwnmohvusfjjhahb7gxbyh6yo22cumaghfe4mbunscusbcbiym --remote
```
``` bash
aea config set agent.default_connection fetchai/http_server:0.22.0
aea config set agent.default_connection valory/http_server:0.22.0
```
``` bash
aea config set vendor.fetchai.connections.http_server.config.api_spec_path "../examples/http_ex/petstore.yaml"
Expand Down Expand Up @@ -48,8 +48,8 @@ models:
mkdir packages
aea create my_aea
cd my_aea
aea add connection fetchai/http_server:0.22.0:bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u --remote
aea push connection fetchai/http_server --local
aea add connection valory/http_server:0.22.0:bafybeihtkwnmohvusfjjhahb7gxbyh6yo22cumaghfe4mbunscusbcbiym --remote
aea push connection valory/http_server --local
aea add protocol fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm --remote
aea push protocol fetchai/default --local
aea add protocol valory/http:1.0.0:bafybeiejoqgv7finfxo3rcvvovrlj5ccrbgxodjq43uo26ylpowsa3llfe --remote
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
``` bash
pipenv shell
aea fetch open_aea/http_echo:0.1.0:bafybeie6dxx5zbu6bz7at7kqj3thjvvzucj45f3tksbio5dg23ywsbb2ty --remote
aea fetch open_aea/http_echo:0.1.0:bafybeiabnmq7c7nu5lon7jvhrmdan72fn47tntzgy5b2lalrxhmochazi4 --remote
cd http_echo
aea generate-key ethereum; aea add-key ethereum
aea install
Expand All @@ -11,8 +11,8 @@ Adding protocol 'valory/http:1.0.0'...
Successfully added protocol 'valory/http:1.0.0'.
Adding protocol 'fetchai/default:1.0.0'...
Successfully added protocol 'fetchai/default:1.0.0'.
Adding connection 'fetchai/http_server:0.22.0'...
Successfully added connection 'fetchai/http_server:0.22.0'.
Adding connection 'valory/http_server:0.22.0'...
Successfully added connection 'valory/http_server:0.22.0'.
Adding skill 'fetchai/http_echo:0.20.0'...
Successfully added skill 'fetchai/http_echo:0.20.0'.
Agent http_echo successfully fetched.
Expand Down
Loading