예제 #1
0
 def test_single_worker_construction_invokes_federating_executor(
         self, mock_obj):
     channels = [
         grpc.insecure_channel('localhost:1'),
     ]
     remote_ex_factory = executor_stacks.remote_executor_factory(channels)
     remote_ex_factory.create_executor({placements.CLIENTS: 10})
     mock_obj.assert_called_once()
예제 #2
0
 def test_fewer_clients_than_workers_only_passes_one_client(self):
     channels = [
         grpc.insecure_channel('localhost:1'),
         grpc.insecure_channel('localhost:2')
     ]
     remote_ex_factory = executor_stacks.remote_executor_factory(channels)
     remote_ex_factory.create_executor({placements.CLIENTS: 1})
     self.assertLen(self.coro_mock.call_args_list, 1)
     self.coro_mock.assert_called_once_with({placements.CLIENTS: 1})
예제 #3
0
 def test_fewer_clients_than_workers_returns_only_one_live_worker(
         self, mock_obj):
     channels = [
         grpc.insecure_channel('localhost:1'),
         grpc.insecure_channel('localhost:2')
     ]
     remote_ex_factory = executor_stacks.remote_executor_factory(channels)
     remote_ex_factory.create_executor({placements.CLIENTS: 1})
     self.assertLen(mock_obj.call_args_list, 1)
     # Assert that aggregate stacks was passed only one executor.
     mock_obj.assert_called_once_with([mock.ANY])
예제 #4
0
def create_remote_execution_context(channels,
                                    thread_pool_executor=None,
                                    dispose_batch_size=20,
                                    max_fanout: int = 100,
                                    default_num_clients: int = 0):
  """Creates context to execute computations with workers on `channels`."""
  factory = executor_stacks.remote_executor_factory(
      channels=channels,
      thread_pool_executor=thread_pool_executor,
      dispose_batch_size=dispose_batch_size,
      max_fanout=max_fanout,
      default_num_clients=default_num_clients,
  )

  return execution_context.ExecutionContext(
      executor_fn=factory, compiler_fn=compiler.transform_to_native_form)
예제 #5
0
def create_remote_execution_context(channels,
                                    rpc_mode='REQUEST_REPLY',
                                    thread_pool_executor=None,
                                    dispose_batch_size=20,
                                    max_fanout: int = 100):
  """Creates context to execute computations with workers on `channels`."""
  factory = executor_stacks.remote_executor_factory(
      channels=channels,
      rpc_mode=rpc_mode,
      thread_pool_executor=thread_pool_executor,
      dispose_batch_size=dispose_batch_size,
      max_fanout=max_fanout,
  )

  return execution_context.ExecutionContext(
      executor_fn=factory, compiler_fn=compiler.transform_to_native_form)
예제 #6
0
 async def coro_func():
     remote_ex_factory = executor_stacks.remote_executor_factory(
         channels)
     remote_ex_factory.create_executor({placements.CLIENTS: 1})