Exemplo n.º 1
0
    def _gen_dispatch(self, task):
        # Get dispatch based on type
        dispatch_type = self._get_config('mri-client', 'dispatch').lower()
        if dispatch_type == 'matplotlib-dispatch':
            folder = os.path.join(
                self._get_config('matplotlib-dispatch', 'save_img_folder'))
            dispatch = MatplotlibDispatch(task, folder)
            windows = self._get_config('matplotlib-dispatch', 'show_windows')
            if windows:
                show_windows = windows.lower() == 'true'
            else:
                show_windows = False

            dispatch.setup_display('iteration',
                                   ['iteration', 'loss', 'accuracy'],
                                   show_windows=show_windows)
        elif dispatch_type == 'mri-server-dispatch':
            url = self._get_config('mri-server-dispatch', 'url')
            username = self._get_config('mri-server-dispatch', 'username')
            password = self._get_config('mri-server-dispatch', 'password')
            dispatch = MriServerDispatch(task, url, username, password)
            dispatch.setup_display('iteration',
                                   ['iteration', 'loss', 'accuracy'])
        else:
            logging.error(
                'Invalid configuration file, please select a dispatch')
            raise Exception(
                'Invalid configuration file, please select a dispatch')

        return dispatch
 def test_new_dispatch(self):
     server = MriServer("http://www.httpbin.com", "testuser", "testpass")
     task = {"title": "TEST", "id": "000112233"}
     dispatch = server.new_dispatch(task)
     test_against = MriServerDispatch(task, "http://www.httpbin.com",
                                      "testuser", "testpass")
     self.assertEqual(dispatch, test_against)