Python urllib3.exceptions.MaxRetryError() Examples

The following are 23 code examples of urllib3.exceptions.MaxRetryError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urllib3.exceptions , or try the search function .
Example #1
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 8 votes vote down vote up
def on_get(self, req, resp, ical_key):
        """Access the oncall calendar identified by the key.

        The response is in ical format and this url is intended to be
        supplied to any calendar application that can subscribe to
        calendars from the internet.
        """
        try:
            path = self.base_url + '/api/v0/ical/' + ical_key
            if req.query_string:
                path += '?%s' % req.query_string
            result = self.oncall_client.get(path)
        except MaxRetryError as ex:
            logger.error(ex)
        else:
            if result.status_code == 200:
                resp.status = falcon.HTTP_200
                resp.content_type = result.headers['Content-Type']
                resp.body = result.content
                return
            elif 400 <= result.status_code <= 499:
                resp.status = falcon.HTTP_404
                return

        raise falcon.HTTPInternalServerError('Internal Server Error', 'Invalid response from API') 
Example #2
Source File: discovery.py    From python-base with Apache License 2.0 7 votes vote down vote up
def _load_server_info(self):
        def just_json(_, serialized):
            return serialized

        if not self._cache.get('version'):
            try:
                self._cache['version'] = {
                    'kubernetes': self.client.request('get', '/version', serializer=just_json)
                }
            except (ValueError, MaxRetryError) as e:
                if isinstance(e, MaxRetryError) and not isinstance(e.reason, ProtocolError):
                    raise
                if not self.client.configuration.host.startswith("https://"):
                    raise ValueError("Host value %s should start with https:// when talking to HTTPS endpoint" %
                                     self.client.configuration.host)
                else:
                    raise

        self.__version = self._cache['version'] 
Example #3
Source File: kubeclient.py    From promenade with Apache License 2.0 6 votes vote down vote up
def get_node_labels(self, node_name):
        """
        Get existing registered node labels

        Args:
            node_name(str): node of which getting labels
        Returns:
            dict: labels dict
        """
        try:
            response = self.client.read_node(node_name)
            if response is not None:
                return response.metadata.labels
            else:
                return {}
        except (ApiException, MaxRetryError) as e:
            LOG.exception("An exception occurred in fetching node labels: " +
                          str(e))
            if hasattr(e, 'status') and str(e.status) == "404":
                raise NodeNotFoundException
            else:
                raise KubernetesApiError 
Example #4
Source File: resources.py    From k8s-sidecar with MIT License 6 votes vote down vote up
def _watch_resource_loop(mode, *args):
    while True:
        try:
            # Always wait to slow down the loop in case of exceptions
            sleep(os.getenv("ERROR_THROTTLE_SLEEP", 5))
            if mode == "SLEEP":
                listResources(*args)
                sleep(os.getenv("SLEEP_TIME", 60))
            else:
                _watch_resource_iterator(*args)
        except ApiException as e:
            if e.status != 500:
                print(f"{timestamp()} ApiException when calling kubernetes: {e}\n")
            else:
                raise
        except ProtocolError as e:
            print(f"{timestamp()} ProtocolError when calling kubernetes: {e}\n")
        except MaxRetryError as e:
            print(f"{timestamp()} MaxRetryError when calling kubernetes: {e}\n")
        except Exception as e:
            print(f"{timestamp()} Received unknown exception: {e}\n") 
Example #5
Source File: test_account_client.py    From qiskit-ibmq-provider with Apache License 2.0 6 votes vote down vote up
def test_access_token_not_in_exception_traceback(self):
        """Check that access token is replaced within chained request exceptions."""
        backend_name = 'ibmq_qasm_simulator'
        backend = self.provider.get_backend(backend_name)
        circuit = transpile(self.qc1, backend, seed_transpiler=self.seed)
        qobj = assemble(circuit, backend, shots=1)
        api = backend._api

        exception_message = 'The access token in this exception ' \
                            'message should be replaced: {}'.format(self.access_token)
        exception_traceback_str = ''
        try:
            with mock.patch.object(
                    HTTPConnectionPool,
                    'urlopen',
                    side_effect=MaxRetryError(
                        HTTPConnectionPool('host'), 'url', reason=exception_message)):
                _ = api.job_submit(backend.name(), qobj.to_dict())
        except RequestsApiError:
            exception_traceback_str = traceback.format_exc()

        self.assertTrue(exception_traceback_str)
        if self.access_token in exception_traceback_str:
            self.fail('Access token not replaced in request exception traceback.') 
