Skip to content

Commit 4d8f3d4

Browse files
committed
Fix a few things, change override args, pipe in extra_config
1 parent 65dd241 commit 4d8f3d4

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

src/ol_infrastructure/applications/jupyterhub/__main__.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""JupyterHub application deployment for MIT Open Learning."""
22

3+
from pathlib import Path
4+
35
from pulumi import Config, StackReference
46
from pulumi_aws import ec2
57

@@ -60,11 +62,10 @@
6062

6163
# Check namespaces
6264
namespace = "jupyter"
65+
authoring_namespace = "jupyter-authoring"
6366
cluster_stack.require_output("namespaces").apply(
6467
lambda ns: check_cluster_namespace(namespace, ns)
6568
)
66-
67-
authoring_namespace = "jupyter-authoring"
6869
cluster_stack.require_output("namespaces").apply(
6970
lambda ns: check_cluster_namespace(authoring_namespace, ns)
7071
)
@@ -173,6 +174,13 @@
173174
**rds_defaults,
174175
)
175176

177+
menu_override = Path(__file__).parent.joinpath("menu_override.json").read_text()
178+
disabled_extensions = (
179+
Path(__file__).parent.joinpath("disabled_extensions.json").read_text()
180+
)
181+
dynamic_image_config = (
182+
Path(__file__).parent.joinpath("dynamicImageConfig.py").read_text()
183+
)
176184
# Provision main JupyterHub deployment
177185
jupyterhub_deployment = provision_jupyterhub_deployment(
178186
base_name="jupyterhub",
@@ -183,13 +191,21 @@
183191
vault_config=vault_config,
184192
db_config=jupyterhub_db_config,
185193
app_db=jupyterhub_db,
186-
network_stack=network_stack,
187194
cluster_stack=cluster_stack,
188195
application_labels=application_labels,
189196
k8s_global_labels=k8s_global_labels,
190197
extra_images=EXTRA_IMAGES,
198+
menu_override_json=menu_override,
199+
disabled_extensions_json=disabled_extensions,
200+
extra_config=dynamic_image_config,
191201
)
192202

203+
author_menu_override = (
204+
Path(__file__).parent.joinpath("author_menu_override.json").read_text()
205+
)
206+
author_disabled_extensions = (
207+
Path(__file__).parent.joinpath("author_disabled_extensions.json").read_text()
208+
)
193209
# Provision JupyterHub authoring deployment
194210
jupyterhub_authoring_deployment = provision_jupyterhub_deployment(
195211
base_name="jupyterhub-authoring",
@@ -200,11 +216,11 @@
200216
vault_config=vault_config,
201217
db_config=jupyterhub_authoring_db_config,
202218
app_db=jupyterhub_db,
203-
network_stack=network_stack,
204219
cluster_stack=cluster_stack,
205220
application_labels=application_labels,
206221
k8s_global_labels=k8s_global_labels,
207222
extra_images=EXTRA_IMAGES,
208-
menu_override_file="author_menu_override.json",
209-
disabled_extensions_file="author_disabled_extensions.json",
223+
menu_override_json=author_menu_override,
224+
disabled_extensions_json=author_disabled_extensions,
225+
extra_config=dynamic_image_config,
210226
)

src/ol_infrastructure/applications/jupyterhub/deployment.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ def provision_jupyterhub_deployment( # noqa: PLR0913
4646
application_labels: dict[str, str],
4747
k8s_global_labels: dict[str, str],
4848
extra_images: dict[str, dict[str, str]] | None = None,
49-
menu_override_file: str = "menu_override.json",
50-
disabled_extensions_file: str = "disabled_extensions.json",
49+
menu_override_json: str | None = None,
50+
disabled_extensions_json: str | None = None,
51+
extra_config: str | None = None,
5152
) -> kubernetes.helm.v3.Release:
5253
"""Provision a JupyterHub deployment with all required AWS and Kubernetes resources.
5354
@@ -60,17 +61,13 @@ def provision_jupyterhub_deployment( # noqa: PLR0913
6061
stack_info: Stack information from parse_stack()
6162
jupyterhub_config: Pulumi config for jupyterhub
6263
vault_config: Pulumi config for vault
63-
network_stack: Network stack reference
64-
vault_stack: Vault stack reference
6564
cluster_stack: EKS cluster stack reference
66-
aws_config: AWS configuration with tags
6765
application_labels: Labels to apply to Kubernetes resources
6866
k8s_global_labels: Global Kubernetes labels
6967
extra_images: List of extra images to pre-pull (optional)
70-
menu_override_file: Path to menu override JSON file relative to
71-
deployment directory
72-
disabled_extensions_file: Path to disabled extensions JSON file
73-
relative to deployment directory
68+
menu_override_json: JSON contents for menu override Jupyter config
69+
disabled_extensions_json: JSON contents for disabled extensions Jupyter config
70+
extra_config: Extra configuration values to merge into the Helm chart values
7471
7572
Returns:
7673
The JupyterHub Helm release resource
@@ -237,8 +234,7 @@ def provision_jupyterhub_deployment( # noqa: PLR0913
237234
# JupyterHub Helm Release
238235
extra_images_list = extra_images or {}
239236
admin_users_list = jupyterhub_config.get_object("admin_users", default=[])
240-
allowed_users_list = (jupyterhub_config.get_object("allowed_users", default=[]),)
241-
#'jupyterhub-CI-application-helm-release'
237+
allowed_users_list = jupyterhub_config.get_object("allowed_users", default=[])
242238
return kubernetes.helm.v3.Release(
243239
f"{base_name}-{env_name.upper()}-application-helm-release",
244240
kubernetes.helm.v3.ReleaseArgs(
@@ -327,11 +323,7 @@ def provision_jupyterhub_deployment( # noqa: PLR0913
327323
.read_text(),
328324
}
329325
},
330-
"extraConfig": {
331-
"dynamicImageConfig.py": Path(__file__)
332-
.parent.joinpath("dynamicImageConfig.py")
333-
.read_text()
334-
},
326+
"extraConfig": {"dynamicImageConfig.py": extra_config},
335327
"config": {
336328
"Authenticator": {
337329
"admin_users": admin_users_list,
@@ -377,17 +369,13 @@ def provision_jupyterhub_deployment( # noqa: PLR0913
377369
"mountPath": (
378370
"/opt/conda/share/jupyter/lab/settings/overrides.json"
379371
),
380-
"stringData": Path(__file__)
381-
.parent.joinpath(menu_override_file)
382-
.read_text(),
372+
"stringData": menu_override_json,
383373
},
384374
"disabled_extensions": {
385375
"mountPath": (
386376
"/home/jovyan/.jupyter/labconfig/page_config.json"
387377
),
388-
"stringData": Path(__file__)
389-
.parent.joinpath(disabled_extensions_file)
390-
.read_text(),
378+
"stringData": disabled_extensions_json,
391379
},
392380
},
393381
"image": {

0 commit comments

Comments
 (0)