Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def forward(self, input_tensor):
     res = Future()
     self._supervisor.send_command(commands.ForwardPass(res, input_tensor))
     return res
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def test_cmd_accepts_future_as_constructor_arg(self):
     fut = Future()
     cmds.ForwardPass(fut, [1])