Example #6
Source File: client.py    From kube-shell with Apache License 2.0 6 votes vote down vote up
def get_resource(self, resource, namespace="all"):
        ret, resources = None, list()
        try:
            ret, namespaced_resource = self._call_api_client(resource)
        except ApiException as ae:
            self.logger.warning("resource autocomplete disabled, encountered "
                                "ApiException", exc_info=1)
        except (NewConnectionError, MaxRetryError, ConnectTimeoutError):
            self.logger.warning("unable to connect to k8 cluster", exc_info=1)
        if ret:
            for i in ret.items:
                if namespace == "all" or not namespaced_resource:
                    resources.append((i.metadata.name, i.metadata.namespace))
                elif namespace == i.metadata.namespace:
                    resources.append((i.metadata.name, i.metadata.namespace))
        return resources 
Example #7
Source File: kubeclient.py    From promenade with Apache License 2.0 6 votes vote down vote up
def update_node_labels(self, node_name, input_labels):
        """
        Updating node labels

        Args:
            node_name(str): node for which updating labels
            input_labels(dict): input labels dict
        Returns:
            SuccessMessage(dict): API success response
        """
        resp_body_succ = SuccessMessage('Update node labels', falcon.HTTP_200)

        try:
            existing_labels = self.get_node_labels(node_name)
            update_labels = _get_update_labels(existing_labels, input_labels)
            # If there is a change
            if bool(update_labels):
                body = {"metadata": {"labels": update_labels}}
                self.client.patch_node(node_name, body)
            return resp_body_succ.get_output_json()
        except (ApiException, MaxRetryError) as e:
            LOG.exception("An exception occurred during node labels update: " +
                          str(e))
            raise KubernetesApiError 
Example #8
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __call__(self, req, resp):
        path = self.base_url + '/api/v0/' + '/'.join(req.path.split('/')[4:])
        if req.query_string:
            path += '?%s' % req.query_string
        try:
            if req.method == 'GET':
                result = self.oncall_client.get(path)
            elif req.method == 'OPTIONS':
                return
            else:
                raise falcon.HTTPMethodNotAllowed(['GET', 'OPTIONS'])
        except MaxRetryError as e:
            logger.error(e.reason)
            raise falcon.HTTPInternalServerError('Internal Server Error', 'Max retry error, api unavailable')
        if result.status_code == 400:
            raise falcon.HTTPBadRequest('Bad Request', '')
        elif str(result.status_code)[0] != '2':
            raise falcon.HTTPInternalServerError('Internal Server Error', 'Unknown response from the api')
        else:
            resp.status = falcon.HTTP_200
            resp.content_type = result.headers['Content-Type']
            resp.body = result.content 
Example #9
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def on_post(self, req, resp):
        """
        Accept twilio POST that has message delivery status, and pass it
        to iris-api
        """

        try:
            re = self.iclient.post(self.endpoint, req.context['body'].decode('utf-8'), raw=True)
        except MaxRetryError:
            logger.exception('Failed posting data to iris-api')
            raise falcon.HTTPInternalServerError('Internal Server Error', 'API call failed')

        if re.status != 204:
            logger.error('Invalid response from API for delivery status update: %s', re.status)
            raise falcon.HTTPBadRequest('Likely bad params passed', 'Invalid response from API')

        resp.status = falcon.HTTP_204 
Example #10
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def on_get(self, req, resp):
        token = req.get_param('token', True)
        data = {}
        for key in self.data_keys:
            data[key] = req.get_param(key, True)

        if not self.validate_token(token, data):
            raise falcon.HTTPForbidden('Invalid token for these given values', '')

        endpoint = self.config['iris']['hook']['gmail_one_click']

        try:
            result = self.iclient.post(endpoint, data)
        except MaxRetryError:
            logger.exception('Hitting iris-api failed for gmail oneclick')
        else:
            if result.status == 204:
                resp.status = falcon.HTTP_204
                return
            else:
                logger.error('Unexpected status code from api %s for gmail oneclick', result.status)

        raise falcon.HTTPInternalServerError('Internal Server Error', 'Invalid response from API') 
