Skip to content

Commit 16fef4e

Browse files
committed
focus on hospital1 and researcher
1 parent 71803ad commit 16fef4e

File tree

11 files changed

+1696
-8
lines changed

11 files changed

+1696
-8
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM continuumio/miniconda3
2+
3+
ENV WORKSPACE /workspace
4+
5+
ARG jupyter_port
6+
ENV env_jupyter_port=jupyter_port
7+
8+
# Setup workspace environment
9+
RUN apt-get update && apt-get install -y gcc
10+
# RUN conda install jupyter notebook=5.7.8
11+
RUN conda install jupyter notebook=6.1.5
12+
13+
14+
ADD projects/aries-fl/requirements.txt .
15+
16+
#
17+
# .
18+
RUN pip install -r requirements.txt
19+
20+
#RUN pip install aiohttp
21+
#RUN export PYTHONPATH="$PYTHONPATH:/aries_basic_controller"
22+
#ENV PYTHONPATH "${PYTHONPATH}:/aries_basic_controller"
23+
#RUN export JUPYTER_PATH="$JUPYTER_PATH:/aries_basic_controller"
24+
# Create jupyter notebook workspace
25+
#RUN mkdir $WORKSPACE
26+
WORKDIR $WORKSPACE
27+
28+
# Make the image start the jupyer notebook
29+
COPY scripts/jupyter-entrypoint.sh /entrypoint.sh
30+
RUN chmod +x /entrypoint.sh
31+
32+
33+
34+
35+
36+
# ENTRYPOINT ["/entrypoint.sh", "$env_jupyter_port"]
37+
ENTRYPOINT ["/entrypoint.sh", "8888"]

projects/aries-fl/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ services:
123123
researcher-notebook:
124124
build:
125125
context: ../../
126-
dockerfile: dockerfiles/controllers/Dockerfile.basiccontroller
126+
dockerfile: projects/aries-fl/Dockerfile.ppmlcontroller
127127
args:
128128
- jupyter_port=${RESEARCHER_JUPYTER_PORT}
129129
depends_on:
@@ -168,7 +168,7 @@ services:
168168
hospital1-notebook:
169169
build:
170170
context: ../../
171-
dockerfile: dockerfiles/controllers/Dockerfile.basiccontroller
171+
dockerfile: projects/aries-fl/Dockerfile.ppmlcontroller
172172
args:
173173
- jupyter_port=${HOSPITAL1_JUPYTER_PORT}
174174
depends_on:
@@ -213,7 +213,7 @@ services:
213213
hospital2-notebook:
214214
build:
215215
context: ../../
216-
dockerfile: dockerfiles/controllers/Dockerfile.basiccontroller
216+
dockerfile: projects/aries-fl/Dockerfile.ppmlcontroller
217217
args:
218218
- jupyter_port=${HOSPITAL2_JUPYTER_PORT}
219219
depends_on:
@@ -258,7 +258,7 @@ services:
258258
hospital3-notebook:
259259
build:
260260
context: ../../
261-
dockerfile: dockerfiles/controllers/Dockerfile.basiccontroller
261+
dockerfile: projects/aries-fl/Dockerfile.ppmlcontroller
262262
args:
263263
- jupyter_port=${HOSPITAL3_JUPYTER_PORT}
264264
depends_on:

projects/aries-fl/manage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ EOF
6262
# -----------------------------------------------------------------------------------------------------------------
6363
# Default Settings:
6464
# -----------------------------------------------------------------------------------------------------------------
65-
DEFAULT_CONTAINERS="nhstrust-agent nhstrust-notebook regulator-agent regulator-notebook researcher-agent researcher-notebook hospital1-agent hospital1-notebook hospital2-agent hospital2-notebook hospital3-agent hospital3-notebook"
66-
65+
# DEFAULT_CONTAINERS="nhstrust-agent nhstrust-notebook regulator-agent regulator-notebook researcher-agent researcher-notebook hospital1-agent hospital1-notebook hospital2-agent hospital2-notebook hospital3-agent hospital3-notebook"
66+
DEFAULT_CONTAINERS="researcher-agent researcher-notebook hospital1-agent hospital1-notebook"
6767
# -----------------------------------------------------------------------------------------------------------------
6868
# Functions:
6969
# -----------------------------------------------------------------------------------------------------------------

