ideonate / cdsdashboards

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

jupyterhub_config with tljh doesn't work #91

Closed raybellwaves closed 2 years ago

raybellwaves commented 2 years ago

Describe the bug Followed instructions here https://cdsdashboards.readthedocs.io/en/stable/chapters/setup/tljh.html#changes-to-jupyterhub-config-py On reloading jupyterhub I get a Bad Gateway which crashes the instance

To Reproduce sudo vi /opt/tljh/config/jupyterhub_config.d/cdsdashboards_config.py

# Replacement for UserCreatingSpawner (a simple extension of SystemdSpawner) - The Littlest JupyterHub's default spawner
c.JupyterHub.spawner_class = 'cdsdashboards.hubextension.spawners.variableusercreating.VariableUserCreatingSpawner'

c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{DASHSERVERNAME}'

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

then sudo tljh-config reload

Screenshots

Configuration

jupyterhub 1.5.0 jupyterhub-base 2.0.1 jupyterlab 3.2.5 jupyterhub-traefik-proxy 0.3.0 cdsdashboards-singleuser 0.6.0

See also https://gitter.im/ideonate/ContainDS

raybellwaves commented 2 years ago

Sorry for noise. Got it to work https://github.com/raybellwaves/tljh-plugin/blob/main/tljh_plugin.py

ScissorHill commented 2 years ago

I'm facing an identical issue to the OP. What is a bit surprising is that following the steps in the TLJH setup documentation causes sudo tljh-config reload to hang, leading to the Bad Gateway message. @raybellwaves' solution is perhaps a bit intimidating to a novice user such as myself.

@danlester: Could you please suggest a workaround?

I did a bit more digging and found that the commented lines below from /opt/tljh/config/jupyterhub_config.d/cdsdashboards_config.py cause sudo tljh-config reload to hang:

#c.JupyterHub.spawner_class = 'cdsdashboards.hubextension.spawners.variableusercreating.VariableUserCreatingSpawner'

c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{DASHSERVERNAME}'

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

Configuration: jupyterhub 1.5.0 the-littlest-jupyterhub==0.1 jupyterhub-traefik-proxy==0.3.0 cdsdashboards==0.6.2

dealmeida-h commented 1 year ago

I also had the same issues. It seems the Hub environment uses the system python3 as default, and in my case, this was python3.6 (which ships with Ubuntu 18.04). I tried to install a newer version of python 3 (3.9.15), but then the launch script won't work:

Traceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 8, in <module>
    from CommandNotFound.db.creator import DbCreator
ModuleNotFoundError: No module named 'CommandNotFound'
Fetched 4,439 B in 1s (3,467 B/s)
Reading package lists...
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code

Traceback (most recent call last):
  File "<stdin>", line 473, in <module>
  File "<stdin>", line 416, in main
  File "<stdin>", line 162, in run_subprocess
subprocess.CalledProcessError: Command '['apt-get', 'update']' returned non-zero exit status 100.

Running the quoted strings from @ScissorHill in python 3.9 works (like in the user env), but in python 3.6 it throws the "cannot import name 'Callable':

>>> from cdsdashboards.hubextension import cds_extra_handlers
/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/crypto.py:17: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
  import cryptography
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/tljh/hub/lib/python3.6/site-packages/cdsdashboards/hubextension/__init__.py", line 8, in <module>
    from .main import AllDashboardsHandler, DashboardEditHandler, MainViewDashboardHandler, ClearErrorDashboardHandler, \
  File "/opt/tljh/hub/lib/python3.6/site-packages/cdsdashboards/hubextension/main.py", line 9, in <module>
    from .base import DashboardBaseMixin, check_database_upgrade, spawner_to_dict
  File "/opt/tljh/hub/lib/python3.6/site-packages/cdsdashboards/hubextension/base.py", line 15, in <module>
    from ..app import BuildersStore, CDSConfigStore
  File "/opt/tljh/hub/lib/python3.6/site-packages/cdsdashboards/app.py", line 10, in <module>
    from traitlets import Unicode, Integer, Bool, Dict, validate, Any, default, observe, List, TraitError, Union, Callable
ImportError: cannot import name 'Callable'

@raybellwaves , I see that your code installs a lot of apt, pip and conda packages. Do you think this is what solved the issue for you?

Thanks.