ideonate / cdsdashboards

JupyterHub extension for ContainDS Dashboards
https://cdsdashboards.readthedocs.io/
Other
200 stars 38 forks source link

OSError: [Errno 99] Cannot assign requested address if the path is wrong in vosk.Model(path) in streamlit #62

Open mohammedi-haroune opened 3 years ago

mohammedi-haroune commented 3 years ago

Describe the bug

I noticed a bug when using cdsdashboards in our ML platform https://iko.ai

OSError: [Errno 99] Cannot assign requested address is returned both in the browser and the logs if the path is wrong in vosk.Model(path) in a streamlit app

It first shows the right error:

INFO:tornado.application:Process mainprocess failed with stdout: 2021-04-14 08:55:47.238 An update   to the [server] config option section was detected. To have these changes be reflected, please       restart streamlit.
LOG (VoskAPI:ReadDataFiles():model.cc:196) Decoding params beam=13 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:199) Silence phones 1:2:3:4:5:6:7:8:9:10
ERROR (VoskAPI:ReadConfigFile():parse-options.cc:462) Cannot open config file: makach-menha/mfcc.conf
terminate called after throwing an instance of 'kaldi::KaldiFatalError'
  what():  kaldi::KaldiFatalError

Then it keeps showing this weird error both in the browser and the logs

HTTPServerRequest(protocol='http', host='172.17.0.1', method='GET', uri='/notebook/jupyter/user/     haroune/iko-streamlit-bug/stream', version='HTTP/1.1', remote_ip='172.17.0.1')
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/tornado/tcpclient.py", line 138, in on_connect_done
    stream = future.result()
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/tornado/web.py", line 1704, in _execute
    result = await result
  File "/opt/conda/lib/python3.8/site-packages/jhsingle_native_proxy/websocket.py", line 105, in get
    return await self.ws_get(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/jhsingle_native_proxy/proxyhandlers.py", line 339, in ws_get
    await self._ws_open_proxy('localhost', self.port, path)
  File "/opt/conda/lib/python3.8/site-packages/jhsingle_native_proxy/proxyhandlers.py", line 413, in _ws_open_proxy
    self.ws = await pingable_ws_connect(request=request,
  File "/opt/conda/lib/python3.8/site-packages/tornado/iostream.py", line 1205, in connect
    self.socket.connect(address)
OSError: [Errno 99] Cannot assign requested address

Also, this happened only once, the streamlit UI opened and keeps rerunning the app forever and show an error pop every now and then. I couldn't take a screenshot of the error in the streamlit UI because it was too fast.

To Reproduce

model = Model('wrong/path/')


**Screenshots**
<!-- Please add screenshots to help explain your problem. -->
![Screenshot-20210414100015-3072x1728](https://user-images.githubusercontent.com/23096288/114685511-d9d7d800-9d09-11eb-9793-f1d17c97f004.png)

**Configuration**
<!-- Include as much jupyterhub_config information as you can - at least enough to understand which Spawner type you are using, and how your JupyterHub is deployed (e.g. The Littlest JupyterHub, or Zero to JupyterHub). -->
```python
from cdsdashboards.app import CDS_TEMPLATE_PATHS
from cdsdashboards.hubextension import cds_extra_handlers

c.JupyterHub.template_paths = CDS_TEMPLATE_PATHS
c.JupyterHub.extra_handlers = cds_extra_handlers

c.JupyterHub.allow_named_servers = True
c.CDSDashboardsConfig.builder_class = 'cdsdashboards.builder.kubebuilder.KubeBuilder'

# # Add `start.sh` to switch to NB_USER before running the command
c.VariableMixin.default_presentation_cmd = ['start.sh', 'python3', '-m', 'jhsingle_native_proxy.main']

# Options to remove Named Server / Dashboard sections for users on their home page. 
# You can remove the named server section and/or the new bottom section where 
# servers started to act as dashboards are hidden.
c.JupyterHub.template_vars = {
    'cds_hide_user_named_servers': True,
    'cds_hide_user_dashboard_servers': False,
}

# Specify how to name dashbaord servers
c.CDSDashboardsConfig.server_name_template = 'iko-{urlname}'

# Control whether ‘All Users’ or ‘Selected Users’ is selected by default on the ‘New Dashboard’ page.
c.CDSDashboardsConfig.default_allow_all = False

# Show Spawner User Options Form before creating a dashboard
c.CDSDashboardsConfig.spawn_default_options = False

c.CDSDashboardsConfig.presentation_types = ['voila', 'streamlit', 'plotlydash', 'bokeh']

from cdsdashboards.hubextension.spawners.variablekube import VariableKubeSpawner

class CustomKubeSpawner(VariableKubeSpawner):
    "Our custom KubeSpawner implementation"
    pass

c.JupyterHub.spawner_class = CustomKubeSpawner
mohammedi-haroune commented 3 years ago

Here's the full logs: vosk_bug.log

danlester commented 3 years ago

What happens if you run this in Streamlit locally, i.e. just on your laptop say?

And I presume if you use the right path the app works fine?

mohammedi-haroune commented 3 years ago

What happens if you run this in Streamlit locally, i.e. just on your laptop say?

The app logs the error and exit.

> streamlit run streamlit_app-wrong-input-path.py 

  You can now view your Streamlit app in your browser.

  Network URL: http://10.4.1.17:8501
  External URL: http://34.123.120.237:8501

LOG (VoskAPI:ReadDataFiles():model.cc:194) Decoding params beam=13 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:197) Silence phones 1:2:3:4:5:6:7:8:9:10
ERROR (VoskAPI:ReadConfigFile():parse-options.cc:462) Cannot open config file: /tmp/vosk-model-ar-mgb2-0.4/mfcc.conf
terminate called after throwing an instance of 'kaldi::KaldiFatalError'
  what():  kaldi::KaldiFatalError
Aborted

And I presume if you use the right path the app works fine?

Yes.