nebari-dev / jhub-apps

Application creator and general launcher for JupyterHub
https://jhub-apps.nebari.dev/
BSD 3-Clause "New" or "Revised" License
27 stars 12 forks source link

Having trouble installing and using jhub-apps in TLJH #409

Open tsi-rnguyen opened 4 months ago

tsi-rnguyen commented 4 months ago

Context

I have installed the latest TLJH on a Ubuntu instance and have been trying to install jhub-apps into it following the instructions provided in the readme. And it appears to spawn the API docs on port 10202 but not the actual jhub-apps on port 8000. I don't see any particular errors in the journalctl that would indicate a start issue. Is there something I am missing?

I have jhub-apps installed for both /opt/tljh/hub and /opt/tljh/user.

Jul 23 17:17:34 TSFV-NEBARI systemd[1]: Started jupyterhub.service. Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.688 JupyterHub app:2885] Running JupyterHub version 4.1.5 Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.689 JupyterHub app:2915] Using Authenticator: oauthenticator.generic.GenericOAuthenticator-16.3.1 Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.689 JupyterHub app:2915] Using Spawner: jhub_apps.spawner.spawner_creation.JHubSpawner Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.689 JupyterHub app:2915] Using Proxy: jupyterhub_traefik_proxy.fileprovider.TraefikFileProviderProxy-1.1.0 Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.699 JupyterHub app:1683] Loading cookie_secret from /opt/tljh/state/jupyterhub_cookie_secret Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [W 2024-07-23 17:17:35.778 JupyterHub configurable:214] Config option userdata_method not recognized by GenericOAuthenticator. Did you mean one of: userdata_params, userdata_token_method, userdata_url? Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.784 JupyterHub app:2005] Not using allowed_users. Any authenticated user will be allowed. Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.813 JupyterHub provider:662] Updating oauth client service-japps Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.854 JupyterHub fileprovider:99] Creating the dynamic configuration file: /opt/tljh/state/rules/rules.toml Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.873 JupyterHub app:2954] Initialized 0 spawners in 0.020 seconds Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.879 JupyterHub metrics:279] Found 2 active users in the last ActiveUserPeriods.twenty_four_hours Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.880 JupyterHub metrics:279] Found 2 active users in the last ActiveUserPeriods.seven_days Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.880 JupyterHub metrics:279] Found 2 active users in the last ActiveUserPeriods.thirty_days Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.881 JupyterHub app:3168] Not starting proxy Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.884 JupyterHub app:3204] Hub API listening on http://127.0.0.1:15001/hub/ Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.884 JupyterHub app:3215] Starting managed service cull-idle Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.884 JupyterHub service:386] Starting service 'cull-idle': ['/opt/tljh/hub/bin/python3', '-m', 'jupyterhub_idle_culler', '--timeout=600', '--cull-every=60', '--concurrency=5', '--max-age=0'] Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.885 JupyterHub service:134] Spawning /opt/tljh/hub/bin/python3 -m jupyterhub_idle_culler --timeout=600 --cull-every=60 --concurrency=5 --max-age=0 Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.891 JupyterHub app:3215] Starting managed service japps at http://127.0.0.1:10202 Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.891 JupyterHub service:386] Starting service 'japps': ['python3', '-m', 'uvicorn', 'jhub_apps.service.app:app', '--port=10202', '--host=0.0.0.0', '--workers=2'] Jul 23 17:17:35 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:35.893 JupyterHub service:134] Spawning python3 -m uvicorn jhub_apps.service.app:app --port=10202 --host=0.0.0.0 --workers=2 Jul 23 17:17:36 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:36.013 JupyterHub log:192] 200 GET /hub/api/ (cull-idle@127.0.0.1) 13.10ms Jul 23 17:17:36 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:36.022 JupyterHub log:192] 200 GET /hub/api/users?state=[secret] (cull-idle@127.0.0.1) 7.72ms Jul 23 17:17:36 TSFV-NEBARI python3[22206]: INFO: Uvicorn running on http://0.0.0.0:10202 (Press CTRL+C to quit) Jul 23 17:17:36 TSFV-NEBARI python3[22206]: INFO: Started parent process [22206] Jul 23 17:17:36 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:36.792 JupyterHub log:192] 200 GET /hub/api (@127.0.0.1) 0.73ms Jul 23 17:17:37 TSFV-NEBARI python3[22210]: INFO: Started server process [22210] Jul 23 17:17:37 TSFV-NEBARI python3[22210]: INFO: Waiting for application startup. Jul 23 17:17:37 TSFV-NEBARI python3[22210]: INFO: Application startup complete. Jul 23 17:17:37 TSFV-NEBARI python3[22209]: INFO: Started server process [22209] Jul 23 17:17:37 TSFV-NEBARI python3[22209]: INFO: Waiting for application startup. Jul 23 17:17:37 TSFV-NEBARI python3[22209]: INFO: Application startup complete. Jul 23 17:17:37 TSFV-NEBARI python3[22209]: INFO: 127.0.0.1:52602 - "GET /services/japps/ HTTP/1.1" 200 OK Jul 23 17:17:37 TSFV-NEBARI python3[22198]: [I 2024-07-23 17:17:37.715 JupyterHub app:3273] JupyterHub is now running, internal Hub API at http://127.0.0.1:15001/hub/

