inception-project / inception-external-recommender

Get annotation suggestions for the INCEpTION text annotation platform from spaCy, Sentence BERT, scikit-learn and more. Runs as a web-service compatible with the external recommender API of INCEpTION.
Apache License 2.0
40 stars 17 forks source link

404 when accessing http://localhost:5000/spacy_ner #46

Closed fishfree closed 1 year ago

fishfree commented 1 year ago

I striclty followed the README to start the server http://localhost:5000/ After adding a spacey_ner recommender and using it to annotate a txt file, It showed as below: image

When I run cur http://127.0.0.1:5000/spacy_pos The developement server outpu as below: image

reckart commented 1 year ago

Did you register the recommender in your Python server script like server.add_classifier("spacy_ner", SpacyNerClassifier("en_core_web_sm"))?

fishfree commented 1 year ago

@reckart Yes. I run these command as below: image

reckart commented 1 year ago

When you curl, you would need to append "/train" or "/predict" to the URL (which INCEpTION does internally).

Cf. https://inception-project.github.io/releases/27.3/docs/developer-guide.html#_external_recommender

reckart commented 1 year ago

Btw. I notice that in your initial report, you wrote spacey_ner - typo only in the report or also in the URL you entered into INCEpTION?

reckart commented 1 year ago

Oh, and is INCEpTION running on the same machine as your recommender?

fishfree commented 1 year ago

@reckart

When you curl, you would need to append "/train" or "/predict" to the URL (which INCEpTION does internally).

Cf. https://inception-project.github.io/releases/27.3/docs/developer-guide.html#_external_recommender

Yes, I noticed that after reading the code.

Btw. I notice that in your initial report, you wrote spacey_ner - typo only in the report or also in the URL you entered into INCEpTION?

Yes, this was my typo error.

Oh, and is INCEpTION running on the same machine as your recommender?

Yes, on the same machine. But INCEpTION is accessed from HTTPS domain name and websocket is working, the recommender is on HTTP 127.0.0.1. Is this the cause?

reckart commented 1 year ago

As long as the Python server process and INCEpTION run on the same system, 127.0.0.1 should be OK even if your users would access INCEpTION under another URL.

Have you deployed any firewall rules on your system that may interfere?

fishfree commented 1 year ago

@reckart I've allowed any source to access 5000 port now. It still does not work. Here is the screenshot, FYI: image Many thanks!

reckart commented 1 year ago

Although you see the error message being delivered by websocket in the browser, the communication between INCEpTION and the recommender does not go across the browser - it happens directly in the backend. If you get a "connection refused" instead of e.g. a "connection timeout", that sounds like there is something actively blocking the request at the TCP level.

If you can connect to the machine that runs both INCEpTION and the recommender, can curl the recommender from there on the command line, and see the requests logged, then it should mean that connecting to the recommender via localhost works - there should not be a difference between INCEpTION and curl if they are both executed on the same machine as the recommender.

Just checked again locally and for me, INCEpTION connects nicely:

URL in the recommender settings: http://localhost:5000/spacy_ner

Python server script

from ariadne.contrib.spacy import SpacyNerClassifier
from ariadne.server import Server

server = Server()
server.add_classifier("spacy_ner", SpacyNerClassifier(model_name="en_core_web_sm"))

server.start(debug=True)

Python server log

 * Serving Flask app 'ariadne.server'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5000
 * Running on http://192.168.178.50:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 586-801-941
127.0.0.1 - - [31/Mar/2023 06:58:12] "POST /spacy_ner/predict HTTP/1.1" 200 -
127.0.0.1 - - [31/Mar/2023 06:59:56] "POST /spacy_ner/predict HTTP/1.1" 200 -

You could try starting INCEpTION from the terminal with -Djdk.internal.httpclient.debug=true and keep and eye on its terminal when you open a document in a project with a recommender. Maybe that provides more insight...

fishfree commented 1 year ago

@reckart Thank you! Finally I figured it out. Because I run INCEpTION in docker, 127.0.0.1 is the container, not the host in which recommender run.