label-studio-ml backend requests.exceptions.ConnectionError

670 Views Asked by At

I'am trying to get pre annotations from label studio-ml backend. I am running both (label studio and label studio ml on Dockers) The connection to Label-studio-ml has worked but every time when I try to get a pre annotation I get the following log in my ls-Machine Learning:

image_url: /data/upload/1/0c8720ce-0f29e9df11dbc1cce55cb3529517dcd5.jpg
2023-01-04 20:49:16 [2023-01-04 19:49:16,462] [ERROR] [label_studio_ml.exceptions::exception_f::53] Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
2023-01-04 20:49:16     conn = connection.create_connection(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection
2023-01-04 20:49:16     raise err
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
2023-01-04 20:49:16     sock.connect(sa)
2023-01-04 20:49:16 ConnectionRefusedError: [Errno 111] Connection refused
2023-01-04 20:49:16 
2023-01-04 20:49:16 During handling of the above exception, another exception occurred:
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
2023-01-04 20:49:16     httplib_response = self._make_request(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request
2023-01-04 20:49:16     conn.request(method, url, **httplib_request_kw)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
2023-01-04 20:49:16     super(HTTPConnection, self).request(method, url, body=body, headers=headers)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
2023-01-04 20:49:16     self._send_request(method, url, body, headers, encode_chunked)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
2023-01-04 20:49:16     self.endheaders(body, encode_chunked=encode_chunked)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
2023-01-04 20:49:16     self._send_output(message_body, encode_chunked=encode_chunked)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
2023-01-04 20:49:16     self.send(msg)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 980, in send
2023-01-04 20:49:16     self.connect()
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
2023-01-04 20:49:16     conn = self._new_conn()
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
2023-01-04 20:49:16     raise NewConnectionError(
2023-01-04 20:49:16 urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xfffebeb87610>: Failed to establish a new connection: [Errno 111] Connection refused
2023-01-04 20:49:16 
2023-01-04 20:49:16 During handling of the above exception, another exception occurred:
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
2023-01-04 20:49:16     resp = conn.urlopen(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
2023-01-04 20:49:16     retries = retries.increment(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
2023-01-04 20:49:16     raise MaxRetryError(_pool, url, error or ResponseError(cause))
2023-01-04 20:49:16 urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /data/upload/1/0c8720ce-0f29e9df11dbc1cce55cb3529517dcd5.jpg (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xfffebeb87610>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-01-04 20:49:16 
2023-01-04 20:49:16 During handling of the above exception, another exception occurred:
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
2023-01-04 20:49:16     return f(*args, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/api.py", line 32, in _predict
2023-01-04 20:49:16     predictions, model = _manager.predict(tasks, project, label_config, force_reload, try_fetch, **params)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/model.py", line 582, in predict
2023-01-04 20:49:16     predictions = m.model.predict(tasks, **kwargs)
2023-01-04 20:49:16   File "/app/mobilenet_finetune.py", line 74, in predict
2023-01-04 20:49:16     image_path = self.get_local_path(image_url, project_dir=self.image_dir)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/model.py", line 322, in get_local_path
2023-01-04 20:49:16     return get_local_path(url, project_dir=project_dir, hostname=self.hostname, access_token=self.access_token)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_tools/core/utils/io.py", line 96, in get_local_path
2023-01-04 20:49:16     r = requests.get(url, stream=True, headers=headers)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 75, in get
2023-01-04 20:49:16     return request('get', url, params=params, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
2023-01-04 20:49:16     return session.request(method=method, url=url, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
2023-01-04 20:49:16     resp = self.send(prep, **send_kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
2023-01-04 20:49:16     r = adapter.send(request, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
2023-01-04 20:49:16     raise ConnectionError(e, request=request)
2023-01-04 20:49:16 requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /data/upload/1/0c8720ce-0f29e9df11dbc1cce55cb3529517dcd5.jpg (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xfffebeb87610>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
2023-01-04 20:49:16     conn = connection.create_connection(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection
2023-01-04 20:49:16     raise err
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
2023-01-04 20:49:16     sock.connect(sa)
2023-01-04 20:49:16 ConnectionRefusedError: [Errno 111] Connection refused
2023-01-04 20:49:16 
2023-01-04 20:49:16 During handling of the above exception, another exception occurred:
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
2023-01-04 20:49:16     httplib_response = self._make_request(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request
2023-01-04 20:49:16     conn.request(method, url, **httplib_request_kw)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
2023-01-04 20:49:16     super(HTTPConnection, self).request(method, url, body=body, headers=headers)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
2023-01-04 20:49:16     self._send_request(method, url, body, headers, encode_chunked)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
2023-01-04 20:49:16     self.endheaders(body, encode_chunked=encode_chunked)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
2023-01-04 20:49:16     self._send_output(message_body, encode_chunked=encode_chunked)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
2023-01-04 20:49:16     self.send(msg)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/http/client.py", line 980, in send
2023-01-04 20:49:16     self.connect()
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
2023-01-04 20:49:16     conn = self._new_conn()
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
2023-01-04 20:49:16     raise NewConnectionError(
2023-01-04 20:49:16 urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xfffebeb87610>: Failed to establish a new connection: [Errno 111] Connection refused
2023-01-04 20:49:16 
2023-01-04 20:49:16 During handling of the above exception, another exception occurred:
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
2023-01-04 20:49:16     resp = conn.urlopen(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
2023-01-04 20:49:16     retries = retries.increment(
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
2023-01-04 20:49:16     raise MaxRetryError(_pool, url, error or ResponseError(cause))
2023-01-04 20:49:16 urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /data/upload/1/0c8720ce-0f29e9df11dbc1cce55cb3529517dcd5.jpg (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xfffebeb87610>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-01-04 20:49:16 
2023-01-04 20:49:16 During handling of the above exception, another exception occurred:
2023-01-04 20:49:16 
2023-01-04 20:49:16 Traceback (most recent call last):
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
2023-01-04 20:49:16     return f(*args, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/api.py", line 32, in _predict
2023-01-04 20:49:16     predictions, model = _manager.predict(tasks, project, label_config, force_reload, try_fetch, **params)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/model.py", line 582, in predict
2023-01-04 20:49:16     predictions = m.model.predict(tasks, **kwargs)
2023-01-04 20:49:16   File "/app/mobilenet_finetune.py", line 74, in predict
2023-01-04 20:49:16     image_path = self.get_local_path(image_url, project_dir=self.image_dir)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_ml/model.py", line 322, in get_local_path
2023-01-04 20:49:16     return get_local_path(url, project_dir=project_dir, hostname=self.hostname, access_token=self.access_token)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/label_studio_tools/core/utils/io.py", line 96, in get_local_path
2023-01-04 20:49:16     r = requests.get(url, stream=True, headers=headers)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 75, in get
2023-01-04 20:49:16     return request('get', url, params=params, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
2023-01-04 20:49:16     return session.request(method=method, url=url, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
2023-01-04 20:49:16     resp = self.send(prep, **send_kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
2023-01-04 20:49:16     r = adapter.send(request, **kwargs)
2023-01-04 20:49:16   File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
2023-01-04 20:49:16     raise ConnectionError(e, request=request)
2023-01-04 20:49:16 requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /data/upload/1/0c8720ce-0f29e9df11dbc1cce55cb3529517dcd5.jpg (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xfffebeb87610>: Failed to establish a new connection: [Errno 111] Connection refused'))

Can anyone tell me how to let label-studio-ml backend docker to access the image path on the label-studio docker

1

There are 1 best solutions below

0
On

Try to connect to the local ip(192.168.1.xx:8080) of the machine you are running label studio rather than localhost:8080.

Replace the localhost:8080 with your local ip address (192.168.1.xx:8080) in the model.py of label studio ml backend. Make sure label studio is running on port 8080.