Value and/or benefit

tljh integration usage

Anything else?

No response

aktech commented 3 months ago

Hey @tsi-rnguyen thanks for reporting this. I have a few questions:

  1. What does your jupyterhub_config.py looks like
  2. What does your environment look like?

What do you see on jupyterhub's home page?

tsi-rnguyen commented 3 months ago

Hey @tsi-rnguyen thanks for reporting this. I have a few questions:

  1. What does your jupyterhub_config.py looks like
  2. What does your environment look like?

What do you see on jupyterhub's home page?

My config file is pretty basic, all I've configured was https, oauth, and attempted to install jhub-apps.

This is the base TLJH jupyterhub_config.py

> import os
> from glob import glob
> 
> from tljh import configurer
> from tljh.config import CONFIG_DIR, INSTALL_PREFIX, USER_ENV_PREFIX
> from tljh.user_creating_spawner import UserCreatingSpawner
> from tljh.utils import get_plugin_manager
> 
> c = get_config()  # noqa
> c.JupyterHub.spawner_class = UserCreatingSpawner
> 
> c.JupyterHub.cleanup_servers = False
> 
> 
> c.JupyterHub.hub_port = 15001
> 
> c.TraefikProxy.should_start = False
> 
> dynamic_conf_file_path = os.path.join(INSTALL_PREFIX, "state", "rules", "rules.toml")
> c.TraefikFileProviderProxy.dynamic_config_file = dynamic_conf_file_path
> c.JupyterHub.proxy_class = "traefik_file"
> 
> c.SystemdSpawner.extra_paths = [os.path.join(USER_ENV_PREFIX, "bin")]
> c.SystemdSpawner.default_shell = "/bin/bash"
>
> c.SystemdSpawner.unit_name_template = "jupyter-{USERNAME}"
> 
> tljh_config = configurer.load_config()
> configurer.apply_config(tljh_config, c)
> 
> 
> pm = get_plugin_manager()
> pm.hook.tljh_custom_jupyterhub_config(c=c)
> 
> extra_configs = sorted(glob(os.path.join(CONFIG_DIR, "jupyterhub_config.d", "*.py")))
> for ec in extra_configs:
>     load_subconfig(ec)

I have extended that config with the below:

from tljh.user_creating_spawner import UserCreatingSpawner
from jhub_apps.configuration import install_jhub_apps

c.JupyterHub.bind_url = "https://<hosted url>"
c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{JHUBSERVERNAME}'
c.JAppsConfig.apps_auth_type = "oauth" #  oauth or none (if you don't want authentication on apps)
c.JAppsConfig.python_exec = "python3"
c.JAppsConfig.jupyterhub_config_path = "jupyterhub_config.py"
c.JAppsConfig.conda_envs = []
c = install_jhub_apps(c, UserCreatingSpawner)

c.NotebookApp.tornado_settings = {"websocket_max_message_size": 100 * 1024 * 1024}

In addition here is my config.yaml

users:
  admin:
  - admin
Jupyterhub:
  base_url: <info has been removed>
https:
  enabled: true
  tls:
    key: <info has been removed>
    cert: <info has been removed>
auth:
  type: oauthenticator.generic.GenericOAuthenticator
  GenericOAuthenticator:
    <info has been removed>
hub:
  db:
    upgrade: true

Below is the packages installed inn /opt/tljh/hub/

