From b0877f98be033a06af161dc01df9e4b595b508db Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 8 Jan 2024 23:12:09 +0000 Subject: [PATCH] Send user to conda env callable --- jhub_apps/service/routes.py | 4 +++- jhub_apps/service/utils.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jhub_apps/service/routes.py b/jhub_apps/service/routes.py index 913434f2..b9147bd1 100644 --- a/jhub_apps/service/routes.py +++ b/jhub_apps/service/routes.py @@ -229,7 +229,9 @@ async def get_frameworks(user: User = Depends(get_current_user)): async def conda_environments(user: User = Depends(get_current_user)): logging.info(f"Getting conda environments for user: {user}") config = get_jupyterhub_config() - conda_envs = get_conda_envs(config) + hclient = HubClient() + user_from_service = hclient.get_user(user.name) + conda_envs = get_conda_envs(config, user_from_service) logger.info(f"Found conda environments: {conda_envs}") return conda_envs diff --git a/jhub_apps/service/utils.py b/jhub_apps/service/utils.py index d5370670..a014ee96 100644 --- a/jhub_apps/service/utils.py +++ b/jhub_apps/service/utils.py @@ -24,7 +24,7 @@ def get_jupyterhub_config(): return config -def get_conda_envs(config): +def get_conda_envs(config, user): """This will extract conda environment from the JupyterHub config""" if isinstance(config.JAppsConfig.conda_envs, list): return config.JAppsConfig.conda_envs @@ -33,7 +33,7 @@ def get_conda_envs(config): elif callable(config.JAppsConfig.conda_envs): try: logger.info("JAppsConfig.conda_envs is a callable, calling now..") - return config.JAppsConfig.conda_envs() + return config.JAppsConfig.conda_envs(user) except Exception as e: logger.exception(e) return []