Skip to content

Commit

Permalink
Implement support for jupyterlab-gallery config
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jun 4, 2024
1 parent 2bac8aa commit 46e0072
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/_nebari/stages/kubernetes_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,23 @@ class IdleCuller(schema.Base):
server_shutdown_no_activity_timeout: int = 15


class JupyterLabGalleryExhibit(schema.Base):
git: str
repository: str
title: str
description: str
icon: Optional[str] = None


class JupyterLabGallerySettings(schema.Base):
title: str = "Examples"
destination: str = "examples"
exhibits: List[JupyterLabGalleryExhibit] = []


class JupyterLab(schema.Base):
default_settings: Dict[str, Any] = {}
gallery_settings: JupyterLabGallerySettings = JupyterLabGallerySettings()
idle_culler: IdleCuller = IdleCuller()
initial_repositories: List[Dict[str, str]] = []
preferred_dir: Optional[str] = None
Expand Down Expand Up @@ -368,6 +383,9 @@ class JupyterhubInputVars(schema.Base):
jupyterlab_default_settings: Dict[str, Any] = Field(
alias="jupyterlab-default-settings"
)
jupyterlab_gallery_settings: JupyterLabGallerySettings = Field(
alias="jupyterlab-gallery-settings"
)
initial_repositories: str = Field(alias="initial-repositories")
jupyterhub_overrides: List[str] = Field(alias="jupyterhub-overrides")
jupyterhub_stared_storage: str = Field(alias="jupyterhub-shared-storage")
Expand Down Expand Up @@ -534,6 +552,7 @@ def input_vars(self, stage_outputs: Dict[str, Dict[str, Any]]):
jhub_apps_enabled=self.config.jhub_apps.enabled,
initial_repositories=str(self.config.jupyterlab.initial_repositories),
jupyterlab_default_settings=self.config.jupyterlab.default_settings,
jupyterlab_gallery_settings=self.config.jupyterlab.gallery_settings,
jupyterlab_preferred_dir=self.config.jupyterlab.preferred_dir,
)

Expand Down
17 changes: 17 additions & 0 deletions src/_nebari/stages/kubernetes_services/template/jupyterhub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ variable "jupyterlab-default-settings" {
type = map(any)
}

variable "jupyterlab-gallery-settings" {
description = "Server-side settings for jupyterlab-gallery extension"
type = object({
title = optional(string)
destination = optional(string)
exhibits = list(object({
git = string
repository = string
title = string
description = string
icon = optional(string)
}))
})
}

variable "jupyterhub-hub-extraEnv" {
description = "Extracted overrides to merge with jupyterhub.hub.extraEnv"
type = string
Expand Down Expand Up @@ -149,6 +164,8 @@ module "jupyterhub" {

jupyterlab-default-settings = var.jupyterlab-default-settings

jupyterlab-gallery-settings = var.jupyterlab-gallery-settings

jupyterlab-pioneer-enabled = var.jupyterlab-pioneer-enabled
jupyterlab-pioneer-log-format = var.jupyterlab-pioneer-log-format

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ resource "local_file" "jupyter_jupyterlab_pioneer_config_py" {
}
}

resource "local_file" "jupyter_gallery_config_json" {
content = jsonencode(var.jupyterlab-gallery-settings)
filename = "${path.module}/files/jupyter/jupyter_gallery_config.json"
}


resource "local_file" "overrides_json" {
content = jsonencode(local.jupyterlab-overrides-json-object)
Expand Down Expand Up @@ -89,7 +94,8 @@ locals {
resource "kubernetes_config_map" "etc-jupyter" {
depends_on = [
local_file.jupyter_server_config_py,
local_file.jupyter_jupyterlab_pioneer_config_py
local_file.jupyter_jupyterlab_pioneer_config_py,
local_file.jupyter_gallery_config_json
]

metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ variable "jupyterlab-default-settings" {
type = map(any)
}

variable "jupyterlab-gallery-settings" {
description = "Server-side settings for jupyterlab-gallery extension"
type = object({
title = optional(string)
destination = optional(string)
exhibits = list(object({
git = string
repository = string
title = string
description = string
icon = optional(string)
}))
})
}

variable "jupyterlab-pioneer-enabled" {
description = "Enable JupyterLab Pioneer for telemetry"
type = bool
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project_name: test
jupyterlab:
gallery_settings:
title: Example repositories
destination: examples
exhibits:
- title: Nebari
git: https://github.com/nebari-dev/nebari.git
repository: https://github.com/nebari-dev/nebari
description: 🪴 Nebari - your open source data science platform

0 comments on commit 46e0072

Please sign in to comment.