Package                          Version
-------------------------------- --------------
aiohttp                          3.9.5
aiosignal                        1.3.1
alembic                          1.13.2
annotated-types                  0.7.0
anyio                            4.4.0
argon2-cffi                      23.1.0
argon2-cffi-bindings             21.2.0
arrow                            1.3.0
asttokens                        2.4.1
async-generator                  1.10
async-lru                        2.0.4
async-timeout                    4.0.3
attrs                            23.2.0
Babel                            2.15.0
backcall                         0.2.0
backoff                          2.2.1
backports.tarfile                1.2.0
bcrypt                           4.2.0
beautifulsoup4                   4.12.3
bleach                           6.1.0
bokeh                            3.1.1
bokeh-root-cmd                   0.1.2
cachetools                       5.4.0
certifi                          2024.7.4
certipy                          0.1.3
cffi                             1.16.0
charset-normalizer               3.3.2
click                            8.1.7
comm                             0.2.2
contourpy                        1.1.1
cryptography                     43.0.0
debugpy                          1.8.2
decorator                        5.1.1
defusedxml                       0.7.1
distlib                          0.3.8
dnspython                        2.6.1
email_validator                  2.2.0
escapism                         1.0.1
exceptiongroup                   1.2.2
executing                        2.0.1
fastapi                          0.111.1
fastapi-cli                      0.0.4
fastjsonschema                   2.20.0
filelock                         3.15.4
fqdn                             1.5.1
frozenlist                       1.4.1
greenlet                         3.0.3
h11                              0.14.0
hatch                            1.12.0
hatchling                        1.25.0
httpcore                         1.0.5
httptools                        0.6.1
httpx                            0.27.0
hyperlink                        21.0.0
idna                             3.7
importlib_metadata               8.2.0
importlib_resources              6.4.0
ipykernel                        6.29.5
ipython                          8.12.3
ipywidgets                       8.1.3
isoduration                      20.11.0
jaraco.classes                   3.4.0
jaraco.context                   5.3.0
jaraco.functools                 4.0.1
jedi                             0.19.1
jeepney                          0.8.0
jhsingle-native-proxy            0.8.2
jhub-apps                        2024.6.1
Jinja2                           3.1.4
json5                            0.9.25
jsonpointer                      3.0.0
jsonschema                       4.23.0
jsonschema-specifications        2023.12.1
jupyter                          1.0.0
jupyter_client                   8.6.2
jupyter-console                  6.6.3
jupyter_core                     5.7.2
jupyter-events                   0.10.0
jupyter-lsp                      2.2.5
jupyter_server                   2.14.2
jupyter_server_terminals         0.5.3
jupyter-telemetry                0.1.0
jupyterhub                       4.1.5
jupyterhub-firstuseauthenticator 1.0.0
jupyterhub-idle-culler           1.3.1
jupyterhub-ldapauthenticator     1.3.2
jupyterhub-nativeauthenticator   1.2.0
jupyterhub-systemdspawner        1.0.1
jupyterhub-tmpauthenticator      1.0.0
jupyterhub-traefik-proxy         1.1.0
jupyterlab                       4.2.4
jupyterlab_pygments              0.3.0
jupyterlab_server                2.27.3
jupyterlab_widgets               3.0.11
keyring                          25.2.1
ldap3                            2.9.1
linkify-it-py                    2.0.3
Mako                             1.3.5
Markdown                         3.6
markdown-it-py                   3.0.0
MarkupSafe                       2.1.5
matplotlib-inline                0.1.7
mdit-py-plugins                  0.4.1
mdurl                            0.1.2
mistune                          3.0.2
more-itertools                   10.3.0
multidict                        6.0.5
nbclient                         0.10.0
nbconvert                        7.16.4
nbformat                         5.10.4
nest-asyncio                     1.6.0
notebook                         7.2.1
notebook_shim                    0.2.4
numpy                            1.24.4
oauthenticator                   16.3.1
oauthlib                         3.2.2
onetimepass                      1.0.1
overrides                        7.7.0
packaging                        24.1
pamela                           1.1.0
pandas                           2.0.3
pandocfilters                    1.5.1
panel                            1.2.3
param                            2.1.1
parso                            0.8.4
passlib                          1.7.4
pathspec                         0.12.1
pexpect                          4.9.0
pickleshare                      0.7.5
pillow                           10.4.0
pip                              24.2
pkg_resources                    0.0.0
pkgutil_resolve_name             1.3.10
platformdirs                     4.2.2
plotlydash-tornado-cmd           0.0.6
pluggy                           1.5.0
prometheus_client                0.20.0
prompt_toolkit                   3.0.47
psutil                           6.0.0
ptyprocess                       0.7.0
pure_eval                        0.2.3
pyasn1                           0.6.0
pycparser                        2.22
pycurl                           7.45.2
pydantic                         2.8.2
pydantic_core                    2.20.1
Pygments                         2.18.0
PyJWT                            2.8.0
pyOpenSSL                        24.2.1
python-dateutil                  2.9.0.post0
python-dotenv                    1.0.1
python-json-logger               2.0.7
python-multipart                 0.0.9
python-slugify                   8.0.4
pytz                             2024.1
pyviz_comms                      3.0.2
PyYAML                           6.0.1
pyzmq                            26.0.3
qtconsole                        5.5.2
QtPy                             2.4.1
referencing                      0.35.1
requests                         2.32.3
rfc3339-validator                0.1.4
rfc3986-validator                0.1.1
rich                             13.7.1
rpds-py                          0.19.1
ruamel.yaml                      0.17.40
ruamel.yaml.clib                 0.2.8
SecretStorage                    3.3.3
Send2Trash                       1.8.3
setuptools                       44.0.0
shellingham                      1.5.4
simpervisor                      0.4
six                              1.16.0
sniffio                          1.3.1
soupsieve                        2.5
SQLAlchemy                       2.0.31
stack-data                       0.6.3
starlette                        0.37.2
structlog                        24.4.0
terminado                        0.18.1
text-unidecode                   1.3
the-littlest-jupyterhub          1.0.0
tinycss2                         1.3.0
toml                             0.10.2
tomli                            2.0.1
tomli_w                          1.0.0
tomlkit                          0.13.0
tornado                          6.4.1
tqdm                             4.66.4
traitlets                        5.14.3
trove-classifiers                2024.7.2
typer                            0.12.3
types-python-dateutil            2.9.0.20240316
typing_extensions                4.12.2
tzdata                           2024.1
uc-micro-py                      1.0.3
uri-template                     1.3.0
urllib3                          2.2.2
userpath                         1.9.2
uv                               0.2.30
uvicorn                          0.30.3
uvloop                           0.19.0
virtualenv                       20.26.3
watchfiles                       0.22.0
wcwidth                          0.2.13
webcolors                        24.6.0
webencodings                     0.5.1
websocket-client                 1.8.0
websockets                       12.0
widgetsnbextension               4.0.11
xyzservices                      2024.6.0
yarl                             1.9.4
zipp                             3.19.2
zstandard                        0.23.0

and lastly all I see on my jupyterhub home:

image

stefanseefeld commented 3 months ago

@aktech, any insights from the above logs / configs ?

stefanseefeld commented 3 months ago

ping ? If there is nothing to be learned from the above data, any ideas how to debug this ?

BardiaKh commented 3 months ago

I am currently facing the same issue with TLJH. It seems that the japps_service is running and if you go there you see the jhub apps api. I think the problem is that I cannot find the home page to set the apps.

aktech commented 3 months ago

Thanks for the config, taking a quick look at it, it seems you're missing (it's not documented):

from jhub_apps import theme_template_paths
c.JupyterHub.template_paths = theme_template_paths
c.JupyterHub.default_url = "/hub/home"
c.JAppsConfig.jupyterhub_config_path = "path/to/your/jupyterhub_config.py" # or something like str(Path(__file__).resolve())

Let me know if doesn't works. I'll to reproduce the config and will get back to you guys. I just came back from PTO today :)

BardiaKh commented 3 months ago

Thanks for the response. It is going a step further now. It now redirects the traffic to: services/japps/jhub-login. But that page cannot be reached:

INFO:     xx.xx.xxx.xxx:0 - "GET /services/japps/spawner-profiles/ HTTP/1.1" 403 Forbidden
INFO:     xx.xx.xxx.xxx:0 - "GET /services/japps/user HTTP/1.1" 403 Forbidden
INFO:     xx.xx.xxx.xxx:0 - "GET /services/japps/jhub-login HTTP/1.1" 302 Found
Aug 07 23:54:27 ip-xx-xx-xxx-xxx python3[5236]: 2024-08-07 23:54:27,435      INFO jhub_apps.service.routes:  90: event='Logging in' view=None peer=None request=<starlette.requests.Request object at 0x7cef0d101130> request_id='d45d34ad-bf9a-4507-a4d6-466b73cd48ea'

Here is my jupyterhub_config.py file content:

from tljh.user_creating_spawner import UserCreatingSpawner
from jhub_apps.configuration import install_jhub_apps
from jhub_apps import theme_template_paths
from pathlib import Path

