Skip to content

Commit 283f9aa

Browse files
committed
Move file read logic into function
1 parent a5f7a50 commit 283f9aa

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

src/ol_infrastructure/applications/jupyterhub/__main__.py

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

3-
from pathlib import Path
4-
53
from pulumi import Config, StackReference
64
from pulumi_aws import ec2
75

@@ -157,8 +155,9 @@
157155
)
158156
jupyterhub_db = OLAmazonDB(jupyterhub_db_config)
159157

158+
# Use same physical DB instance
160159
jupyterhub_authoring_db_config = OLPostgresDBConfig(
161-
instance_name=f"jupyterhub-db-{stack_info.env_suffix}", # Use same physical DB instance
160+
instance_name=f"jupyterhub-db-{stack_info.env_suffix}",
162161
password=rds_password,
163162
subnet_group_name=target_vpc["rds_subnet"],
164163
security_groups=[jupyterhub_db_security_group],
@@ -183,24 +182,6 @@
183182
cluster_stack.require_output("namespaces").apply(
184183
lambda ns, namespace=namespace: check_cluster_namespace(namespace, ns)
185184
)
186-
# Need to decide if this is the best way to handle
187-
# these overrides/revisit values merged into helm charts
188-
# Can pull into function and remove params
189-
menu_override = (
190-
Path(__file__)
191-
.parent.joinpath(deployment_config["menu_override_file"])
192-
.read_text()
193-
)
194-
disabled_extensions = (
195-
Path(__file__)
196-
.parent.joinpath(deployment_config["disabled_extension_file"])
197-
.read_text()
198-
)
199-
dynamic_image_config = (
200-
Path(__file__)
201-
.parent.joinpath(deployment_config["extra_config_file"])
202-
.read_text()
203-
)
204185
jupyterhub_deployment = provision_jupyterhub_deployment(
205186
stack_info=stack_info,
206187
jupyterhub_deployment_config=deployment_config,
@@ -211,7 +192,4 @@
211192
application_labels=application_labels,
212193
k8s_global_labels=k8s_global_labels,
213194
extra_images=EXTRA_IMAGES,
214-
menu_override_json=menu_override,
215-
disabled_extensions_json=disabled_extensions,
216-
extra_config=dynamic_image_config,
217195
)

src/ol_infrastructure/applications/jupyterhub/deployment.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,30 @@ def provision_jupyterhub_deployment( # noqa: PLR0913
4949
application_labels: dict[str, str],
5050
k8s_global_labels: dict[str, str],
5151
extra_images: dict[str, dict[str, str]] | None = None,
52-
menu_override_json: str | None = None,
53-
disabled_extensions_json: str | None = None,
54-
extra_config: str | None = None,
5552
) -> kubernetes.helm.v3.Release:
5653
base_name = jupyterhub_deployment_config["name"]
5754
domain_name = jupyterhub_deployment_config["domain"]
5855
namespace = jupyterhub_deployment_config["namespace"]
5956
env_name = f"{stack_info.env_suffix}"
6057
db_name_normalized = base_name.replace("-", "_")
6158

59+
# Read configuration files from paths in deployment config
60+
menu_override_json = (
61+
Path(__file__)
62+
.parent.joinpath(jupyterhub_deployment_config["menu_override_file"])
63+
.read_text()
64+
)
65+
disabled_extensions_json = (
66+
Path(__file__)
67+
.parent.joinpath(jupyterhub_deployment_config["disabled_extension_file"])
68+
.read_text()
69+
)
70+
extra_config = (
71+
Path(__file__)
72+
.parent.joinpath(jupyterhub_deployment_config["extra_config_file"])
73+
.read_text()
74+
)
75+
6276
# Derive common configuration values
6377
apisix_ingress_class = (
6478
jupyterhub_deployment_config.get("apisix_ingress_class") or "apisix"

0 commit comments

Comments
 (0)