Example #11
Source File: discovery.py    From openshift-restclient-python with Apache License 2.0 5 votes vote down vote up
def _load_server_info(self):
        def just_json(_, serialized):
            return serialized

        if not self._cache.get('version'):
            try:
                self._cache['version'] = {
                    'kubernetes': self.client.request('get', '/version', serializer=just_json)
                }
            except (ValueError, MaxRetryError) as e:
                if isinstance(e, MaxRetryError) and not isinstance(e.reason, ProtocolError):
                    raise
                if not self.client.configuration.host.startswith("https://"):
                    raise ValueError("Host value %s should start with https:// when talking to HTTPS endpoint" %
                                     self.client.configuration.host)
                else:
                    raise
            try:
                self._cache['version']['openshift'] = self.client.request(
                    'get',
                    '/version/openshift',
                    serializer=just_json,
                )
            except ApiException:
                pass
        self.__version = self._cache['version'] 
Example #12
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __call__(self, req, resp):
        path = self.base_url + '/v0/' + '/'.join(req.path.split('/')[4:])
        if req.query_string:
            path += '?%s' % req.query_string
        try:
            if req.method == 'POST':
                body = b''
                if req.context['body']:
                    body = req.context['body']
                result = self.iris_client.post(path, body)
            elif req.method == 'GET':
                result = self.iris_client.get(path)
            elif req.method == 'OPTIONS':
                return
            else:
                raise falcon.HTTPMethodNotAllowed(['GET', 'POST', 'PUT', 'DELETE'])
        except MaxRetryError as e:
            logger.error(e.reason)
            raise falcon.HTTPInternalServerError('Internal Server Error', 'Max retry error, api unavailable')
        if result.status_code == 400:
            raise falcon.HTTPBadRequest('Bad Request', '')
        elif str(result.status_code)[0] != '2':
            raise falcon.HTTPInternalServerError('Internal Server Error', 'Unknown response from the api')
        else:
            resp.status = falcon.HTTP_200
            resp.content_type = result.headers['Content-Type']
            resp.body = result.content 
Example #13
Source File: test_urllib3.py    From apm-agent-python with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_timeout(mock_urlopen, elasticapm_client):
    transport = Transport("http://localhost", timeout=5, client=elasticapm_client)
    transport.start_thread()
    mock_urlopen.side_effect = MaxRetryError(None, None, reason=TimeoutError())
    try:
        with pytest.raises(TransportException) as exc_info:
            transport.send("x")
        assert "timeout" in str(exc_info.value)
    finally:
        transport.close() 
Example #14
Source File: http.py    From apm-agent-python with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def send(self, data):
        response = None

        headers = self._headers.copy() if self._headers else {}
        headers.update(self.auth_headers)

        if compat.PY2 and isinstance(self._url, compat.text_type):
            url = self._url.encode("utf-8")
        else:
            url = self._url
        try:
            try:
                response = self.http.urlopen(
                    "POST", url, body=data, headers=headers, timeout=self._timeout, preload_content=False
                )
                logger.debug("Sent request, url=%s size=%.2fkb status=%s", url, len(data) / 1024.0, response.status)
            except Exception as e:
                print_trace = True
                if isinstance(e, MaxRetryError) and isinstance(e.reason, TimeoutError):
                    message = "Connection to APM Server timed out " "(url: %s, timeout: %s seconds)" % (
                        self._url,
                        self._timeout,
                    )
                    print_trace = False
                else:
                    message = "Unable to reach APM Server: %s (url: %s)" % (e, self._url)
                raise TransportException(message, data, print_trace=print_trace)
            body = response.read()
            if response.status >= 400:
                if response.status == 429:  # rate-limited
                    message = "Temporarily rate limited: "
                    print_trace = False
                else:
                    message = "HTTP %s: " % response.status
                    print_trace = True
                message += body.decode("utf8", errors="replace")
                raise TransportException(message, data, print_trace=print_trace)
            return response.getheader("Location")
        finally:
            if response:
                response.close() 
Example #15
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def on_post(self, req, resp):
        """
        Accept twilio SMS webhook and forward to iris API
        """
        try:
            path = self.config['iris']['hook']['twilio_messages']
            re = self.iclient.post(path, req.context['body'].decode('utf-8'), raw=True)
        except MaxRetryError as e:
            logger.error(e.reason)
            self.return_twixml_message('Connection error to web hook.', resp)
            return

        if re.status != 200:
            self.return_twixml_message(
                'Got status code: %d, content: %s' % (re.status,
                                                      re.data[0:100]), resp)
            return
        else:
            body = process_api_response(re.data)
            self.return_twixml_message(body, resp)
            return 
Example #16
Source File: docker_quickstart.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def run(count=0):
    global bot
    try:
        bot = Bot(multi_logs=True, selenium_local_session=False,
                  proxy_address_port=get_proxy(os.environ.get('INSTA_USER')), disable_image_load=True)
        selenium_url = "http://%s:%d/wd/hub" % (os.environ.get('SELENIUM', 'selenium'), 4444)
        bot.set_selenium_remote_session(logger=logging.getLogger(), selenium_url=selenium_url, selenium_driver=selenium_driver(selenium_url))
        bot.login()
        bot.set_settings()
        bot.act()
    except (NewConnectionError, WebDriverException) as exc:
        bot.logger.warning("Exception in run: %s; try again: count=%s" % (exc, count))
        if count > 3:
            print("Exception in run(): %s \n %s" % (exc, traceback.format_exc()))
            report_exception(exc)
        else:
            run(count=count + 1)

    except (ProtocolError, MaxRetryError) as exc:
        bot.logger.error("Abort because of %s; \n%s" % (exc, traceback.format_exc()))
        return

    except Exception as exc:
        print("Exception in run(): %s \n %s" % (exc, traceback.format_exc()))
        report_exception(exc)
    finally:
        print("END")
        bot.end() 
Example #17
Source File: docker_tryLogin.py    From bot with GNU General Public License v3.0 5 votes vote down vote up
def run(count=0):
    global bot
    try:
        bot = Bot(multi_logs=True, selenium_local_session=False,
                  proxy_address_port=get_proxy(os.environ.get('INSTA_USER')), disable_image_load=False)
        selenium_url = "http://%s:%d/wd/hub" % (os.environ.get('SELENIUM', 'selenium'), 4444)
        bot.set_selenium_remote_session(logger=logging.getLogger(), selenium_url=selenium_url, selenium_driver=selenium_driver(selenium_url))
        bot.try_first_login()
    except (NewConnectionError, NewConnectionError) as exc:
        bot.logger.warning("Exception in run: %s; try again: count=%s" % (exc, count))
        if count > 3:
            print("Exception in run(): %s \n %s" % (exc, traceback.format_exc()))
            report_exception(exc)
        else:
            run(count=count + 1)

    except (ProtocolError, MaxRetryError) as exc:
        bot.logger.error("Abort because of %s; \n%s" % (exc, traceback.format_exc()))
        return

    except Exception as exc:
        print("Exception in run(): %s \n %s" % (exc, traceback.format_exc()))
        report_exception(exc)
    finally:
        print("END")
        bot.end() 
Example #18
Source File: app.py    From iris-relay with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def on_post(self, req, resp):
        """
        Accept twilio gather callbacks and forward to iris API
        """
        message_id = req.get_param('message_id')

        # If we weren't given a message_id, this is an OOB message and there isn't
        # anything to say, so hang up.
        if not message_id:
            self.return_twixml_call('Thank you', resp)
            return

        if not message_id.isdigit() and not uuid4hex.match(message_id):
            raise falcon.HTTPBadRequest('Bad message id', 'message id must be int/hex')

        try:
            path = self.config['iris']['hook']['twilio_calls']
            re = self.iclient.post(path, req.context['body'].decode('utf-8'), raw=True, params={
                'message_id': message_id
            })
        except MaxRetryError as e:
            logger.error(e.reason)
            self.return_twixml_call('Connection error to web hook.', resp)
            return

        if re.status != 200:
            self.return_twixml_call(
                'Got status code: %d, content: %s' % (re.status,
                                                      re.data[0:100]), resp)
            return
        else:
            body = process_api_response(re.data)
            self.return_twixml_call(body, resp)
            return 
