2i2c-org / jupyter-launcher-shortcuts

Launcher shortcuts for classic Jupyter Notebook & JupyterLab
BSD 3-Clause "New" or "Revised" License
17 stars 11 forks source link

icon_path configuration raises error #10

Closed shberlin closed 4 months ago

shberlin commented 3 years ago

Hello @yuvipanda ,

Thanks for this nice package. Unfortunately I cannot insert a svg icon.

I have used the following versions of your package and extension.

pip install jupyter-launcher-shortcuts==1.0rc1
jupyter labextension install jupyterlab-launcher-shortcuts@2.0.0

As soon as I use the icon_path argument in jupyter_notebook_config.py , an error is raised (without it works fine).

c = get_config()
c.LauncherShortcuts.shortcuts = {
    'MLflow': {
        'title': 'MLFlow',
        'target': "/user/test/proxy/5000/",
        'icon_path': '/home/test/mlflow_icon.svg' # icon does not work
    }
}

The logs give me the following error:

hub_1  | [E 2021-02-04 08:45:21.567 SingleUserNotebookApp web:1789] Uncaught exception GET /user/test/launcher-shortcuts/shortcuts (::ffff:172.24.0.1)
hub_1  |     HTTPServerRequest(protocol='http', host='localhost:8000', method='GET', uri='/user/test/launcher-shortcuts/shortcuts', version='HTTP/1.1', remote_ip='::ffff:172.24.0.1')
hub_1  |     Traceback (most recent call last):
hub_1  |       File "/usr/local/lib/python3.8/dist-packages/tornado/web.py", line 1704, in _execute
hub_1  |         result = await result
hub_1  |       File "/usr/local/lib/python3.8/dist-packages/jupyter_launcher_shortcuts/api.py", line 20, in get
hub_1  |         icon_url = ujoin(self.base_url, 'launcher-shortcuts', 'icon', sp.name)
hub_1  |     NameError: name 'sp' is not defined
hub_1  | [E 2021-02-04 08:45:21.641 SingleUserNotebookApp log:173] {
hub_1  |       "X-Forwarded-Host": "localhost:8000",
hub_1  |       "X-Forwarded-Proto": "http",
hub_1  |       "X-Forwarded-Port": "8000",
hub_1  |       "X-Forwarded-For": "::ffff:172.24.0.1",
hub_1  |       "Cookie": "jupyterhub-user-test=[secret]; _xsrf=[secret]; jupyterhub-session-id=[secret]",
hub_1  |       "Accept-Language": "de,de-DE;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
hub_1  |       "Accept-Encoding": "gzip, deflate, br",
hub_1  |       "Referer": "http://localhost:8000/user/test/lab?",
hub_1  |       "Sec-Fetch-Dest": "empty",
hub_1  |       "Sec-Fetch-Mode": "cors",
hub_1  |       "Sec-Fetch-Site": "same-origin",
hub_1  |       "Accept": "*/*",
hub_1  |       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.56",
hub_1  |       "Connection": "close",
hub_1  |       "Host": "localhost:8000"
hub_1  |     }

So the following line is buggy:

icon_url = ujoin(self.base_url, 'launcher-shortcuts', 'icon', sp.name)

In the history I see that @bsimpson53 has fixed this on 31 May 2020 commenting 'bad var name '.

This change does not seem to have made it into the final package.

shberlin commented 3 years ago

Furthermore, the icon_path is ignored.

The dictionary item does not get the icon_url. Therefore line

icon_url = ujoin(self.base_url, 'launcher-shortcuts', 'icon', sp.name)

needs to be replaced with

icon_url = ujoin(self.base_url, 'launcher-shortcuts', 'icon', ls.name)
item['icon_url'] = icon_url
consideRatio commented 4 months ago

Should now be resolved by https://github.com/2i2c-org/jupyter-launcher-shortcuts/pull/23!

@shberlin great bug report writeup btw!! :heart: :tada: