コード例 #1
0
 def test_bad_server_init(self):
     s = Server(port=36710,
                ml=FittingInterface,
                ml_config={
                    'shit': False,
                    'poop': True
                })
     with self.assertRaises(RuntimeError):
         s()
コード例 #2
0
 def setUpClass(cls):
     a = [[255, 128, 3], [255, 127, 2], [253, 125, 0]]
     cls._data = np.array([[[a, a, a], [a, a, a]], [[a, a, a], [a, a, a]]])
     cls._short_server = Server(port=36789,
                                ml=FittingInterface(),
                                log=False)
     cls._short_server_address = 'http://127.0.0.1:36789'
     cls._pr1 = Process(target=cls._short_server)
     cls._long_server = Server(port=36790,
                               ml=FittingInterface(True),
                               log=False)
     cls._pr2 = Process(target=cls._long_server)
     cls._long_server_address = 'http://127.0.0.1:36790'
     cls._sm = StateMachine(port=36791,
                            ml=FittingInterface(False),
                            log=False)
     cls._pr3 = Process(target=cls._sm)
     cls._sm_address = 'http://127.0.0.1:36791'
     cls._pr1.start()
     cls._pr2.start()
     cls._pr3.start()
コード例 #3
0
 def test_ready_safe(self):
     s = Server(port=36795,
                ml=FittingInterface,
                ml_config={
                    'long_predict': False,
                    'long_init': True
                })
     pr = Process(target=s)
     client = Client(address='http://127.0.0.1:36795')
     pr.start()
     while not client.ready():
         pass
     pr.terminate()
コード例 #4
0
 def test_fails(self):
     s = Server(port=36795,
                ml=FailingInterface,
                ml_config={
                    'long_predict': False,
                    'long_init': True
                })
     pr = Process(target=s)
     client = Client(address='http://127.0.0.1:36795')
     pr.start()
     while not client.ready():
         pass
     with self.assertRaises(ValueError):
         res = client.predict(self._data)
         res.result()
     pr.terminate()
コード例 #5
0
    def test_ready(self):
        s = Server(port=36794,
                   ml=FittingInterface,
                   ml_config={
                       'long_predict': False,
                       'long_init': True
                   })
        pr = Process(target=s)
        client = Client(address='http://127.0.0.1:36794')
        self.assertFalse(client.started())

        res = client.predict(self._data)
        self.assertIsNotNone(res.exception())
        pr.start()
        while not client.started():
            pass
        self.assertFalse(client.ready())
        while not client.ready():
            pass
        self.assertTrue(client.ready())
        pr.terminate()
コード例 #6
0
def run_server(port):
    predictor = IDS()
    server = Server(port=port, ml=predictor)
    server()
コード例 #7
0
 def test_interface(self):
     with self.assertRaises(ValueError):
         Server(port=36789, ml='test')
コード例 #8
0
 def test_init_ml(self):
     Server(port=36795, ml=FittingInterface, ml_config={})