Repository: OpenMined/PySyft

Issue:
I want to be able to send private tensors to my own grid worker
**Is your feature request related to a problem? Please describe.**

me = sy.grid.register("Andrew")

b = th.tensor([1,2,3,4]).tag("#hello").private_tensor(allowed_users=("Ionesio","Andrew"))

me.host_dataset(b)

This raises an error when it should allow me to host data on my own node.


Discussion:

Resolving patch:
diff --git a/syft/frameworks/torch/tensors/interpreters/native.py b/syft/frameworks/torch/tensors/interpreters/native.py
--- a/syft/frameworks/torch/tensors/interpreters/native.py
+++ b/syft/frameworks/torch/tensors/interpreters/native.py
@@ -802,7 +802,7 @@ def private_tensor(self, *args, allowed_users: List[str], no_wrap: bool = False,
 
         if self.is_wrapper:
             self.child = (
-                syft.PrivateTensor(*args, **kwargs)
+                syft.PrivateTensor(tags=self.tags, *args, **kwargs)
                 .on(self.child, wrap=False)
                 .register_credentials(tuple(allowed_users))
             )
@@ -812,7 +812,7 @@ def private_tensor(self, *args, allowed_users: List[str], no_wrap: bool = False,
                 return self
 
         private_tensor = (
-            syft.PrivateTensor(*args, **kwargs)
+            syft.PrivateTensor(tags=self.tags, *args, **kwargs)
             .on(self, wrap=False)
             .register_credentials(tuple(allowed_users))
         )
diff --git a/syft/frameworks/torch/tensors/interpreters/private.py b/syft/frameworks/torch/tensors/interpreters/private.py
--- a/syft/frameworks/torch/tensors/interpreters/private.py
+++ b/syft/frameworks/torch/tensors/interpreters/private.py
@@ -57,16 +57,16 @@ def allow(self, user) -> bool:
         """
         return user in self.allowed_users
 
-    def register_credentials(self, users: Tuple[str]) -> "PrivateTensor":
+    def register_credentials(self, users: List[str]) -> "PrivateTensor":
         """ Register a new user credential(s) into the list of allowed users to get this tensor.
 
             Args:
-                users (tuple): Credential(s) to be registered.
+                users (list): Credential(s) to be registered.
         """
         if not hasattr(self, "allowed_users"):
             self.allowed_users = tuple()
 
-        self.allowed_users = self.allowed_users + users
+        self.allowed_users = self.allowed_users + tuple(users)
 
         return self
 
diff --git a/syft/grid/network.py b/syft/grid/network.py
--- a/syft/grid/network.py
+++ b/syft/grid/network.py
@@ -2,6 +2,7 @@
 import websocket
 import json
 from syft.codes import NODE_EVENTS, GRID_EVENTS, MSG_FIELD
+from syft.frameworks.torch.tensors.interpreters.private import PrivateTensor
 from syft.grid.nodes_manager import WebRTCManager
 from syft.grid.peer_events import (
     _monitor,
@@ -146,7 +147,13 @@ def host_dataset(self, dataset):
             Args:
                 dataset: Dataset to be hosted.
         """
-        return dataset.send(self._worker)
+        allowed_users = None
+
+        # By default the peer should be allowed to access its own private tensors.
+        if dataset.is_wrapper and type(dataset.child) == PrivateTensor:
+            dataset.child.register_credentials([self._worker.id])
+
+        return dataset.send(self._worker, user=self._worker.id)
 
     def host_model(self, model):
         """ Host model using the virtual worker defined previously. """


Test patch: