seeq12 / seeq-azureml

Seeq - Azure ML integration example
Apache License 2.0
7 stars 0 forks source link

[Errno 111] Connection refused #9

Closed minasouliman closed 2 years ago

minasouliman commented 2 years ago

Hi,

In testing out the add-in on our test SDL instance, I got the connection error below. When performing the same test on my local environment I don't get this error and the /api/trees/assets end point is accessible by the code and the model inputs asset selector is enabled.


ConnectionRefusedError                    Traceback (most recent call last)
/usr/local/lib/python3.8/site-packages/urllib3/connection.py in _new_conn(self)
    168         try:
--> 169             conn = connection.create_connection(
    170                 (self._dns_host, self.port), self.timeout, **extra_kw

/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     95     if err is not None:
---> 96         raise err
     97 

/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     85                 sock.bind(source_address)
---> 86             sock.connect(sa)
     87             return sock

ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    698             # Make the request on the httplib connection object.
--> 699             httplib_response = self._make_request(
    700                 conn,

/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    393             else:
--> 394                 conn.request(method, url, **httplib_request_kw)
    395 

/usr/local/lib/python3.8/site-packages/urllib3/connection.py in request(self, method, url, body, headers)
    233             headers["User-Agent"] = _get_default_user_agent()
--> 234         super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    235 

/usr/local/lib/python3.8/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1255         """Send a complete request to the server."""
-> 1256         self._send_request(method, url, body, headers, encode_chunked)
   1257 

/usr/local/lib/python3.8/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1301             body = _encode(body, 'body')
-> 1302         self.endheaders(body, encode_chunked=encode_chunked)
   1303 

/usr/local/lib/python3.8/http/client.py in endheaders(self, message_body, encode_chunked)
   1250             raise CannotSendHeader()
-> 1251         self._send_output(message_body, encode_chunked=encode_chunked)
   1252 

/usr/local/lib/python3.8/http/client.py in _send_output(self, message_body, encode_chunked)
   1010         del self._buffer[:]
-> 1011         self.send(msg)
   1012 

/usr/local/lib/python3.8/http/client.py in send(self, data)
    950             if self.auto_open:
--> 951                 self.connect()
    952             else:

/usr/local/lib/python3.8/site-packages/urllib3/connection.py in connect(self)
    199     def connect(self):
--> 200         conn = self._new_conn()
    201         self._prepare_conn(conn)

/usr/local/lib/python3.8/site-packages/urllib3/connection.py in _new_conn(self)
    180         except SocketError as e:
--> 181             raise NewConnectionError(
    182                 self, "Failed to establish a new connection: %s" % e

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fc4f3d97760>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
/usr/local/lib/python3.8/site-packages/ipyvue/VueTemplateWidget.py in _handle_event(self, _, content, buffers)
     58                 getattr(self, "vue_" + event)(data, buffers)
     59             else:
---> 60                 getattr(self, "vue_" + event)(data)
     61 
     62 

~/.local/lib/python3.8/site-packages/seeq/addons/azureml/ui_components/_model_inputs.py in vue_endpoint_on_change(self, data)
     79 
     80     def vue_endpoint_on_change(self, data=None):
---> 81         self.endpoint_on_change(data)
     82 
     83     def vue_asset_on_change(self, data=None):

~/.local/lib/python3.8/site-packages/seeq/addons/azureml/_add_on_main.py in on_endpoint_dropdown_change(self, data)
    161 
    162         try:
--> 163             self.user_selections.get_assets(self.user_selections.endpoints[data])
    164         except AzureMLException as e:
    165             self.set_error_message(title="AzureMLException: ", message=str(e))

~/.local/lib/python3.8/site-packages/seeq/addons/azureml/_ui_selections.py in get_assets(self, endpoint)
    100             asset_path_names = list()
    101             for idd in self.deployment.model.asset_path_ids:
--> 102                 tree = trees_api.get_tree(id=idd)
    103                 asset_path_names.append(f"{' >> '.join([x.name for x in tree.item.ancestors if x.type == 'Asset'])} >> "
    104                                         f"{tree.item.name}")

/usr/local/lib/python3.8/site-packages/seeq/sdk/apis/trees_api.py in get_tree(self, **kwargs)
    388             return self.get_tree_with_http_info(**kwargs)
    389         else:
--> 390             (data) = self.get_tree_with_http_info(**kwargs)
    391             return data
    392 

/usr/local/lib/python3.8/site-packages/seeq/sdk/apis/trees_api.py in get_tree_with_http_info(self, **kwargs)
    469         auth_settings = []
    470 
--> 471         return self.api_client.call_api('/trees/assets/{id}', 'GET',
    472                                         path_params,
    473                                         query_params,

/usr/local/lib/python3.8/site-packages/seeq/sdk/api_client.py in call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, callback, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
    395         """
    396         if callback is None:
--> 397             return self.__call_api(resource_path, method,
    398                                    path_params, query_params, header_params,
    399                                    body, post_params, files,

/usr/local/lib/python3.8/site-packages/seeq/sdk/api_client.py in __call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, callback, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
    174 
    175             except HTTPError:
--> 176                 _reraise_possibly()
    177 
    178             except ApiException as e:

/usr/local/lib/python3.8/site-packages/seeq/sdk/api_client.py in _reraise_possibly(force)
    159                 retry_timeout['start'] = time.time()
    160             if force or time.time() - retry_timeout['start'] > config.retry_timeout_in_seconds:
--> 161                 reraise(*sys.exc_info())
    162 
    163         while True:

/usr/local/lib/python3.8/site-packages/six.py in reraise(tp, value, tb)
    717             if value.__traceback__ is not tb:
    718                 raise value.with_traceback(tb)
--> 719             raise value
    720         finally:
    721             value = None

/usr/local/lib/python3.8/site-packages/seeq/sdk/api_client.py in __call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, callback, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
    164             try:
    165                 # perform request and return response
--> 166                 response_data = self.request(method, url,
    167                                              query_params=query_params,
    168                                              headers=header_params,

/usr/local/lib/python3.8/site-packages/seeq/sdk/api_client.py in request(self, method, url, query_params, headers, post_params, body, _preload_content, _request_timeout)
    418         """
    419         if method == "GET":
--> 420             return self.rest_client.GET(url,
    421                                         query_params=query_params,
    422                                         _preload_content=_preload_content,

/usr/local/lib/python3.8/site-packages/seeq/sdk/rest.py in GET(self, url, headers, query_params, _preload_content, _request_timeout)
    222 
    223     def GET(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None):
--> 224         return self.request("GET", url,
    225                             headers=headers,
    226                             _preload_content=_preload_content,

/usr/local/lib/python3.8/site-packages/seeq/sdk/rest.py in request(self, method, url, query_params, headers, body, post_params, _preload_content, _request_timeout)
    196             # For `GET`, `HEAD`
    197             else:
--> 198                 r = self.pool_manager.request(method, url,
    199                                               fields=query_params,
    200                                               preload_content=_preload_content,

/usr/local/lib/python3.8/site-packages/urllib3/request.py in request(self, method, url, fields, headers, **urlopen_kw)
     72 
     73         if method in self._encode_url_methods:
---> 74             return self.request_encode_url(
     75                 method, url, fields=fields, headers=headers, **urlopen_kw
     76             )

/usr/local/lib/python3.8/site-packages/urllib3/request.py in request_encode_url(self, method, url, fields, headers, **urlopen_kw)
     94             url += "?" + urlencode(fields)
     95 
---> 96         return self.urlopen(method, url, **extra_kw)
     97 
     98     def request_encode_body(

/usr/local/lib/python3.8/site-packages/urllib3/poolmanager.py in urlopen(self, method, url, redirect, **kw)
    373             response = conn.urlopen(method, url, **kw)
    374         else:
--> 375             response = conn.urlopen(method, u.request_uri, **kw)
    376 
    377         redirect_location = redirect and response.get_redirect_location()

/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    781                 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    782             )
--> 783             return self.urlopen(
    784                 method,
    785                 url,

/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    781                 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    782             )
--> 783             return self.urlopen(
    784                 method,
    785                 url,

/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    781                 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    782             )
--> 783             return self.urlopen(
    784                 method,
    785                 url,

/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    753                 e = ProtocolError("Connection aborted.", e)
    754 
--> 755             retries = retries.increment(
    756                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    757             )

/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    572 
    573         if new_retry.is_exhausted():
--> 574             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    575 
    576         log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPConnectionPool(host='localhost', port=34218): Max retries exceeded with url: /api/trees/assets/541388CC-305F-47E4-8158-E5B1AB8F9EE7 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc4f3d97760>: Failed to establish a new connection: [Errno 111] Connection refused'))```
monstrorivas commented 2 years ago

Is the Add-on installed and accessed from Workbench? or is it being run on a cell in a SDL notebook?

It looks like seeq.spy hasn't been authenticated, which should happen automatically when opening an SDL notebook.

In the test SDL instance, can you open a new notebook (in the same project where you have the add-on) and try this command spy.client (without any previous imports)? It should return an instance of seeq.sdk.api_client.ApiClient. If it returns None there might be an issue with the SDL setup. However, if it is None that can explain the error you are encountering.

minasouliman commented 2 years ago

hmmm...interesting, after logging out and logging back into SDL it's working just fine...must've just been an odd issue that one time. Seems like SDL is authenticating just fine, so closing this. Thanks @monstrorivas!