OSError: [Errno 99] Cannot assign requested address

docs
done

(Michael Becker) #1

I installed the latest prodigy (prodigy-0.5.0-cp35.cp36-cp35m.cp36m-linux_x86_64.whl)

I then ran the following commands from https://prodi.gy/docs/workflow-text-classification:

$ prodigy dataset gh_issues "Classify issues on GitHub"
$ prodigy textcat.teach gh_issues en_core_web_sm "docs" --api github --label DOCUMENTATION

I get the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.6/site-packages/prodigy/__main__.py", line 240, in <module>
    server(controller, controller.config)
  File "/usr/local/lib/python3.6/site-packages/prodigy/app.py", line 36, in server
    threads=1)
  File "/usr/local/lib/python3.6/site-packages/waitress/server.py", line 85, in create_server
    sockinfo=sockinfo)
  File "/usr/local/lib/python3.6/site-packages/waitress/server.py", line 182, in __init__
    self.bind_server_socket()
  File "/usr/local/lib/python3.6/site-packages/waitress/server.py", line 294, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/local/lib/python3.6/asyncore.py", line 329, in bind
    return self.socket.bind(addr)
OSError: [Errno 99] Cannot assign requested address

I was able to work around this by changing the default host in prodigy.json to 127.0.0.1:

{
  "host": "127.0.0.1",
}

Some additional debugging of waitress directly:

$ python
>>> from waitress import serve
>>> app = lambda x:x
>>> serve(app, listen='127.0.0.1:8088')
Serving on http://localhost:8088
>>> serve(app, listen='localhost:8088')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/waitress/__init__.py", line 11, in serve
    server = _server(app, **kw)
  File "/usr/local/lib/python3.6/site-packages/waitress/server.py", line 85, in create_server
    sockinfo=sockinfo)
  File "/usr/local/lib/python3.6/site-packages/waitress/server.py", line 182, in __init__
    self.bind_server_socket()
  File "/usr/local/lib/python3.6/site-packages/waitress/server.py", line 294, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/local/lib/python3.6/asyncore.py", line 329, in bind
    return self.socket.bind(addr)
OSError: [Errno 99] Cannot assign requested address

$ ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.066 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.136 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.192 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.137 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.475 ms

Some information about my environment:

$ cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/

$ python --version
Python 3.6.3

$ pip freeze
certifi==2017.11.5
chardet==3.0.4
cymem==1.31.2
cytoolz==0.8.2
dill==0.2.7.1
en-core-web-sm==2.0.0
falcon==1.3.0
ftfy==4.4.3
html5lib==0.999999999
hug==2.3.2
hug-middleware-cors==1.0.0
idna==2.6
json5==0.5.1
mmh3==2.5.1
msgpack-numpy==0.4.1
msgpack-python==0.4.8
murmurhash==0.28.0
numpy==1.13.3
oauthlib==2.0.6
pathlib==1.0.1
peewee==2.10.2
plac==0.9.6
preshed==1.0.0
prodigy==0.5.0
python-mimeparse==1.6.0
regex==2017.4.5
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
spacy==2.0.3
termcolor==1.1.0
thinc==6.10.1
toolz==0.8.2
tqdm==4.19.4
TwitterSearch==1.0.1
ujson==1.35
urllib3==1.22
waitress==1.1.0
wcwidth==0.1.7
webencodings==0.5.1
wrapt==1.10.11

(Ines Montani) #2

Thanks a lot for the report and the super detailed environment and debugging info! This is really helpful :+1:

The default host is localhost – and considering it’s in your /etc/hosts and you can ping it without problems, I’m really not sure what’s going wrong here… We’re also not doing anything “clever” or especially custom here – Prodigy is mostly just serving the app using waitress with a pretty standard configuration.

On the other hand, network stuff isn’t our strongest skill, so we’re open for suggestions here. Maybe we should consider using 127.0.0.1 instead of localhostthen? Adding a note to the docs early on would probably make sense, too. (Even if we get the localhost stuff to work properly, some users may still have their hosts configured differently, so having a little reminder could be nice.)


(Michael Becker) #3

So I was poking at this further and I noticed I’m only able to get this working when I use host “0.0.0.0”. With “127.0.0.1” the app starts without crashing but I can’t connect to it from a browser.

Some additional information. I’m running this in a docker container on my laptop. Networking is also not my strongest suite but usually when I run into these kinds of issues switching to 0.0.0.0 fixes things :slight_smile:

Here’s my Dockerfile:

FROM python:stretch
MAINTAINER Michael Becker

ENV PYTHONUNBUFFERED 1

COPY *linux_x86_64.whl /root
RUN pip install /root/prodigy*.whl
RUN python -m spacy download en_core_web_sm
RUN mkdir -p /root/.prodigy/
COPY prodigy.json /root/.prodigy/prodigy.json
RUN prodigy dataset gh_issues "Classify issues on GitHub"

ENTRYPOINT prodigy textcat.teach gh_issues en_core_web_sm "docs" --api github --label DOCUMENTATION

And the commands I’m running to build and run the container:

$ docker build -t prodigy-docker . 
$ docker run -it --rm --name prodigy -p 8080:8080 -d prodigy-docker

The Dockerfile requires that you have the linux prodigy wheel and a prodigy.json in the CWD

Here’s my updated prodigy.json:

{
  "host": "0.0.0.0",
}

Update: I talked with my local docker guru and we’re convinced this is a quirk of docker networking. Obviously when running these tools in production you’ll either need to bind to 0.0.0.0 or setup some kind of gateway like nginx so it probably can’t hurt to mention something about this caveat in the docs.

Thanks for the awesome tool!


(Matthew Honnibal) #4

Thanks for following up! Definitely good to have this in the docs.

In hindsight I suppose it makes some sense that within the container, localhost doesn’t point out to the outside world.


(Ines Montani) #5

Thanks, this is really helpful and good to know! I’ve added a “Using Prodigy with Docker” section to the configuration docs that mentions this, link to this thread for more details and also suggests setting "host": "0.0.0.0" as a possible solution for other environments and setups that produce a similar error.


(Alex A Morgan) #6

Would it be possible to add an example Dockerfile to the Prodigy documentation. It wasn’t trivial to set up Prodigy in Docker for someone new to Docker, and I spent a couple hours trying to get it to work.

Before I found this post I got Prodigy working in Docker using the “python:3.7-slim” base image, in contrast to the “python:stretch” base image used in the Dockerfile in the previous post. The “python:3.7-slim” base image doesn’t include gcc therefore I had to install gcc in order to install the prodigy*.whl, and then uninstall gcc to save space (see link). In fact I also had to add g++ because I got another error (see link). In the end this looks a bit messy but it leads to a Docker image which is less than half the size (733 MB as opposed to 1.51 GB). So in case anyone cares about the size of their Docker image then I thought I’d post my solution here. Here’s the Dockerfile I used.

FROM python:3.7-slim

COPY *linux_x86_64.whl /root
RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc g++ \
    && rm -rf /var/lib/apt/lists/* \
    && pip install *linux_x86_64.whl \
    && apt-get purge -y --auto-remove gcc g++
RUN python -m spacy download en_core_web_sm
RUN mkdir -p /root/.prodigy/
COPY prodigy.json /root/.prodigy/prodigy.json
RUN prodigy dataset gh_issues "Classify issues on GitHub"

ENTRYPOINT prodigy textcat.teach gh_issues en_core_web_sm "docs" --api github --label 
DOCUMENTATION

I hope this helps,

Alex