Skip to content

Commit

Permalink
Expose jupyter's preferred dir as a config option (#2251)
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski authored Feb 19, 2024
1 parent d50539c commit 32f62f8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/_nebari/stages/kubernetes_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class IdleCuller(schema.Base):
class JupyterLab(schema.Base):
idle_culler: IdleCuller = IdleCuller()
initial_repositories: typing.List[typing.Dict[str, str]] = []
preferred_dir: typing.Optional[str] = None


class InputSchema(schema.Base):
Expand Down Expand Up @@ -363,6 +364,9 @@ class JupyterhubInputVars(schema.Base):
argo_workflows_enabled: bool = Field(alias="argo-workflows-enabled")
jhub_apps_enabled: bool = Field(alias="jhub-apps-enabled")
cloud_provider: str = Field(alias="cloud-provider")
jupyterlab_preferred_dir: typing.Optional[str] = Field(
alias="jupyterlab-preferred-dir"
)


class DaskGatewayInputVars(schema.Base):
Expand Down Expand Up @@ -501,6 +505,7 @@ def input_vars(self, stage_outputs: Dict[str, Dict[str, Any]]):
argo_workflows_enabled=self.config.argo_workflows.enabled,
jhub_apps_enabled=self.config.jhub_apps.enabled,
initial_repositories=str(self.config.jupyterlab.initial_repositories),
jupyterlab_preferred_dir=self.config.jupyterlab.preferred_dir,
)

dask_gateway_vars = DaskGatewayInputVars(
Expand Down
7 changes: 7 additions & 0 deletions src/_nebari/stages/kubernetes_services/template/jupyterhub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ variable "jupyterlab-profiles" {
description = "JupyterHub profiles to expose to user"
}

variable "jupyterlab-preferred-dir" {
description = "Directory in which the JupyterLab should open the file browser"
type = string
}

variable "initial-repositories" {
description = "Map of folder location and git repo url to clone"
type = string
Expand Down Expand Up @@ -144,4 +149,6 @@ module "jupyterhub" {

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

jupyterlab-preferred-dir = var.jupyterlab-preferred-dir
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ locals {
kernel_cull_connected = var.idle-culler-settings.kernel_cull_connected ? "True" : "False" # for Python compatible boolean values
kernel_cull_busy = var.idle-culler-settings.kernel_cull_busy ? "True" : "False" # for Python compatible boolean values
server_shutdown_no_activity_timeout = var.idle-culler-settings.server_shutdown_no_activity_timeout
jupyterlab_preferred_dir = var.jupyterlab-preferred-dir != null ? var.jupyterlab-preferred-dir : ""
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
c.ContentsManager.allow_hidden = True
c.FileContentsManager.allow_hidden = True

# Set the preferred path for the frontend to start in
preferred_dir = ${jupyterlab_preferred_dir}
c.FileContentsManager.preferred_dir = preferred_dir if preferred_dir else None

# Timeout (in seconds) in which a terminal has been inactive and ready to
# be culled.
c.TerminalManager.cull_inactive_timeout = ${terminal_cull_inactive_timeout} * 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ variable "jupyterlab-pioneer-log-format" {
type = string
}

variable "jupyterlab-preferred-dir" {
description = "Directory in which the JupyterLab should open the file browser"
type = string
}

variable "cloud-provider" {
description = "Name of cloud provider."
type = string
Expand Down

0 comments on commit 32f62f8

Please sign in to comment.