Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Update PyGrid tutorials (#528)
Browse files Browse the repository at this point in the history
* remove heroku tutorials

* update intro to pygrid

* update intro tutorials

* rename tutorials

* delete android examples

* fix black issues

* DELETE outdated tutorials

Co-authored-by: Ionésio Junior <ionesiojr@gmail.com>
  • Loading branch information
monuelo and IonesioJunior committed Mar 31, 2020
1 parent cc3f8f7 commit 8fbfbdf
Show file tree
Hide file tree
Showing 43 changed files with 25 additions and 9,126 deletions.
Expand Up @@ -4,14 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# What is Grid?"
"# What is PyGrid?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"OpenGrid (also known as Grid) is a collaborative network platform for data owners and data scientists who can collectively train and share AI models using the PySyft library, which extends deep learning librairies such as PyTorch.\n"
"PyGrid (also known as Grid) is a collaborative network platform for data owners and data scientists who can collectively train and share AI models using the PySyft library, which extends deep learning libraries such as PyTorch and Tensorflow.\n"
]
},
{
Expand All @@ -30,7 +30,7 @@
"source": [
"### Introduction\n",
"\n",
"Grid platform aims to be a secure peer to peer platform used to train, manage and share models. A Grid is a collection of workers that can exchange messages and tensors in a transparent way.\n",
"PyGrid platform aims to be a secure peer to peer platform used to train, manage and share models. A Grid is a collection of workers that can exchange messages and tensors in a transparent way.\n",
"\n",
"\n",
"Grid currently supports:\n",
Expand All @@ -45,7 +45,7 @@
"* Federated Learning processes with no need to manage distributed workers directly.\n",
"\n",
"\n",
"[Try our tutorials to learn how to use Grid!](https://github.com/OpenMined/PyGrid/tree/dev/examples)\n"
"[Try our tutorials to learn how to use Grid!](https://github.com/OpenMined/PySyft/tree/master/examples/tutorials/grid)\n"
]
},
{
Expand Down Expand Up @@ -82,22 +82,17 @@
"source": [
"### Implementation\n",
"\n",
"The Grid repository consists mainly of 3 folders:\n",
"\n",
"#### grid\n",
"\n",
"`grid` is a python framework that extends PySyft with new workers that are capable of performing remote communication via a Rest API or via websockets. Grid also adds support for deploying these new clients on different plataforms (such as Heroku).\n",
"\n",
"The PyGrid repository consists mainly of 2 folders:\n",
"\n",
"#### app\n",
"\n",
"`apps` are basically regular Flask servers with a postgresql database. We add to these servers the ability to talk to Grid Workers, store tensors and models on the database to ensure fault tolerance.\n",
"`apps` are basically regular Flask servers with a REDIS database. We add to these servers the ability to talk to Grid Workers, store tensors and models on the database to ensure fault tolerance.\n",
"\n",
"The idea is that Grid Workers are a way to communicate with an app.\n",
"\n",
"#### grid_gateway\n",
"#### gateway\n",
"\n",
"`grid_gateway` works like a special DNS component but it will route nodes by queries instead of domain names.\n",
"`gateway` works like a special DNS component but it will route nodes by queries instead of domain names.\n",
" The Grid Gateway needs to know the addresses and ids of all grid nodes connected on the Grid Network (workers that are all connected to each other).\n",
"\n",
"A user can talk to a Grid Gateway and seemingless perform operations on multiple remote nodes without even knowing that they exist on the network.\n"
Expand Down
Expand Up @@ -32,16 +32,6 @@
"pip install -r requirements.txt\n",
"```\n",
"\n",
"### Step 3: Make grid importable\n",
"\n",
"Install grid as a python package\n",
"\n",
"```bash\n",
"cd PyGrid\n",
"python setup.py install (or python setup.py develop)\n",
"```\n",
"\n",
"\n",
"### Step 3: Start App\n",
"\n",
"Then, to start the app, just run the `websocket_app` script.\n",
Expand Down Expand Up @@ -86,7 +76,7 @@
"# General dependencies\n",
"import torch as th\n",
"import syft as sy\n",
"import grid as gr\n",
"from syft.workers.node_client import NodeClient\n",
"\n",
"hook = sy.TorchHook(th)"
]
Expand All @@ -98,7 +88,7 @@
"outputs": [],
"source": [
"# WARNING: We should use the same id and port as the one used to start the app!!!\n",
"worker = gr.WebsocketGridClient(hook, id=\"bob\", address=\"http://localhost:3000\")\n",
"worker = NodeClient(hook, \"ws://localhost:3000\")\n",
"\n",
"# If you don't connect to the worker you can't send messages to it\n",
"worker.connect()"
Expand Down Expand Up @@ -192,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
406 changes: 0 additions & 406 deletions examples/Part 2 - Launch a Grid Node on Heroku.ipynb

This file was deleted.

Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Part 3: Launch a Grid Network Locally\n",
"# Part 2: Launch a Grid Network Locally\n",
"\n",
"In this tutorial, you'll learn how to deploy a grid network into a local machine and then interact with it using PySyft.\n",
"\n",
Expand Down Expand Up @@ -34,16 +34,8 @@
"pip install -r requirements.txt\n",
"```\n",
"\n",
"### Step 3: Make grid importable\n",
"\n",
"Install grid as a python package\n",
"\n",
"```bash\n",
"cd PyGrid\n",
"python setup.py install (or python setup.py develop)\n",
"```\n",
"\n",
"### Step 4: Start gateway app\n",
"### Step 3: Start gateway app\n",
"\n",
"Then to start the app just run the `gateway.py` script. The `--start_local_db` automatically starts a local database so you don't have to configure one yourself.\n",
"\n",
Expand All @@ -69,7 +61,7 @@
"\n",
"## Starting the Grid Worker App\n",
"\n",
"### Step 5: Starting the Grid Worker app\n",
"### Step 4: Starting the Grid Worker app\n",
"\n",
"This is the same procedure already described at Part 1. But we add a new argument when starting the app called `--gateway_url` this should equal to the address used by the grid network here it's \"http://localhost:5000\"\n",
"\n",
Expand All @@ -91,7 +83,7 @@
"Great, so if your app started successfully the script should still be running.\n",
"\n",
"\n",
"### Step 6: Start communication with the Grid Gateway and workers\n",
"### Step 5: Start communication with the Grid Gateway and workers\n",
"\n",
"Let's start communication with the Gateway and the workers."
]
Expand All @@ -105,7 +97,7 @@
"# General dependencies\n",
"import torch as th\n",
"import syft as sy\n",
"import grid as gr\n",
"from syft.grid.public_grid import PublicGridNetwork\n",
"\n",
"hook = sy.TorchHook(th)"
]
Expand All @@ -116,7 +108,10 @@
"metadata": {},
"outputs": [],
"source": [
"gateway = gr.GridNetwork(\"http://localhost:5000\")"
"GRID_ADDRESS = 'localhost'\n",
"GRID_PORT = '5000'\n",
"\n",
"gateway = PublicGridNetwork(hook,\"http://\" + GRID_ADDRESS + \":\" + GRID_PORT)"
]
},
{
Expand All @@ -126,12 +121,12 @@
"outputs": [],
"source": [
"# WARNING: We should use the same id and port as the one used to start the app!!!\n",
"bob = gr.WebsocketGridClient(hook, id=\"bob\", address=\"http://localhost:3000\")\n",
"bob = NodeClient(hook, \"ws://localhost:3000\")\n",
"# If you don't connect to the worker you can't send messages to it\n",
"bob.connect()\n",
"\n",
"# WARNING: We should use the same id and port as the one used to start the app!!!\n",
"alice = gr.WebsocketGridClient(hook, id=\"alice\", address=\"http://localhost:3001\")\n",
"alice = NodeClient(hook, \"ws://localhost:3001\")\n",
"# If you don't connect to the worker you can't send messages to it\n",
"alice.connect()"
]
Expand All @@ -140,9 +135,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Step 7: Use PySyft Like Normal\n",
"### Step 6: Use PySyft Like Normal\n",
"\n",
"Now you can simply use the worker you created like you would any other normal PySyft worker. For more on how PySyft works, please see the PySyft tutorials: https://github.com/OpenMined/PySyft/tree/dev/examples/tutorials"
"Now you can simply use the worker you created like you would any other normal PySyft worker. For more on how PySyft works, please see the PySyft tutorials: https://github.com/OpenMined/PySyft/tree/master/examples/tutorials"
]
},
{
Expand Down Expand Up @@ -299,7 +294,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8fbfbdf

Please sign in to comment.