Skip to content

Commit

Permalink
Merge pull request #55 from nebari-dev/user-for-conda-envs
Browse files Browse the repository at this point in the history
Send user to conda env callable
  • Loading branch information
aktech authored Jan 9, 2024
2 parents 63c1151 + b0877f9 commit 810013c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion jhub_apps/service/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions jhub_apps/service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 []
Expand Down

0 comments on commit 810013c

Please sign in to comment.