ideonate / cdsdashboards

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

sudospawner voila issue #76

Closed fdion closed 3 years ago

fdion commented 3 years ago

Describe the bug Trying to save a dashboard with voila and the call to voila is not quite right. python3 should be full path to jupyterhub environment, and --progressive needs an argument, it appears.

To Reproduce This was set up as a sudospawner jupyterhub install and conda environments. Everything works as expected, in use for months on this particular server. Added cdsdashboards to the jupyterhub environment and cdsdashboards[user] to each conda data science environments (registered through ipykernel).

Screenshots

Log shows:

[I 210628 22:55:14 mediator:89] Spawning /usr/bin/jupyterhub-singleuser --destport=0 python3 '{-}m' voila '{presentation_path}' '{--}port={port}' '{--}no-browser' '{--}Voila.base_url={base_url}/' '{--}Voila.server_url=/' --progressive --presentation-path=./notebooks/testing/dash --port=53703
usage: jupyterhub-singleuser [-h] [--debug] [--generate-config] [-y]
                             [--no-browser] [--no-mathjax] [--allow-root]
                             [--autoreload] [--script] [--no-script]
                             [--disable-user-config]
                             [--log-level Application.log_level]
                             [--config JupyterApp.config_file]
                             [--ip SingleUserNotebookApp.ip]
                             [--port SingleUserNotebookApp.port]
                             [--port-retries SingleUserNotebookApp.port_retries]
                             [--sock SingleUserNotebookApp.sock]
                             [--sock-mode SingleUserNotebookApp.sock_mode]
                             [--transport KernelManager.transport]
                             [--keyfile SingleUserNotebookApp.keyfile]
                             [--certfile SingleUserNotebookApp.certfile]
                             [--client-ca SingleUserNotebookApp.client_ca]
                             [--notebook-dir SingleUserNotebookApp.notebook_dir]
                             [--browser SingleUserNotebookApp.browser]
                             [--pylab [SingleUserNotebookApp.pylab]]
                             [--gateway-url GatewayClient.url]
                             [--user SingleUserNotebookApp.user]
                             [--group SingleUserNotebookApp.group]
                             [--cookie-name HubOAuth.cookie_name]
                             [--hub-prefix SingleUserNotebookApp.hub_prefix]
                             [--hub-host SingleUserNotebookApp.hub_host]
                             [--hub-api-url SingleUserNotebookApp.hub_api_url]
                             [--base-url SingleUserNotebookApp.base_url]
                             [extra_args ...]
jupyterhub-singleuser: error: argument --progressive: expected one argument

Configuration

c.JupyterHub.spawner_class = 'cdsdashboards.hubextension.spawners.variablesudospawner.VariableSudoSpawner'

c.JupyterHub.allow_named_servers = True

c.CDSDashboardsConfig.builder_class = 'cdsdashboards.builder.processbuilder.ProcessBuilder'

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
fdion commented 3 years ago

I commented out --progressive, it now complains about --presentation-path=... as unrecognized arguments.

I don't see anything else in the logs

danlester commented 3 years ago

It shouldn't be running jupyterhub-singleuser at all. The dashboard servers should be running jhsingle_native_proxy (the default command is python3 -m jhsingle_native_proxy.main) instead:

https://github.com/ideonate/cdsdashboards/blob/0a3f7de0c722f041e75cb12133f16c4701a8ccaf/cdsdashboards/hubextension/spawners/variablemixin.py#L107

Are you sure there isn't some other configuration that's somehow overriding that?

Having said that, sudospawner isn't something I've come across often - it's possible that something is wrong even with the default setup, maybe depending on other aspects of your JupyterHub.

Definitely, your comments about --progressive etc won't be relevant since these arguments aren't being passed to the right command anyway!

jupyterhub-singleuser should be run for regular Jupyter servers; the 'variable spawners' should override to use jhsingle_native_proxy for dashboard servers.

I hope this helps you debug a bit further...

fdion commented 3 years ago

Yes, it is a bit strange. I've been using sudospawner for quite a while, on different sites. I set things up with ansible, so I don't forget steps. Basically, I just replaced spawner_class from sudospawner.SudoSpawner to cdsdashboards.hubextension.spawners.variablesudospawner.VariableSudoSpawner and it definitely runs that code. But why it doesn't set the right default_presentation_cmd, not sure yet. I was hoping it was a "oh yeah, we see this all the time and you have to..." situation. Guess it's time to step through the code...

fdion commented 3 years ago

VariableSudoSpawner runs sudospawner start, and that calls spawner.do. The spawner executable is set here:

https://github.com/jupyterhub/sudospawner/blob/f1e841e6d8698ac1793975c2860571c42a36b811/sudospawner/spawner.py#L68

This is set to whatever sudospawner is in the path (/usr/bin/sudospawner)

This will run mediator.main which will call jupyterhub-singleuser:

https://github.com/jupyterhub/sudospawner/blob/f1e841e6d8698ac1793975c2860571c42a36b811/sudospawner/mediator.py#L173

Trying to understand how this should work... It doesn't look like there is a way to do this due to mediator... Has anybody had success with the sudospawner to date?

Unlike sudospawner, the systemd spawner does look at self.cmd, so I can see how that would work:

https://github.com/jupyterhub/systemdspawner/blob/ee566d5989ca004bc6f4a3bf5a0a7cd332da2e90/systemdspawner/systemdspawner.py#L295

fdion commented 3 years ago

@danlester I've found that without significant changes to sudospawner, the instructions at: https://cdsdashboards.readthedocs.io/en/stable/chapters/setup/otherspawners.html#sudospawner cannot work. I've played around modifying the kwargs payload to the mediator process in sudospawner, but it is too complicated / brittle at this point, so I'm moving on to a different approach for right now. FYI, @minrk, @willingc, @parente

obearn-archidev commented 3 years ago

88 Tries to fix the spawner with no changes in sudospawner