diff --git a/docs/customize.md b/docs/customize.md index d9cc7cc49..954ec5ade 100644 --- a/docs/customize.md +++ b/docs/customize.md @@ -639,3 +639,21 @@ By using the [layout customization system](https://jupyterlab.readthedocs.io/en/ } } ``` + +## Custom kernel_spec_manager class + +By default, VoilĂ  uses `jupyter_client`'s KernelSpecManager. To change this class, add the following to your config like so: + +```py +import CustomKernelSpecManager + +c.VoilaConfiguration.kernel_spec_manager_class = CustomKernelSpecManager +``` + +## Kernel startup_timeout + +By default, VoilĂ 's grace period for kernel startup time is 60 seconds. It can be adjusted as such, in seconds + +```sh +voila --VoilaExecutor.startup_timeout=60 +``` diff --git a/voila/app.py b/voila/app.py index 4c015b78c..78a49c5e3 100644 --- a/voila/app.py +++ b/voila/app.py @@ -168,7 +168,7 @@ class Voila(Application): "template": "VoilaConfiguration.template", "theme": "VoilaConfiguration.theme", "classic_tree": "VoilaConfiguration.classic_tree", - "kernel_spec_manager_class": "VoilaConfiguration.kernel_spec_manager_class" + "kernel_spec_manager_class": "VoilaConfiguration.kernel_spec_manager_class", } classes = [VoilaConfiguration, VoilaExecutor, VoilaExporter] connection_dir_root = Unicode( @@ -544,7 +544,9 @@ def init_settings(self) -> Dict: # default server_url to base_url self.server_url = self.server_url or self.base_url - self.kernel_spec_manager = self.voila_configuration.kernel_spec_manager_class(parent=self) + self.kernel_spec_manager = self.voila_configuration.kernel_spec_manager_class( + parent=self + ) # we create a config manager that load both the serverconfig and nbconfig (classical notebook) read_config_path = [ diff --git a/voila/configuration.py b/voila/configuration.py index 422eab931..03ba6a44e 100644 --- a/voila/configuration.py +++ b/voila/configuration.py @@ -163,7 +163,7 @@ def _valid_file_blacklist(self, proposal): default_value="jupyter_client.kernelspec.KernelSpecManager", klass="jupyter_client.kernelspec.KernelSpecManager", help="""The kernel spec manager class. Allows for setting a custom kernel spec manager for finding and running kernels - """ + """, ) http_header_envs = List( diff --git a/voila/execute.py b/voila/execute.py index 1e584116e..6071725ee 100644 --- a/voila/execute.py +++ b/voila/execute.py @@ -10,7 +10,7 @@ from nbclient.client import NotebookClient from nbclient.exceptions import CellExecutionError from nbconvert.preprocessors.clearoutput import ClearOutputPreprocessor -from traitlets import Bool, Unicode +from traitlets import Bool, Unicode, Integer def strip_code_cell_warnings(cell): @@ -50,6 +50,18 @@ class VoilaExecutor(NotebookClient): help=("Whether to send tracebacks to clients on exceptions."), ) + startup_timeout: int = Integer( + 60, + config=True, + help=( + """ + The time to wait (in seconds) for the kernel to start. + If kernel startup takes longer, a RuntimeError is + raised. + """ + ), + ) + def execute(self, nb, resources, km=None): try: result = super().execute()