socket.gaierror: [Errno -2] Name or service not known #63

Closed
opened 2025-10-14 15:42:17 -06:00 by navan · 0 comments
Owner

Originally created by @shi4712shi on 3/28/2022

Hello! Looks to be a very useful tool. Following the "Installing BERN2" on READAME.md, I have installed BERN2 on my lab server. And I run the run_bern2.sh successfully with these logs:

[28/Mar/2022 10:13:16.373253] BERN2 LOADED..
 * Serving Flask app 'app' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://**.***.**.*:8888/ (Press CTRL+C to quit)

but when I tried to use the bern2 API with

import requests

def query_plain(text, url=" http://**.***.**.*:8888/plain"):
    return requests.post(url, json={'text': text}).json()

if __name__ == '__main__':
    text = "Autophagy maintains tumour growth through circulating arginine."
    print(query_plain(text))

the error occurred:

[28/Mar/2022 16:16:25.544316] id: cd11338c2ddb8a9c081e4083773b71ba8c2c25eb06698ac53af26704
Traceback (most recent call last):
  File "PATH/TO/BERN2/bern2/bern2.py", line 106, in annotate_text
    output = self.tag_entities(text, base_name)
  File "PATH/TO/BERN2/bern2/bern2.py", line 358, in tag_entities
    async_result = loop.run_until_complete(self.async_ner(arguments_for_coroutines))
  File "PATH/TO/bern2/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "PATH/TO/BERN2/bern2/bern2.py", line 491, in async_ner
    result = await asyncio.gather(*coroutines)
  File "PATH/TO/BERN2/bern2/bern2.py", line 517, in _ner_wrap
    loop)
  File "PATH/TO/BERN2/bern2/bern2.py", line 553, in async_tell_inputfile
    sock.connect((host, port))
socket.gaierror: [Errno -2] Name or service not known

[2022-03-28 16:16:25,587] ERROR in app: Exception on /plain [POST]
Traceback (most recent call last):
  File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "PATH/TO/BERN2/app/__init__.py", line 85, in plain_api
    return Response(json.dumps({"error_message": result_dict["error_message"]}), status=404, content_type='application/json')
NameError: name 'Response' is not defined

Thank you
(I'm not the root of the lab server, I remove the 'sudo' command in run_bern2.sh. But I'm not sure the effect.)

*Originally created by @shi4712shi on 3/28/2022* Hello! Looks to be a very useful tool. Following the "Installing BERN2" on READAME.md, I have installed BERN2 on my lab server. And I run the run_bern2.sh successfully with these logs: ``` [28/Mar/2022 10:13:16.373253] BERN2 LOADED.. * Serving Flask app 'app' (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on all addresses. WARNING: This is a development server. Do not use it in a production deployment. * Running on http://**.***.**.*:8888/ (Press CTRL+C to quit) ``` but when I tried to use the bern2 API with ``` import requests def query_plain(text, url=" http://**.***.**.*:8888/plain"): return requests.post(url, json={'text': text}).json() if __name__ == '__main__': text = "Autophagy maintains tumour growth through circulating arginine." print(query_plain(text)) ``` the error occurred: ``` [28/Mar/2022 16:16:25.544316] id: cd11338c2ddb8a9c081e4083773b71ba8c2c25eb06698ac53af26704 Traceback (most recent call last): File "PATH/TO/BERN2/bern2/bern2.py", line 106, in annotate_text output = self.tag_entities(text, base_name) File "PATH/TO/BERN2/bern2/bern2.py", line 358, in tag_entities async_result = loop.run_until_complete(self.async_ner(arguments_for_coroutines)) File "PATH/TO/bern2/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete return future.result() File "PATH/TO/BERN2/bern2/bern2.py", line 491, in async_ner result = await asyncio.gather(*coroutines) File "PATH/TO/BERN2/bern2/bern2.py", line 517, in _ner_wrap loop) File "PATH/TO/BERN2/bern2/bern2.py", line 553, in async_tell_inputfile sock.connect((host, port)) socket.gaierror: [Errno -2] Name or service not known [2022-03-28 16:16:25,587] ERROR in app: Exception on /plain [POST] Traceback (most recent call last): File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "PATH/TO/bern2/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "PATH/TO/BERN2/app/__init__.py", line 85, in plain_api return Response(json.dumps({"error_message": result_dict["error_message"]}), status=404, content_type='application/json') NameError: name 'Response' is not defined ``` Thank you (I'm not the root of the lab server, I remove the 'sudo' command in run_bern2.sh. But I'm not sure the effect.)
navan closed this issue 2025-10-14 15:42:19 -06:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/BERN2#63
No description provided.