projects/aries-fl/notebooks/Test/Test DP training.ipynb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
"cell_type": "code",
55
"execution_count": 1,
66
"metadata": {},
7-
"outputs": [],
7+
"outputs": [
8+
{
9+
"ename": "ModuleNotFoundError",
10+
"evalue": "No module named 'torch'",
11+
"output_type": "error",
12+
"traceback": [
13+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
14+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
15+
"\u001b[0;32m<ipython-input-1-ebded2444677>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mseaborn\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0msns\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtraceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
16+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'torch'"
17+
]
18+
}
19+
],
820
"source": [
921
"import numpy as np # linear algebra\n",
1022
"import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
@@ -372,7 +384,7 @@
372384
"name": "python",
373385
"nbconvert_exporter": "python",
374386
"pygments_lexer": "ipython3",
375-
"version": "3.6.12"
387+
"version": "3.8.5"
376388
}
377389
},
378390
"nbformat": 4,
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "undefined-customs",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"IPython autoawait is `on`, and set to use `asyncio`\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"%autoawait\n",
19+
"import time\n",
20+
"import asyncio\n",
21+
"from aries_basic_controller.aries_controller import AriesAgentController\n",
22+
" \n",
23+
"WEBHOOK_HOST = \"0.0.0.0\"\n",
24+
"WEBHOOK_PORT = 8052\n",
25+
"WEBHOOK_BASE = \"\"\n",
26+
"ADMIN_URL = \"http://hospital1-agent:8051\"\n",
27+
"\n",
28+
"agent_controller = AriesAgentController(webhook_host=WEBHOOK_HOST, webhook_port=WEBHOOK_PORT,\n",
29+
" webhook_base=WEBHOOK_BASE, admin_url=ADMIN_URL)"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 4,
35+
"id": "leading-madness",
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"\n",
40+
"loop = asyncio.get_event_loop()\n",
41+
"loop.create_task(agent_controller.listen_webhooks())\n",
42+
"\n",
43+
"def messages_handler(payload):\n",
44+
" connection_id = payload[\"connection_id\"]\n",
45+
" asyncio.get_event_loop().create_task(agent_controller.messaging.send_message(connection_id, \"This is a response from Bob\"))\n",
46+
" print(\"Handle message\", payload, connection_id)\n",
47+
"\n",
48+
"\n",
49+
"message_listener = {\n",
50+
" \"handler\": messages_handler,\n",
51+
" \"topic\": \"basicmessages\"\n",
52+
"}\n",
53+
"\n",
54+
"def connection_handler(payload):\n",
55+
" print(\"Connection Handler Called\")\n",
56+
" connection_id = payload[\"connection_id\"]\n",
57+
" state = payload[\"state\"]\n",
58+
" print(f\"Connection {connection_id} in State {state}\")\n",
59+
" \n",
60+
"connection_listener = {\n",
61+
" \"handler\": connection_handler,\n",
62+
" \"topic\": \"connections\"\n",
63+
"}\n",
64+
"\n",
65+
"agent_controller.register_listeners([connection_listener, message_listener], defaults=True)"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"id": "periodic-hepatitis",
71+
"metadata": {},
72+
"source": [
73+
"## Copy Invite from Researcher"
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": 5,
79+
"id": "right-guatemala",
80+
"metadata": {},
81+
"outputs": [],
82+
"source": [
83+
"#Paste in invitation from researcher agent\n",
84+
"invitation = {'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation', '@id': '31d22c96-b531-467a-8637-867f0e9199ac', 'label': 'Health Researcher', 'serviceEndpoint': 'http://172.17.0.1:8040', 'recipientKeys': ['Hu8va1kwBxycxKa731q6FeenAmhk5s3x2X3MXXR7CckE']}"
85+
]
86+
},
87+
{
88+
"cell_type": "code",
89+
"execution_count": 6,
90+
"id": "future-desert",
91+
"metadata": {},
92+
"outputs": [
93+
{
94+
"name": "stdout",
95+
"output_type": "stream",
96+
"text": [
97+
"Connection Handler Called\n",
98+
"Connection ec35bfc5-68ef-45c4-87c6-5d9f63819c77 in State invitation\n",
99+
"Connection Handler Called\n",
100+
"Connection ec35bfc5-68ef-45c4-87c6-5d9f63819c77 in State request\n",
101+
"Connection {'invitation_key': 'Hu8va1kwBxycxKa731q6FeenAmhk5s3x2X3MXXR7CckE', 'state': 'request', 'connection_id': 'ec35bfc5-68ef-45c4-87c6-5d9f63819c77', 'routing_state': 'none', 'updated_at': '2021-01-23 14:22:15.871577Z', 'initiator': 'external', 'invitation_mode': 'once', 'created_at': '2021-01-23 14:22:15.851490Z', 'accept': 'manual', 'their_label': 'Health Researcher', 'my_did': 'ALrPXCqEuqa5wYFUDDkfeo', 'request_id': 'b9560178-dc00-4496-9a8c-2da146166b4d'}\n",
102+
"Connection Handler Called\n",
103+
"Connection ec35bfc5-68ef-45c4-87c6-5d9f63819c77 in State response\n",
104+
"Connection Handler Called\n",
105+
"Connection ec35bfc5-68ef-45c4-87c6-5d9f63819c77 in State active\n"
106+
]
107+
}
108+
],
109+
"source": [
110+
"# Receive Invitation\n",
111+
"response = await agent_controller.connections.accept_connection(invitation)\n",
112+
"# Print out accepted Invite and Alice's connection ID\n",
113+
"print(\"Connection\", response)\n",
114+
"alice_id = response[\"connection_id\"]\n"
115+
]
116+
},
117+
{
118+
"cell_type": "code",
119+
"execution_count": null,
120+
"id": "narrow-signature",
121+
"metadata": {},
122+
"outputs": [],
123+
"source": [
124+
"# Print connection list\n",
125+
"connection = await agent_controller.connections.get_connection(alice_id)\n",
126+
"print(\"Alice AGENT CONNECTION\")\n",
127+
"print(connection)\n",
128+
"print(\"State:\", connection[\"state\"])"
129+
]
130+
},
131+
{
132+
"cell_type": "code",
133+
"execution_count": null,
134+
"id": "bearing-tuition",
135+
"metadata": {},
136+
"outputs": [],
137+
"source": []
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": null,
142+
"id": "encouraging-guard",
143+
"metadata": {},
144+
"outputs": [],
145+
"source": [
146+
"response = await agent_controller.terminate()\n",
147+
"print(response)"
148+
]
149+
}
150+
],
151+
"metadata": {
152+
"kernelspec": {
153+
"display_name": "Python 3",
154+
"language": "python",
155+
"name": "python3"
156+
},
157+
"language_info": {
158+
"codemirror_mode": {
159+
"name": "ipython",
160+
"version": 3
161+
},
162+
"file_extension": ".py",
163+
"mimetype": "text/x-python",
164+
"name": "python",
165+
"nbconvert_exporter": "python",
166+
"pygments_lexer": "ipython3",
167+
"version": "3.7.6"
168+
}
169+
},
170+
"nbformat": 4,
171+
"nbformat_minor": 5
172+
}

0 commit comments

Comments
 (0)