Skip to content

Commit

Permalink
make spawner fetching async
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Jan 6, 2024
1 parent 7036b6d commit 5418612
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion jhub_apps/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ async def conda_environments(user: User = Depends(get_current_user)):
async def spawner_profiles(user: User = Depends(get_current_user)):
logging.info("Getting spawner profiles")
config = get_jupyterhub_config()
spawner_profiles_ = get_spawner_profiles(config)
spawner_profiles_ = await get_spawner_profiles(config)
logger.info(f"Loaded spawner profiles: {config}")
return spawner_profiles_


Expand Down
10 changes: 5 additions & 5 deletions jhub_apps/service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def get_jupyterhub_config():
os.environ["PROXY_API_SERVICE_PORT"] = "*"
os.environ["HUB_SERVICE_PORT"] = "*"
jhub_config_file_path = os.environ["JHUB_JUPYTERHUB_CONFIG"]
print(f"Getting JHub config from file: {jhub_config_file_path}")
logger.info(f"Getting JHub config from file: {jhub_config_file_path}")
hub.load_config_file(jhub_config_file_path)
config = hub.config
print(f"JHub config from file: {config}")
print(f"JApps config: {config.JAppsConfig}")
logger.info(f"JHub config from file: {config}")
logger.info(f"JApps config: {config.JAppsConfig}")
return config


Expand All @@ -44,7 +44,7 @@ def get_conda_envs(config):
)


def get_spawner_profiles(config):
async def get_spawner_profiles(config):
"""This will extract spawner profiles from the JupyterHub config
If the Spawner is KubeSpawner
"""
Expand All @@ -56,7 +56,7 @@ def get_spawner_profiles(config):
elif callable(profile_list):
try:
logger.info("config.KubeSpawner.profile_list is a callable, calling now..")
return profile_list()
return await profile_list()
except Exception as e:
logger.exception(e)
return []
Expand Down

0 comments on commit 5418612

Please sign in to comment.