Exemple #1
0
def test_future_map_raise_exception():
    f = RPCFuture()
    new = f.map(process_err)
    f.set_result(40)

    with pytest.raises(TExc):
        assert new.result()
Exemple #2
0
def test_propagates_only_once_1():
    rpc_fut = RPCFuture()
    fut = Future()

    rpc_fut.attach(fut)
    rpc_fut.cancel()
    rpc_fut.set_result(42)

    with pytest.raises(CancelledError):
        assert fut.result(timeout=1)
Exemple #3
0
 def load_model(self, config: dict, model_file: bytes, model_state: bytes,
                optimizer_state: bytes,
                devices: list) -> RPCFuture[SetDeviceReturnType]:
     logger.info("load model")
     logger.debug(
         "config %s\n model_file %s\n model_state %s\n optimizer_state %s\n devices %s\n",
         config,
         model_file,
         model_state,
         optimizer_state,
         devices,
     )
     fut = RPCFuture()
     ret = SetDeviceReturnType((1, 1, 1, 10, 10), [(1, 1, 1, 10, 10),
                                                   (1, 1, 1, 20, 20)],
                               (0, 0, 0, 4, 4))
     fut.set_result(ret)
     return fut
Exemple #4
0
def test_future_map_returns_new_future():
    f = RPCFuture()
    new = f.map(lambda v: v + 2)
    f.set_result(40)
    assert new.result() == 42
Exemple #5
0
 def forward(self, batch: NDArray) -> RPCFuture[NDArray]:
     logger.info("forward for array of shape %s", batch.shape)
     fut = RPCFuture()
     fut.set_result(batch)
     return fut