Skip to content

Commit

Permalink
Merge branch 'upgrade-on-users-behalf' of /~https://github.com/nebari-d…
Browse files Browse the repository at this point in the history
…ev/nebari into upgrade-on-users-behalf
  • Loading branch information
marcelovilla committed Jun 26, 2024
2 parents 0d8350f + fd67b94 commit 88a1549
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 2 deletions.
21 changes: 21 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,25 @@ class IdleCuller(schema.Base):
server_shutdown_no_activity_timeout: int = 15


class JupyterLabGalleryExhibit(schema.Base):
git: str
title: str
homepage: Optional[str] = None
description: Optional[str] = None
icon: Optional[str] = None
account: Optional[str] = None
token: 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 +385,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 +554,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
19 changes: 19 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,23 @@ 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
title = string
homepage = optional(string)
description = optional(string)
icon = optional(string)
account = optional(string)
token = optional(string)
}))
})
}

variable "jupyterhub-hub-extraEnv" {
description = "Extracted overrides to merge with jupyterhub.hub.extraEnv"
type = string
Expand Down Expand Up @@ -149,6 +166,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,13 @@ resource "local_file" "jupyter_jupyterlab_pioneer_config_py" {
}
}

resource "local_sensitive_file" "jupyter_gallery_config_json" {
content = jsonencode({
"GalleryManager" = 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 All @@ -70,7 +77,8 @@ resource "kubernetes_config_map" "etc-ipython" {
locals {
etc-jupyter-config-data = merge(
{
"jupyter_server_config.py" = local_file.jupyter_server_config_py.content,
"jupyter_server_config.py" = local_file.jupyter_server_config_py.content,
"jupyter_gallery_config.json" = local_sensitive_file.jupyter_gallery_config_json.content,
},
var.jupyterlab-pioneer-enabled ? {
# quotes are must here, as terraform would otherwise think py is a property of
Expand All @@ -89,7 +97,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_sensitive_file.jupyter_gallery_config_json
]

metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ 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
title = string
homepage = optional(string)
description = optional(string)
icon = optional(string)
account = optional(string)
token = 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
homepage: /~https://github.com/nebari-dev/nebari
description: 🪴 Nebari - your open source data science platform

0 comments on commit 88a1549

Please sign in to comment.