def test_executing_resolves_future(self): fut = Future() cmd = cmds.ForwardPass(fut, [1]) ctx = cmds.Context(supervisor=mock.Mock()) cmd.execute(ctx) assert fut.result(timeout=0)
def test_executing_resolves_future_if_raised(self): fut = Future() cmd = cmds.ForwardPass(fut, [1]) supervisor = mock.Mock() supervisor.forward.side_effect = self.FailException("fail") ctx = cmds.Context(supervisor=supervisor) cmd.execute(ctx) with pytest.raises(self.FailException): assert fut.result(timeout=0)
def forward(self, input_tensor): res = Future() self._supervisor.send_command(commands.ForwardPass(res, input_tensor)) return res
def test_forward(self, supervisor, worker_thread, exemplum): fut = Future() forward_cmd = commands.ForwardPass(fut, np.array([1])) supervisor.send_command(forward_cmd) assert 42 == fut.result(timeout=0.5)
def test_cmd_accepts_future_as_constructor_arg(self): fut = Future() cmds.ForwardPass(fut, [1])