11import os
22import pathlib
33
4+ from jupyter_core .paths import jupyter_runtime_dir
45from jupyter_server .config_manager import recursive_update
56from jupyter_server .extension .application import ExtensionApp
67from jupyter_server .extension .application import ExtensionAppJinjaMixin
1819from .telemetry .utils import DEFAULT_TEMPLATE_FILES_PATH
1920from .telemetry .utils import get_schema_files
2021from .traits import UnicodeFromEnv
22+ from .utils import get_ssl_cert
2123
2224
2325MODE_CONFIG_PATH = pathlib .Path (__file__ ).parent .joinpath ("config" )
2426
2527
2628class DataStudioJupyterExtensions (ExtensionAppJinjaMixin , ExtensionApp ):
29+ """JupyterLab with Data Studio extensions.
30+
31+ This extension bundles multiple Jupyter server and client extensions to
32+ ship a JupyterLab experience that serves Apple Data Scientists.
33+
34+ The application can be launched by calling:
35+ ```
36+ DataStudioJupyterExtensions.launch_instance()
37+ ```
38+ """
2739
2840 name = "data_studio_jupyter_extensions"
2941 default_url = "/lab"
@@ -32,18 +44,36 @@ class DataStudioJupyterExtensions(ExtensionAppJinjaMixin, ExtensionApp):
3244 template_paths = [str (DEFAULT_TEMPLATE_FILES_PATH )]
3345 static_paths = [str (DEFAULT_STATIC_FILES_PATH )]
3446
47+ # Add configurables to the list of classes displayed
48+ # in the --help.
49+ classes = [NotebookServiceClient , TelemetryBus ]
50+
3551 handlers = handlers
3652
3753 aliases = {"mode" : "DataStudioJupyterExtensions.mode" }
3854
3955 mode = UnicodeFromEnv (
4056 default_value = "local-local" ,
41- help = "The type" ,
57+ help = "The mode describing how/where the application is being launched."
58+ "There are three option, 'local-local', 'local-cluster', or "
59+ "'cluster-cluster'. " ,
4260 name = constants .NOTEBOOK_SERVICE_MODE ,
4361 ).tag (config = True )
4462
4563 mode_config_path = str (MODE_CONFIG_PATH )
4664
65+ ssl_cert_file = UnicodeFromEnv (
66+ name = "DS_SSL_CERT_FILE" ,
67+ help = "The Apple corporate SSL cert file necessary for accessing "
68+ "the Data Platform UI. If not given, this application will try to "
69+ "automatically download a new SSL cert to the Runtime directory." ,
70+ allow_none = True ,
71+ ).tag (config = True )
72+
73+ @default ("ssl_cert_file" )
74+ def _default_ssl_cert_file (self ): # pragma: no cover
75+ return get_ssl_cert (jupyter_runtime_dir ())
76+
4777 # List configurables here.
4878 nbservice_client_class = Type (
4979 default_value = NotebookServiceClient ,
@@ -96,8 +126,7 @@ def initialize_settings(self):
96126
97127 def initialize_configurables (self ):
98128 self .nbservice_client = self .nbservice_client_class .instance (
99- parent = self ,
100- log = self .log ,
129+ parent = self , log = self .log , ssl_cert_file = self .ssl_cert_file
101130 )
102131 self .telemetry_bus = TelemetryBus .instance (
103132 allowed_schemas = ["event.datastudio.jupyter.com/kernel-message" ]
0 commit comments