c.JupyterHub.bind_url = "http://<hosted url>"
c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{JHUBSERVERNAME}'
c.JupyterHub.template_paths = theme_template_paths
c.JupyterHub.default_url = "/hub/home"
c.JAppsConfig.apps_auth_type = "oauth" #  oauth or none (if you don't want authentication on apps)
c.JAppsConfig.python_exec = "python3"
c.JAppsConfig.jupyterhub_config_path = "jupyterhub_config.py"
c.JAppsConfig.conda_envs = []
c = install_jhub_apps(c, UserCreatingSpawner)

c.JAppsConfig.jupyterhub_config_path = str(Path(__file__).resolve())

UPDATE: Apparently in the

https://github.com/nebari-dev/jhub-apps/blob/f298b2e6d58d0ec7a2d673d581aff3a11cbdf820/jhub_apps/service/routes.py#L88-L95

Per JHub docs, there should be a &redirect_uri=/hub/home/.

BardiaKh commented 3 months ago

@aktech Would appreciate if you have any update / advice regarding this issue.

aktech commented 3 months ago

I just deployed a fresh TLJH and created a file named config.py at /opt/tljh/config/jupyterhub_config.d/config.py, with following contents.

from tljh.user_creating_spawner import UserCreatingSpawner
from jhub_apps.configuration import install_jhub_apps
from jhub_apps import theme_template_paths
from pathlib import Path

c.JupyterHub.bind_url = "http://192.168.50.37"
c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{JHUBSERVERNAME}'
c.JAppsConfig.apps_auth_type = "oauth" # or none (if you don't want authentication on apps)
c.JAppsConfig.python_exec = "python3"
# Pass in the path to jupyterhub config
c.JAppsConfig.jupyterhub_config_path = str(Path(__file__).resolve())
# Either a static list of conda environments to show in the
# create panel apps form or a callable to fetch conda enviornments
# dynamically, e.g. from conda-store API
c.JAppsConfig.conda_envs = []
c = install_jhub_apps(c, UserCreatingSpawner)

c.JupyterHub.template_paths = theme_template_paths
c.JupyterHub.default_url = "/hub/home"

I was able to access the jhub-apps and deploy a panel app:

Screenshot 2024-08-18 at 10 00 13 pm

The logo didn't loaded by default, which we need to fix.

Per JHub docs, there should be a &redirect_uri=/hub/home/.

I'll take a look and get that fixed.

It is going a step further now. It now redirects the traffic to: services/japps/jhub-login. But that page cannot be reached:

@BardiaKh What do you see in the UI and the network tab, can you share a screenhot?

seidlr commented 2 months ago

I've installed TLJH locally using docker as described here: https://tljh.jupyter.org/en/latest/contributing/dev-setup.html Then I created a conda env, installed all dependencies, and created a config.py file as you described

from tljh.user_creating_spawner import UserCreatingSpawner
from jhub_apps.configuration import install_jhub_apps
from jhub_apps import theme_template_paths
from pathlib import Path

c.JupyterHub.bind_url = "http://127.0.0.1:12000"
c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{JHUBSERVERNAME}'
c.JAppsConfig.apps_auth_type = "oauth" # or none (if you don't want authentication on apps)
c.JAppsConfig.python_exec = "python3"
# Pass in the path to jupyterhub config
c.JAppsConfig.jupyterhub_config_path = str(Path(__file__).resolve())
# Either a static list of conda environments to show in the
# create panel apps form or a callable to fetch conda enviornments
# dynamically, e.g. from conda-store API
c.JAppsConfig.conda_envs = []
c = install_jhub_apps(c, UserCreatingSpawner)

c.JupyterHub.template_paths = theme_template_paths
c.JupyterHub.default_url = "/hub/home"

I can start JupyterLab without issues, and I can see the new Hub Control panel, but when i try to create a streamlit app it seems to time out and there is an error "Undefined has no properties". The app is created twice and still shown in the Control Panel but it is not able to run. When I start it the status goes back to "Pending"

grafik

Any idea what is going wrong? Thanks a lot.

aktech commented 2 months ago

I can start JupyterLab without issues, and I can see the new Hub Control panel, but when i try to create a streamlit app

I assume you do have streamlit in your environment? Can you please share your environment?

The app is created twice and still shown in the Control Panel but it is not able to run.

This might be a bug which should have been fixed in the latest release, what version of jhub-apps are you running?

seidlr commented 2 months ago

Thanks for the tipps. I reinstalled everything and i can create streamlit dashboards now if I install everything in /opt/tljh/user. There are still two issues: 1) Conda envs

2) Dashboards are not shared I created a second user but the app is not shown for him. How can I share the app with all users or a group of them? grafik

Thanks a lot!

seidlr commented 1 month ago

@aktech Could you help please?