Exemplo n.º 1
0
 def SetCardinalities(
     self,
     request: executor_pb2.SetCardinalitiesRequest,
     context: grpc.ServicerContext,
 ) -> executor_pb2.SetCardinalitiesResponse:
   """Sets the cartinality for the executor service."""
   py_typecheck.check_type(request, executor_pb2.SetCardinalitiesRequest)
   try:
     cardinalities_dict = executor_serialization.deserialize_cardinalities(
         request.cardinalities)
     self._executor = self._ex_factory.create_executor(cardinalities_dict)
     return executor_pb2.SetCardinalitiesResponse()
   except (ValueError, TypeError) as err:
     _set_invalid_arg_err(context, err)
     return executor_pb2.SetCardinalitiesResponse()
 def test_set_cardinalities_returns_none(self, mock_stub):
   response = executor_pb2.SetCardinalitiesResponse()
   instance = mock_stub.return_value
   instance.SetCardinalities = mock.Mock(side_effect=[response])
   executor = create_remote_executor()
   result = executor.set_cardinalities({placements.CLIENTS: 3})
   self.assertIsNone(result)
 def test_set_cardinalities_returns_none(self, mock_stub):
     response = executor_pb2.ExecuteResponse(
         set_cardinalities=executor_pb2.SetCardinalitiesResponse())
     executor = _setup_mock_streaming_executor(mock_stub, response)
     loop = asyncio.get_event_loop()
     result = loop.run_until_complete(
         executor.set_cardinalities({placement_literals.CLIENTS: 3}))
     self.assertIsNone(result)
 def test_set_cardinalities_returns_none(self, mock_stub):
     response = executor_pb2.SetCardinalitiesResponse()
     instance = mock_stub.return_value
     instance.SetCardinalities = mock.Mock(side_effect=[response])
     executor = create_remote_executor()
     loop = asyncio.get_event_loop()
     result = loop.run_until_complete(
         executor.set_cardinalities({placement_literals.CLIENTS: 3}))
     self.assertIsNone(result)