jtpio / jupyterlab-system-monitor

JupyterLab extension to display system metrics
BSD 3-Clause "New" or "Revised" License
299 stars 30 forks source link

The top bar recently stopped working. TypeError: object Future can't be used in 'await' expression #42

Closed anigmo97 closed 1 year ago

anigmo97 commented 4 years ago

Hi everyone, I have been using this extension for two weeks and everything went fine but suddenly it stopped working.

Because of the browser errors and the logs I would say that you cannot get any metrics.

Can somebody help me?

My versions are:

jupyter-client                   6.1.7       
jupyter-core                     4.6.3       
jupyterhub                       1.0.0       
jupyterlab                       2.2.8           
jupyterlab-pygments              0.1.2       
jupyterlab-server                1.2.0       
nbclient                         0.5.0       
nbconvert                        5.6.1       
nbdime                           2.1.0       
nbformat                         5.0.7       
nbresuse                         0.3.6       
notebook                         6.1.4       
widgetsnbextension               3.5.1

Checking my jupyterlab extensions all seems fine:

jupyter labextension list
JupyterLab v2.2.8
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @jupyterlab/git v0.22.0  enabled  OK
        jupyterlab-system-monitor v0.6.0  enabled  OK
        jupyterlab-topbar-extension v0.5.0  enabled  OK
        nbdime-jupyterlab v2.0.1  enabled  OK

Checking Jupyterlab logs:

[E 2020-10-15 07:12:40.564 SingleUserNotebookApp log:174] 500 GET /user/user3/metrics (user3@127.0.0.1) 10.20ms
[E 2020-10-15 07:12:41.294 SingleUserNotebookApp web:1621] Uncaught exception GET /user/user3/metrics (127.0.0.1)
    HTTPServerRequest(protocol='http', host='192.168.1.44:8000', method='GET', uri='/user/user3/metrics', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.6/site-packages/tornado/web.py", line 1543, in _execute
        result = yield result
      File "/opt/conda/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
        value = future.result()
      File "/opt/conda/lib/python3.6/site-packages/nbresuse/api.py", line 49, in get
        cpu_percent = await self._get_cpu_percent(all_processes)
    TypeError: object Future can't be used in 'await' expression

Checking the browser logs : image

jtpio commented 4 years ago

Thanks @anigmo97.

Looks like it is an issue with nbresuse which is used to retrieve the metrics.

michalrudko commented 4 years ago

I've just installed the extension and I am experiencing same issue - I see only separators in the bar but no actual metrics. Is there something that can be done to resolve it or it's a bigger issue with some dependencies? I am using JL 2.1.5 (running in virtual environment).

anigmo97 commented 4 years ago

I've just installed the extension and I am experiencing same issue - I see only separators in the bar but no actual metrics. Is there something that can be done to resolve it or it's a bigger issue with some dependencies? I am using JL 2.1.5 (running in virtual environment).

Hi, the problem seems to be related only with the CPU usage.

If you change this in jupyter_notebook_config.py

c.NotebookApp.ResourceUseDisplay.track_cpu_percent = False

You will be able to see the RAM usage bar

michalrudko commented 4 years ago

I've just installed the extension and I am experiencing same issue - I see only separators in the bar but no actual metrics. Is there something that can be done to resolve it or it's a bigger issue with some dependencies? I am using JL 2.1.5 (running in virtual environment).

Hi, the problem seems to be related only with the CPU usage.

If you change this in jupyter_notebook_config.py

c.NotebookApp.ResourceUseDisplay.track_cpu_percent = False

You will be able to see the RAM usage bar

Thanks for a quick reply! Is this something I can configure in JupyterHub config as well? (this is a multiuser environment, sessions are spawned based on jupyterhub_config.py)

anigmo97 commented 4 years ago

I've just installed the extension and I am experiencing same issue - I see only separators in the bar but no actual metrics. Is there something that can be done to resolve it or it's a bigger issue with some dependencies? I am using JL 2.1.5 (running in virtual environment).

Hi, the problem seems to be related only with the CPU usage. If you change this in jupyter_notebook_config.py

c.NotebookApp.ResourceUseDisplay.track_cpu_percent = False

You will be able to see the RAM usage bar

Thanks for a quick reply! Is this something I can configure in JupyterHub config as well? (this is a multiuser environment, sessions are spawned based on jupyterhub_config.py)

Hello, yes this can be configured also using jupyterHub.

I'm also using jupyterHub.

I'm not an expert, but i let you what i understood.

First we have to differents configuration files:

  1. jupyterhub_config.py (for jupyter_hub).
  2. jupyter_notebook_config.py (at jupyter_notebook level). This file must be on jupyter path (like /usr/local/etc/jupyter/jupyter_notebook_config.py).

So, this extension settings must be on jupyter_notebook_config.py As example, my /usr/local/etc/jupyter/jupyter_notebook_config.py file looks like:

c = get_config()

# memoryand cpu display settings
c.NotebookApp.ResourceUseDisplay.mem_limit = int(3 * 1024 * 1024 * 1024)
c.NotebookApp.ResourceUseDisplay.track_cpu_percent = False
c.NotebookApp.ResourceUseDisplay.cpu_limit = 3
# 10 % free memory
c.NotebookApp.ResourceUseDisplay.mem_warning_threshold = 0.1

And my jupyterhub_config.py looks like:

c.JupyterHub.port = 8000
c.Spawner.default_url = '/lab'
...

I hope it helps

jtpio commented 1 year ago

Closing as jupyterlab-system-monitor has now been integrated in jupyter-resource-usage: https://github.com/jupyter-server/jupyter-resource-usage/issues/191

Feel free to open a new issue on the jupyter-resource-usage repo if needed: https://github.com/jupyter-server/jupyter-resource-usage

Thanks!