Skip to content

Commit

Permalink
Added startup_timeout config
Browse files Browse the repository at this point in the history
  • Loading branch information
castrom authored and castrom committed Oct 3, 2023
1 parent 1828fca commit 5ecb996
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
14 changes: 14 additions & 0 deletions docs/customize.md
Expand Up @@ -639,3 +639,17 @@ 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
6 changes: 4 additions & 2 deletions voila/app.py
Expand Up @@ -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(
Expand Down Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion voila/configuration.py
Expand Up @@ -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(
Expand Down
14 changes: 13 additions & 1 deletion voila/execute.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5ecb996

Please sign in to comment.