From 1114e29d3fa26410caffb18ef204192af0cac88b Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Wed, 26 Feb 2020 02:13:50 -0800 Subject: [PATCH 01/14] Tutorial Notebook 10 note on numpy hook (OpenMined#3022) --- ...ederated Learning with Secure Aggregation.ipynb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/translations/chinese/Part 10 - Federated Learning with Secure Aggregation.ipynb b/examples/tutorials/translations/chinese/Part 10 - Federated Learning with Secure Aggregation.ipynb index e22a9ea4916..346d417e88b 100644 --- a/examples/tutorials/translations/chinese/Part 10 - Federated Learning with Secure Aggregation.ipynb +++ b/examples/tutorials/translations/chinese/Part 10 - Federated Learning with Secure Aggregation.ipynb @@ -1,5 +1,16 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 由于还不支持numpy,目前notebook中的 \"Part B: Encrypted Aggregation\" 无法正常使用。\n", + "\n", + "如需查看状态,请访问 https://github.com/OpenMined/PySyft/issues/2771.\n", + "\n", + "只要B部分恢复正常,这段话就会被移除。" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -17,7 +28,8 @@ "- Andrew Trask - Twitter: [@iamtrask](https://twitter.com/iamtrask)\n", "\n", "中文版译者:\n", - "- Hou Wei - github:[@dljgs1](https://github.com/dljgs1)" + "- Hou Wei - github:[@dljgs1](https://github.com/dljgs1)\n", + "- Haofan Wang - github:[@haofanwang](https://github.com/haofanwang)\n" ] }, { From 6289f68d5e0258b022097d486b4bdfd47f744f73 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 11:16:46 -0800 Subject: [PATCH 02/14] Update Tutorial 1 - SplitNN Introduction.ipynb --- .../Tutorial 1 - SplitNN Introduction.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb index 9abd1e35353..21e499fcea2 100644 --- a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb +++ b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb @@ -23,7 +23,7 @@ "\n", "### What is a SplitNN?\n", "\n", - "The training of a neural network (NN) is 'split' accross one or more hosts. Each model segment is a self contained NN that feeds into the segment in front. In this example Alice has unlabeled training data and the bottom of the network whereas Bob has the corresponding labels and the top of the network. The image below shows this training process where Bob has all the labels and there are multiple alices with X data [[1](https://arxiv.org/abs/1810.06060)]. Once Alice$_1$ has trained she sends a copy of her trained bottom model to the next Alice. This continues until Alice$_n$ has trained.\n", + "The training of a neural network (NN) is 'split' accross one or more hosts. Each model segment is a self contained NN that feeds into the segment in front. In this example Alice has unlabeled training data and the bottom of the network whereas Bob has the corresponding labels and the top of the network. The image below shows this training process where Bob has all the labels and there are multiple alices with X data [[1](https://arxiv.org/abs/1810.06060)]. Once $Alice_1$ has trained she sends a copy of her trained bottom model to the next Alice. This continues until $Alice_n$ has trained.\n", "\n", "\"dominating_sets_example2\"\n", "\n", From b4d76215cf78d3a186ce841e5902a2fe5159af94 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 11:25:31 -0800 Subject: [PATCH 03/14] Update Tutorial 1 - SplitNN Introduction.ipynb --- .../Tutorial 1 - SplitNN Introduction.ipynb | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb index 21e499fcea2..e33a540fda6 100644 --- a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb +++ b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb @@ -31,7 +31,7 @@ "\n", "### Why use a SplitNN?\n", "\n", - "The SplitNN has been shown to provide a dramatic reduction to the computational burden of training while maintaining higher accuracies when training over large number of clients [[2](https://arxiv.org/abs/1812.00564)]. In the figure below, the Blue line denotes distributed deep learning using splitNN, red line indicate federated learning (FL) and green line indicates Large Batch Stochastic Gradient Descent (LBSGD).\n", + "The SplitNN has been shown to provide a dramatic reduction to the computational burden of training while maintaining higher accuracies when training over large number of clients [[2](https://arxiv.org/abs/1812.00564)]. In the figure below, the Blue line denotes distributed deep learning using SplitNN, red line indicate federated learning (FL) and green line indicates Large Batch Stochastic Gradient Descent (LBSGD).\n", "\n", "\n", "\n", @@ -48,20 +48,20 @@ "- The scalability of this approach, in terms of both network and computational resources, could make this an a valid alternative to FL and LBSGD, particularly on low power devices.\n", "- This could be an effective mechanism for both horizontal and vertical data distributions.\n", "- As computational cost is already quite low, the cost of applying homomorphic encryption is also minimised.\n", - "- Only activation signal gradients are sent/ recieved, meaning that malicious actors cannot use gradients of model parameters to reverse engineer the original values\n", + "- Only activation signal gradients are sent/ recieved, meaning that malicious actors cannot use gradients of model parameters to reverse engineer the original values.\n", "\n", "### Constraints\n", "\n", - "- A new technique with little surroundung literature, a large amount of comparison and evaluation is still to be performed\n", - "- This approach requires all hosts to remain online during the entire learning process (less fesible for hand-held devices)\n", - "- Not as established in privacy-preserving toolkits as FL and LBSGD\n", - "- Activation signals and their corresponding gradients still have the capacity to leak information, however this is yet to be fully addressed in the literature\n", + "- A new technique with little surroundung literature, a large amount of comparison and evaluation is still to be performed.\n", + "- This approach requires all hosts to remain online during the entire learning process (less fesible for hand-held devices).\n", + "- Not as established in privacy-preserving toolkits as FL and LBSGD.\n", + "- Activation signals and their corresponding gradients still have the capacity to leak information, however this is yet to be fully addressed in the literature.\n", "\n", "### Tutorial \n", "\n", - "This tutorial demonstrates a basic example of SplitNN which;\n", + "This tutorial demonstrates a basic example of SplitNN which\n", "\n", - "- Has two paticipants; Alice and Bob.\n", + "- Has two paticipants: Alice and Bob.\n", " - Bob has labels\n", " - Alice has X values\n", "- Has two model segments.\n", @@ -81,15 +81,10 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import torch\n", - "import torchvision\n", - "import matplotlib.pyplot as plt\n", - "from time import time\n", "from torchvision import datasets, transforms\n", "from torch import nn, optim\n", "import syft as sy\n", - "import time\n", "hook = sy.TorchHook(torch)" ] }, @@ -99,6 +94,7 @@ "metadata": {}, "outputs": [], "source": [ + "# Data preprocessing\n", "transform = transforms.Compose([transforms.ToTensor(),\n", " transforms.Normalize((0.5,), (0.5,)),\n", " ])\n", @@ -114,6 +110,7 @@ "source": [ "torch.manual_seed(0)\n", "\n", + "# Define our model segments\n", "\n", "input_size = 784\n", "hidden_sizes = [128, 640]\n", From bee63ad5522014f0210ca3ea46fc4c9084d8d924 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 11:26:54 -0800 Subject: [PATCH 04/14] Update Tutorial 1 - SplitNN Introduction.ipynb --- .../Tutorial 1 - SplitNN Introduction.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb index e33a540fda6..b15fc02c478 100644 --- a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb +++ b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb @@ -72,7 +72,8 @@ "\n", "Authors:\n", "- Adam J Hall - Twitter: [@AJH4LL](https://twitter.com/AJH4LL) · GitHub: [@H4LL](https://github.com/H4LL)\n", - "- Théo Ryffel - Twitter: [@theoryffel](https://twitter.com/theoryffel) · GitHub: [@LaRiffle](https://github.com/LaRiffle)" + "- Théo Ryffel - Twitter: [@theoryffel](https://twitter.com/theoryffel) · GitHub: [@LaRiffle](https://github.com/LaRiffle)\n", + "- Haofan Wang - github:[@haofanwang](https://github.com/haofanwang)" ] }, { From f545103e854a096e26badeeb084ff03826fc093a Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 11:30:51 -0800 Subject: [PATCH 05/14] Update Tutorial 2 - MultiLayer Split Neural Network.ipynb --- .../Tutorial 2 - MultiLayer Split Neural Network.ipynb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/advanced/Split Neural Network/Tutorial 2 - MultiLayer Split Neural Network.ipynb b/examples/tutorials/advanced/Split Neural Network/Tutorial 2 - MultiLayer Split Neural Network.ipynb index 7726f414983..3788de6302f 100644 --- a/examples/tutorials/advanced/Split Neural Network/Tutorial 2 - MultiLayer Split Neural Network.ipynb +++ b/examples/tutorials/advanced/Split Neural Network/Tutorial 2 - MultiLayer Split Neural Network.ipynb @@ -42,7 +42,8 @@ "We use the exact same model as we used in the previous tutorial, only this time we are splitting over 3 hosts, not two. However, we see the same loss being reported as there is no reduction in accuracy when training in this way. While we only use 3 models this can be done for any arbitrary number of models.\n", "\n", "Author:\n", - "- Adam J Hall - Twitter: [@AJH4LL](https://twitter.com/AJH4LL) · GitHub: [@H4LL](https://github.com/H4LL)\n" + "- Adam J Hall - Twitter: [@AJH4LL](https://twitter.com/AJH4LL) · GitHub: [@H4LL](https://github.com/H4LL)\n", + "- Haofan Wang - github:[@haofanwang](https://github.com/haofanwang)" ] }, { @@ -51,15 +52,10 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import torch\n", - "import torchvision\n", - "import matplotlib.pyplot as plt\n", - "from time import time\n", "from torchvision import datasets, transforms\n", "from torch import nn, optim\n", "import syft as sy\n", - "import time\n", "hook = sy.TorchHook(torch)" ] }, @@ -123,6 +119,7 @@ "metadata": {}, "outputs": [], "source": [ + "# Data preprocessing\n", "transform = transforms.Compose([transforms.ToTensor(),\n", " transforms.Normalize((0.5,), (0.5,)),\n", " ])\n", From d0cef826fb50e72ca5b3f50883cf8fb25df3f191 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 11:32:56 -0800 Subject: [PATCH 06/14] Update Tutorial 1 - SplitNN Introduction.ipynb --- .../Tutorial 1 - SplitNN Introduction.ipynb | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb index b15fc02c478..5ffade3a544 100644 --- a/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb +++ b/examples/tutorials/advanced/Split Neural Network/Tutorial 1 - SplitNN Introduction.ipynb @@ -161,37 +161,37 @@ "def train(x, target, models, optimizers):\n", " # Training Logic\n", "\n", - " # 1) erase previous gradients (if they exist)\n", + " #1) erase previous gradients (if they exist)\n", " for opt in optimizers:\n", " opt.zero_grad()\n", "\n", - " # 2) make a prediction\n", - " a = models[0](x)\n", + " #2) make a prediction\n", + " a = models[0](x)\n", "\n", - " # 3) break the computation graph link, and send the activation signal to the next model\n", + " #3) break the computation graph link, and send the activation signal to the next model\n", " remote_a = a.detach().move(models[1].location).requires_grad_()\n", "\n", - " # 4) make prediction on next model using recieved signal\n", + " #4) make prediction on next model using recieved signal\n", " pred = models[1](remote_a)\n", "\n", - " # 5) calculate how much we missed\n", + " #5) calculate how much we missed\n", " criterion = nn.NLLLoss()\n", " loss = criterion(pred, target)\n", "\n", - " # 6) figure out which weights caused us to miss\n", + " #6) figure out which weights caused us to miss\n", " loss.backward()\n", "\n", - " # 7) send gradient of the recieved activation signal to the model behind\n", + " #7) send gradient of the recieved activation signal to the model behind\n", " grad_a = remote_a.grad.copy().move(models[0].location)\n", "\n", - " # 8) backpropagate on bottom model given this gradient\n", + " #8) backpropagate on bottom model given this gradient\n", " a.backward(grad_a)\n", "\n", - " # 9) change the weights\n", + " #9) change the weights\n", " for opt in optimizers:\n", " opt.step()\n", "\n", - " # 10) print our progress\n", + " #10) print our progress\n", " return loss.detach().get()" ] }, From f53f7d5c0251ee8ac9c924bb8cc3a9f3eda34cb6 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 11:35:46 -0800 Subject: [PATCH 07/14] Update Tutorial 3 - Folded Split Neural Network.ipynb --- .../Tutorial 3 - Folded Split Neural Network.ipynb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/tutorials/advanced/Split Neural Network/Tutorial 3 - Folded Split Neural Network.ipynb b/examples/tutorials/advanced/Split Neural Network/Tutorial 3 - Folded Split Neural Network.ipynb index c8a40aaacaa..349ebb57bb2 100644 --- a/examples/tutorials/advanced/Split Neural Network/Tutorial 3 - Folded Split Neural Network.ipynb +++ b/examples/tutorials/advanced/Split Neural Network/Tutorial 3 - Folded Split Neural Network.ipynb @@ -22,7 +22,7 @@ "\n", "Recap: The previous tutorial looked at building a SplitNN. The NN was split into three segments on three seperate hosts, where one host had data and another had labels. However, what if someone has data and labels in the same place? \n", "\n", - "Description: Here we fold a multilayer SplitNN in on itself in order to accomodate the data nd labels being in the same place. We demonstrate the SplitNN class with a 3 segment distribution. This time;\n", + "Description: Here we fold a multilayer SplitNN in on itself in order to accomodate the data nd labels being in the same place. We demonstrate the SplitNN class with a 3 segment distribution. This time,\n", "\n", "\n", "\n", @@ -37,7 +37,8 @@ "Again, we use the exact same model as we used in the previous tutorial and see the same accuracy. Neither Alice nor Bob have the full model and Bob can't see Alice's data. \n", "\n", "Author:\n", - "- Adam J Hall - Twitter: [@AJH4LL](https://twitter.com/AJH4LL) · GitHub: [@H4LL](https://github.com/H4LL)\n" + "- Adam J Hall - Twitter: [@AJH4LL](https://twitter.com/AJH4LL) · GitHub: [@H4LL](https://github.com/H4LL)\n", + "- Haofan Wang - github:[@haofanwang](https://github.com/haofanwang)" ] }, { @@ -108,15 +109,10 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import torch\n", - "import torchvision\n", - "import matplotlib.pyplot as plt\n", - "from time import time\n", "from torchvision import datasets, transforms\n", "from torch import nn, optim\n", "import syft as sy\n", - "import time\n", "hook = sy.TorchHook(torch)" ] }, @@ -126,6 +122,7 @@ "metadata": {}, "outputs": [], "source": [ + "# Data preprocessing\n", "transform = transforms.Compose([transforms.ToTensor(),\n", " transforms.Normalize((0.5,), (0.5,)),\n", " ])\n", @@ -178,7 +175,7 @@ " model.send(location)\n", "\n", "#Instantiate a SpliNN class with our distributed segments and their respective optimizers\n", - "splitNN = SplitNN(models, optimizers)" + "splitNN = SplitNN(models, optimizers)" ] }, { From 351b36965623dcc4cac9f1cf953a6a68c66f70af Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 12:26:50 -0800 Subject: [PATCH 08/14] Update virtual.py --- syft/workers/virtual.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/syft/workers/virtual.py b/syft/workers/virtual.py index 153883beb8e..a15515c1ce8 100644 --- a/syft/workers/virtual.py +++ b/syft/workers/virtual.py @@ -6,12 +6,17 @@ class VirtualWorker(BaseWorker, FederatedClient): def _send_msg(self, message: bin, location: BaseWorker) -> bin: + """send message to worker location""" + if self.message_pending_time > 0: if self.verbose: print(f"pending time of {self.message_pending_time} seconds to send message...") + # pending sleep(self.message_pending_time) return location._recv_msg(message) def _recv_msg(self, message: bin) -> bin: + """receieve message""" + return self.recv_msg(message) From 75c92090678e3698a2d7570fe0b08526045b108d Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Fri, 28 Feb 2020 12:39:37 -0800 Subject: [PATCH 09/14] Update test_federated_client.py --- test/federated/test_federated_client.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/federated/test_federated_client.py b/test/federated/test_federated_client.py index c1296e8dc0f..4cadef49923 100644 --- a/test/federated/test_federated_client.py +++ b/test/federated/test_federated_client.py @@ -11,7 +11,7 @@ PRINT_IN_UNITTESTS = False # To make execution deterministic to some extent -# for more information - refer https://pytorch.org/docs/stable/notes/randomness.html +# For more information - refer https://pytorch.org/docs/stable/notes/randomness.html torch.manual_seed(0) torch.cuda.manual_seed_all(0) torch.backends.cudnn.benchmark = False @@ -19,22 +19,31 @@ def test_add_dataset(): + # Create a client to execute federated learning fed_client = FederatedClient() - + + # Create a dataset dataset = "my_dataset" + + # "string_dataset" is the key value fed_client.add_dataset(dataset, "string_dataset") assert "string_dataset" in fed_client.datasets def test_add_dataset_with_duplicate_key(): + # Create a client to execute federated learning fed_client = FederatedClient() - + + # Create a dataset dataset = "my_dataset" + + # "string_dataset" is the key value fed_client.add_dataset(dataset, "string_dataset") assert "string_dataset" in fed_client.datasets - + + # Raise error if the key is already exists with pytest.raises(ValueError): fed_client.add_dataset(dataset, "string_dataset") From d21e3e557ca999698ed3fc37f7440e5197eef386 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Sat, 29 Feb 2020 11:42:48 -0800 Subject: [PATCH 10/14] Update virtual.py --- syft/workers/virtual.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/syft/workers/virtual.py b/syft/workers/virtual.py index a15515c1ce8..3e2ba64b9bb 100644 --- a/syft/workers/virtual.py +++ b/syft/workers/virtual.py @@ -7,7 +7,6 @@ class VirtualWorker(BaseWorker, FederatedClient): def _send_msg(self, message: bin, location: BaseWorker) -> bin: """send message to worker location""" - if self.message_pending_time > 0: if self.verbose: print(f"pending time of {self.message_pending_time} seconds to send message...") @@ -18,5 +17,4 @@ def _send_msg(self, message: bin, location: BaseWorker) -> bin: def _recv_msg(self, message: bin) -> bin: """receieve message""" - return self.recv_msg(message) From 300253ef43bb1d567e367aac79b3f99df8eb21ad Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Sat, 29 Feb 2020 11:51:41 -0800 Subject: [PATCH 11/14] Update test_federated_client.py --- test/federated/test_federated_client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/federated/test_federated_client.py b/test/federated/test_federated_client.py index 4cadef49923..65e767cefb1 100644 --- a/test/federated/test_federated_client.py +++ b/test/federated/test_federated_client.py @@ -24,7 +24,6 @@ def test_add_dataset(): # Create a dataset dataset = "my_dataset" - # "string_dataset" is the key value fed_client.add_dataset(dataset, "string_dataset") @@ -37,7 +36,6 @@ def test_add_dataset_with_duplicate_key(): # Create a dataset dataset = "my_dataset" - # "string_dataset" is the key value fed_client.add_dataset(dataset, "string_dataset") From 4b8084e8d3f4b27115a187315d6f164841647829 Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Sat, 29 Feb 2020 12:02:50 -0800 Subject: [PATCH 12/14] Update test_federated_client.py --- test/federated/test_federated_client.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/federated/test_federated_client.py b/test/federated/test_federated_client.py index 65e767cefb1..3f98c941746 100644 --- a/test/federated/test_federated_client.py +++ b/test/federated/test_federated_client.py @@ -21,11 +21,11 @@ def test_add_dataset(): # Create a client to execute federated learning fed_client = FederatedClient() - # Create a dataset dataset = "my_dataset" - # "string_dataset" is the key value - fed_client.add_dataset(dataset, "string_dataset") + key = "string_dataset" + # add new dataset + fed_client.add_dataset(dataset, key) assert "string_dataset" in fed_client.datasets @@ -33,28 +33,29 @@ def test_add_dataset(): def test_add_dataset_with_duplicate_key(): # Create a client to execute federated learning fed_client = FederatedClient() - # Create a dataset dataset = "my_dataset" - # "string_dataset" is the key value - fed_client.add_dataset(dataset, "string_dataset") + key = "string_dataset" + # add new dataset + fed_client.add_dataset(dataset, key) assert "string_dataset" in fed_client.datasets - # Raise error if the key is already exists with pytest.raises(ValueError): fed_client.add_dataset(dataset, "string_dataset") def test_remove_dataset(): + # Create a client to execute federated learning fed_client = FederatedClient() - + # Create a dataset dataset = "my_dataset" key = "string_dataset" + # add new dataset fed_client.add_dataset(dataset, key) assert key in fed_client.datasets - + # remove new dataset fed_client.remove_dataset(key) assert key not in fed_client.datasets From acae37de9db4fa29fdbf155ba294007b7439cb8c Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Mon, 2 Mar 2020 00:21:37 -0800 Subject: [PATCH 13/14] Update test_federated_client.py --- test/federated/test_federated_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/federated/test_federated_client.py b/test/federated/test_federated_client.py index 3f98c941746..a334e8331df 100644 --- a/test/federated/test_federated_client.py +++ b/test/federated/test_federated_client.py @@ -24,7 +24,7 @@ def test_add_dataset(): # Create a dataset dataset = "my_dataset" key = "string_dataset" - # add new dataset + # Add new dataset fed_client.add_dataset(dataset, key) assert "string_dataset" in fed_client.datasets @@ -36,11 +36,11 @@ def test_add_dataset_with_duplicate_key(): # Create a dataset dataset = "my_dataset" key = "string_dataset" - # add new dataset + # Add new dataset fed_client.add_dataset(dataset, key) assert "string_dataset" in fed_client.datasets - # Raise error if the key is already exists + # Raise an error if the key is already exists with pytest.raises(ValueError): fed_client.add_dataset(dataset, "string_dataset") @@ -51,11 +51,11 @@ def test_remove_dataset(): # Create a dataset dataset = "my_dataset" key = "string_dataset" - # add new dataset + # Add new dataset fed_client.add_dataset(dataset, key) assert key in fed_client.datasets - # remove new dataset + # Remove new dataset fed_client.remove_dataset(key) assert key not in fed_client.datasets From 9941b9f09b98052e1c17ee93991de8b4d506fe6a Mon Sep 17 00:00:00 2001 From: Haofan Wang Date: Mon, 2 Mar 2020 00:22:13 -0800 Subject: [PATCH 14/14] Update virtual.py --- syft/workers/virtual.py | 1 - 1 file changed, 1 deletion(-) diff --git a/syft/workers/virtual.py b/syft/workers/virtual.py index 3e2ba64b9bb..53b939a8a2a 100644 --- a/syft/workers/virtual.py +++ b/syft/workers/virtual.py @@ -10,7 +10,6 @@ def _send_msg(self, message: bin, location: BaseWorker) -> bin: if self.message_pending_time > 0: if self.verbose: print(f"pending time of {self.message_pending_time} seconds to send message...") - # pending sleep(self.message_pending_time) return location._recv_msg(message)