diff --git a/roles/jupyterhub/defaults/main.yml b/roles/jupyterhub/defaults/main.yml index d21dee55..c32cf873 100644 --- a/roles/jupyterhub/defaults/main.yml +++ b/roles/jupyterhub/defaults/main.yml @@ -24,6 +24,13 @@ jupyterhub_config: spawner: start_timeout: 180 # seconds +jupyterhub_profiles: + - default: + display_name: default + options: + req_memory: "2" + req_nprocs: "1" + jupyterhub_services: dask_gateway: CStgn1NN8DogQR1KajuoQfye1qNRqx6zsh diff --git a/roles/jupyterhub/templates/environments/dashboards.yaml b/roles/jupyterhub/templates/environments/dashboards.yaml index 42ab5b90..f39320b0 100644 --- a/roles/jupyterhub/templates/environments/dashboards.yaml +++ b/roles/jupyterhub/templates/environments/dashboards.yaml @@ -16,6 +16,6 @@ dependencies: - voila >= 0.2.7 - streamlit >= 0.76 - dash >= 1.19 + - batchspawner==1.3.0 - pip: - - git+https://github.com/jupyterhub/batchspawner.git - jhub-apps==2024.2.1rc1 diff --git a/roles/jupyterhub/templates/environments/jupyterhub.yaml b/roles/jupyterhub/templates/environments/jupyterhub.yaml index 44feee4d..ac0668a9 100644 --- a/roles/jupyterhub/templates/environments/jupyterhub.yaml +++ b/roles/jupyterhub/templates/environments/jupyterhub.yaml @@ -9,11 +9,12 @@ dependencies: - escapism==1.0.1 - jupyterhub-idle-culler==1.2.1 - sqlalchemy==1.4.46 + - batchspawner==1.3.0 - pip: - nebari_jupyterhub_theme==2023.4.1 - python-keycloak==0.26.1 - jupyterhub-traefik-proxy==1.1.0 # jupyterhub-ssh has not made a release yet - git+https://github.com/yuvipanda/jupyterhub-ssh.git - - git+https://github.com/jupyterhub/batchspawner.git + - git+https://github.com/jupyterhub/wrapspawner.git - jhub-apps==2024.2.1rc1 diff --git a/roles/jupyterhub/templates/environments/jupyterlab.yaml b/roles/jupyterhub/templates/environments/jupyterlab.yaml index 93c8ae94..3c7d0fbf 100644 --- a/roles/jupyterhub/templates/environments/jupyterlab.yaml +++ b/roles/jupyterhub/templates/environments/jupyterlab.yaml @@ -44,6 +44,7 @@ dependencies: - black - isort - importnb + - batchspawner==1.3.0 - pip: # vscode jupyterlab launcher diff --git a/roles/jupyterhub/templates/jupyterhub_config.py b/roles/jupyterhub/templates/jupyterhub_config.py index 9001c6ea..3cf195f8 100644 --- a/roles/jupyterhub/templates/jupyterhub_config.py +++ b/roles/jupyterhub/templates/jupyterhub_config.py @@ -144,68 +144,6 @@ async def _get_batch_script(self, **subvars): # Could be overridden by subclasses, but mainly useful for testing return format_template(self.batch_script, **subvars) - - - -{% if jupyterhub_qhub_options_form %} - # data from form submission is {key: [value]} - # we need to convert the formdata to a key value dict - def options_from_form(self, data): - return {key: value[0] for key, value in data.items()} - - main_options_form = f''' -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- ''' - - conda_options_form = f''' - {% raw %} -
- -
- -
-
- {% endraw %} - ''' - - def options_form(self, spawner): - ## Not currently working - idea is to omit conda env from spawner form - ## for dashboards, since already selected a conda env - #if spawner.orm_spawner.user_options and 'presentation_type' in spawner.orm_spawner.user_options: - # self.log.info("In options_form") - # if spawner.user_options['presentation_type']: - # return self.main_options_form # Omit the conda env dropdown since that is chosen per dashboard - - # Display full form including conda env dropdown - return ''.join([self.main_options_form, self.conda_options_form]) -{% endif %} - # Assign Qhub Spawner class QHubHPCSpawner(QHubHPCSpawnerBase): pass @@ -216,7 +154,7 @@ class QHubHPCSpawner(QHubHPCSpawnerBase): c.JupyterHub.template_paths = [] c.JupyterHub.extra_handlers = [] -c.JupyterHub.spawner_class = QHubHPCSpawner +c.JupyterHub.spawner_class = 'wrapspawner.ProfilesSpawner' c.SlurmSpawner.start_timeout = {{ jupyterhub_config.spawner.start_timeout }} c.QHubHPCSpawner.default_url = '/lab' @@ -224,6 +162,7 @@ class QHubHPCSpawner(QHubHPCSpawnerBase): # default values for batch spawner c.QHubHPCSpawner.req_memory = '1' # GB c.QHubHPCSpawner.req_nprocs = '1' +c.QHubHPCSpawner.req_partition = 'general' c.QHubHPCSpawner.req_conda_environment_prefix = '{{ miniforge_home }}/envs/{{ jupyterhub_lab_environment | basename | splitext | first }}' c.QHubHPCSpawner.req_prologue = ''' # ensure user has link to the shared directory, if it exists @@ -312,6 +251,24 @@ def generate_batch_script(spawner): c.QHubHPCSpawner.batch_script = generate_batch_script +USER_PROFILES = {{ jupyterhub_profiles | tojson }} + +def set_profiles(user_profiles: list): + """Set the profiles for the ProfilesSpawner.""" + profiles = [] + for profile_dict in user_profiles: + profile_name, profile_data = next(iter(profile_dict.items())) + profiles.append(( + profile_data['display_name'], + profile_name, + QHubHPCSpawner, + dict(**profile_data['options']) + )) + return profiles + + +# User profiles +c.ProfilesSpawner.profiles = set_profiles(USER_PROFILES) # ===== adding api tokens for external services ======= c.JupyterHub.services = [ diff --git a/roles/miniforge/defaults/main.yml b/roles/miniforge/defaults/main.yml index c14e94d7..d6f65874 100644 --- a/roles/miniforge/defaults/main.yml +++ b/roles/miniforge/defaults/main.yml @@ -1,7 +1,7 @@ --- miniforge_enabled: false -miniforge_version: 4.11.0-0 -miniforge_sha256: 49268ee30d4418be4de852dda3aa4387f8c95b55a76f43fb1af68dcbf8b205c3 +miniforge_version: 23.11.0-0 +miniforge_sha256: 3dfdcc162bf0df83b5025608dc2acdbbc575bd416b75701fb5863343c0517a78 miniforge_home: /opt/conda miniforge_envs: - /opt/conda/envs/