Example #19
Source File: http.py    From OpenDoor with GNU General Public License v3.0 4 votes vote down vote up
def request(self, url):
        """
        Client request HTTP
        :param str url: request uri
        :return: urllib3.HTTPResponse
        """

        if self._HTTP_DBG_LEVEL <= self.__debug.level:
            self.__debug.debug_request(self._headers, url, self.__cfg.method)
        try:
            if self.__cfg.DEFAULT_SCAN == self.__cfg.scan:
                response = self.__pool.request(self.__cfg.method,
                                               helper.parse_url(url).path,
                                               headers=self._headers,
                                               retries=self.__cfg.retries,
                                               assert_same_host=True,
                                               redirect=False)

                self.cookies_middleware(is_accept=self.__cfg.accept_cookies, response=response)
            else:
                response = PoolManager().request(self.__cfg.method, url,
                                                 headers=self._headers,
                                                 retries=self.__cfg.retries,
                                                 assert_same_host=False,
                                                 redirect=False)
            return response

        except MaxRetryError:
            if self.__cfg.DEFAULT_SCAN == self.__cfg.scan:
                self.__tpl.warning(key='max_retry_error', url=helper.parse_url(url).path)
            pass

        except HostChangedError as error:
            self.__tpl.warning(key='host_changed_error', details=error)
            pass

        except ReadTimeoutError:
            self.__tpl.warning(key='read_timeout_error', url=url)
            pass

        except ConnectTimeoutError:
            self.__tpl.warning(key='connection_timeout_error', url=url)
            pass 
Example #20
Source File: __init__.py    From cauldron with MIT License 4 votes vote down vote up
def status():
    """
    Returns the current status of the cauldron kernel application, which is
    used to keep the
    :return:
    """
    args = arguments.from_request()
    last_timestamp = args.get('last_timestamp', 0)
    force = args.get('force', False)

    if not environ.remote_connection.active:
        results = ui_statuses.get_status(last_timestamp, force)
        return flask.jsonify(results)

    # When connected remotely, get the status from the remote kernel and
    # then merge it with local information that may not have been synced
    # to the remote kernel yet.
    lost_errors = (
        ConnectionError,
        requests_exceptions.ConnectionError,
        requests_exceptions.ConnectTimeout,
        url_exceptions.MaxRetryError,
    )

    try:
        remote_status = requests.post(
            '{}/ui-status'.format(environ.remote_connection.url),
            json=args
        ).json()
    except lost_errors as error:
        ui_configs.status_failures += 1
        return (
            environ.Response().fail(
                code='LOST_REMOTE_CONNECTION',
                message='Unable to communicate with the remote kernel.',
                error=error
            )
            .console_if(
                display_condition=ui_configs.status_failures < 2,
                whitespace=1
            )
            .response
            .flask_serialize()
        )

    ui_configs.status_failures = 0
    return flask.jsonify(ui_statuses.merge_local_state(remote_status, force)) 
Example #21
Source File: flask_unsign.py    From Flask-Unsign with MIT License 4 votes vote down vote up
def test_server(self, requests):
        """Ensure it's possible to fetch cookies from a server and errors are handled properly"""
        requests.return_value = requests
        requests.get.return_value = requests

        requests.cookies = {'session': self.encoded}
        stdout, stderr = self.call('--decode', '--server', 'http://localhost:5000')
        self.assertEqual(stdout.read().strip(), str(self.decoded))

        requests.cookies = {'something-else': self.encoded}
        stdout, stderr = self.call('--decode', '--server', 'http://localhost:5000')
        self.assertNotEqual(stderr.read(), '', msg='Expected an error message')
        self.assertEqual(stdout.read(), '')

        requests.cookies = {'something-else': self.encoded}
        stdout, stderr = self.call('--decode', '--server', 'http://localhost:5000', '--cookie-name', 'something-else')
        self.assertEqual(stdout.read().strip(), str(self.decoded))

        requests.cookies = {'session': self.encoded}
        stdout, stderr = self.call(
            '--decode',
            '--server', 'http://localhost:5000',
            '--proxy', 'https://root:password@localhost:8080')

        self.assertEqual(stdout.read().strip(), str(self.decoded))

        for call in requests.mock_calls:
            if call[INDEX_FN_NAME] == 'get':
                if 'proxies' in call[INDEX_KWARGS]:
                    break

        else:
            raise AssertionError('Didn\'t find "proxies" argument in call args.')

        error_reason = ProxyError()
        error_reason.args = ('Cannot connect to proxy', OSError('Tunnel connection failed'))
        error = ProxyError(MaxRetryError(reason=error_reason, pool=MagicMock(), url='http://localhost:5000'))
        requests.get.side_effect = error

        requests.cookies = {'session': self.encoded}
        stdout, stderr = self.call(
            '--decode',
            '--server', 'http://localhost:5000',
            '--proxy', 'https://root:password@localhost:8080')

        self.assertIn('Tunnel connection failed', stderr.read().strip()) 
