Repository: sql-machine-learning/elasticdl

Issue:
[PS-1]Add new RPC services definition in elasticdl.proto according to PS design
[PS design](https://github.com/sql-machine-learning/elasticdl/blob/develop/docs/designs/ps_design.md#rpc-definition) adds some new RPC services.


Discussion:

Resolving patch:
diff --git a/elasticdl/python/ps/servicer.py b/elasticdl/python/ps/servicer.py
--- a/elasticdl/python/ps/servicer.py
+++ b/elasticdl/python/ps/servicer.py
@@ -1,6 +1,6 @@
 from google.protobuf import empty_pb2
 
-from elasticdl.proto import elasticdl_pb2_grpc
+from elasticdl.proto import elasticdl_pb2, elasticdl_pb2_grpc
 
 
 class PserverServicer(elasticdl_pb2_grpc.PserverServicer):
@@ -23,11 +23,11 @@ def __init__(
 
     def pull_variable(self, request, _):
         # TODO: implement this RPC service
-        return empty_pb2.Empty()
+        return elasticdl_pb2.PullVariableResponse()
 
     def pull_embedding_vector(self, request, _):
         # TODO: implement this RPC service
-        return empty_pb2.Empty()
+        return elasticdl_pb2.Tensor()
 
     def push_model(self, request, _):
         # TODO: implement this RPC service
@@ -35,4 +35,4 @@ def push_model(self, request, _):
 
     def push_gradient(self, request, _):
         # TODO: implement this RPC service
-        return empty_pb2.Empty()
+        return elasticdl_pb2.PushGradientResponse()


Test patch:
diff --git a/elasticdl/python/tests/pserver_servicer_test.py b/elasticdl/python/tests/pserver_servicer_test.py
--- a/elasticdl/python/tests/pserver_servicer_test.py
+++ b/elasticdl/python/tests/pserver_servicer_test.py
@@ -4,7 +4,7 @@
 import grpc
 from google.protobuf import empty_pb2
 
-from elasticdl.proto import elasticdl_pb2_grpc
+from elasticdl.proto import elasticdl_pb2, elasticdl_pb2_grpc
 from elasticdl.python.common.constants import GRPC
 from elasticdl.python.ps.parameter_server import ParameterServer
 from elasticdl.python.ps.parameters import Parameters
@@ -80,15 +80,18 @@ def testServicer(self):
 
         # TODO: replace the section below with real RPC service tests
         # after service implementation
-        try:
-            req = empty_pb2.Empty()
-            res = self._stub.pull_variable(req)
-            self.assertEqual(res, req)
-            res = self._stub.pull_embedding_vector(req)
-            self.assertEqual(res, req)
-            res = self._stub.push_model(req)
-            self.assertEqual(res, req)
-            res = self._stub.push_gradient(req)
-            self.assertEqual(res, req)
-        except Exception:
-            self.assertTrue(False)
+        req = elasticdl_pb2.PullVariableRequest()
+        res = self._stub.pull_variable(req)
+        self.assertEqual(res, elasticdl_pb2.PullVariableResponse())
+
+        req = elasticdl_pb2.PullEmbeddingVectorRequest()
+        res = self._stub.pull_embedding_vector(req)
+        self.assertEqual(res, elasticdl_pb2.Tensor())
+
+        req = elasticdl_pb2.Model()
+        res = self._stub.push_model(req)
+        self.assertEqual(res, empty_pb2.Empty())
+
+        req = elasticdl_pb2.PushGradientRequest()
+        res = self._stub.push_gradient(req)
+        self.assertEqual(res, elasticdl_pb2.PushGradientResponse())