Example #22
Source File: webdriver_patches.py    From pytest-splinter with MIT License 4 votes vote down vote up
def patch_webdriver():
    """Patch selenium webdriver to add functionality/fix issues."""
    def _request(self, *args, **kwargs):
        """Override _request to set socket timeout to some appropriate value."""
        exception = HTTPException('Unable to get response')
        for _ in range(3):
            try:
                return old_request(self, *args, **kwargs)
            except (socket.error, HTTPException, IOError, OSError, MaxRetryError) as exc:
                exception = exc
                self._conn = urllib3.PoolManager(timeout=self._timeout)
        raise exception

    # Apply the monkey patch for RemoteConnection
    remote_connection.RemoteConnection._request = _request

    # Apply the monkey patch to Firefox webdriver to disable native events
    # to avoid click on wrong elements, totally unpredictable
    # more info http://code.google.com/p/selenium/issues/detail?id=633
    webdriver.WebDriver.NATIVE_EVENTS_ALLOWED = False

    def execute(self, driver_command, params=None):
        result = self._base_execute(driver_command, params)
        speed = self.get_speed()
        if speed > 0:
            time.sleep(speed)  # pragma: no cover
        return result

    def get_current_window_info(self):
        atts = self.execute_script("return [ window.id, window.name, document.title, document.url ];")
        atts = [
            att if att is not None and att else 'undefined'
            for att in atts]
        return (self.current_window_handle, atts[0], atts[1], atts[2], atts[3])

    def current_window_is_main(self):
        return self.current_window_handle == self.window_handles[0]

    def set_speed(self, seconds):
        self._speed = seconds

    def get_speed(self):
        if not hasattr(self, '_speed'):
            self._speed = float(0)
        return self._speed

    RemoteWebDriver.set_speed = set_speed
    RemoteWebDriver.get_speed = get_speed
    RemoteWebDriver.execute = execute
    RemoteWebDriver.get_current_window_info = get_current_window_info
    RemoteWebDriver.current_window_is_main = current_window_is_main 
Example #23
Source File: processor_kfp.py    From elyra with Apache License 2.0 4 votes vote down vote up
def process(self, pipeline):
        timestamp = datetime.now().strftime("%m%d%H%M%S")
        pipeline_name = f'{pipeline.name}-{timestamp}'

        runtime_configuration = self._get_runtime_configuration(pipeline.runtime_config)
        api_endpoint = runtime_configuration.metadata['api_endpoint']
        cos_endpoint = runtime_configuration.metadata['cos_endpoint']
        cos_bucket = runtime_configuration.metadata['cos_bucket']

        with tempfile.TemporaryDirectory() as temp_dir:
            pipeline_path = os.path.join(temp_dir, f'{pipeline_name}.tar.gz')

            self.log.info("Pipeline : %s", pipeline_name)
            self.log.debug("Creating temp directory %s", temp_dir)

            # Compile the new pipeline
            try:
                pipeline_function = lambda: self._cc_pipeline(pipeline, pipeline_name)  # nopep8 E731
                kfp.compiler.Compiler().compile(pipeline_function, pipeline_path)
            except Exception as ex:
                raise RuntimeError('Error compiling pipeline {} at {}'.
                                   format(pipeline_name, pipeline_path), str(ex)) from ex

            self.log.info("Kubeflow Pipeline successfully compiled.")
            self.log.debug("Kubeflow Pipeline was created in %s", pipeline_path)

            # Upload the compiled pipeline and create an experiment and run
            client = kfp.Client(host=api_endpoint)
            try:
                kfp_pipeline = client.upload_pipeline(pipeline_path, pipeline_name)
            except MaxRetryError as ex:
                raise RuntimeError('Error connecting to pipeline server {}'.format(api_endpoint)) from ex

            self.log.info("Kubeflow Pipeline successfully uploaded to : %s", api_endpoint)

            run = client.run_pipeline(experiment_id=client.create_experiment(pipeline_name).id,
                                      job_name=timestamp,
                                      pipeline_id=kfp_pipeline.id)

            self.log.info("Starting Kubeflow Pipeline Run...")

            return PipelineProcessorResponse(
                run_url="{}/#/runs/details/{}".format(api_endpoint, run.id),
                object_storage_url="{}".format(cos_endpoint),
                object_storage_path="/{}/{}".format(cos_bucket, pipeline_name),
            )

        return None