From 90a591e7711fadef4c4b0ccc8ace74b411bc1157 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Thu, 15 Jun 2023 10:16:00 +0200 Subject: [PATCH 1/4] Use partial --- voila/notebook_renderer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index 57ae2d72b..ec9863283 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -11,6 +11,7 @@ import os import sys import traceback +from functools import partial from typing import Generator, List, Tuple, Union import nbformat @@ -150,8 +151,7 @@ def generate_content_generator( kernel_id: Union[str, None] = None, kernel_future=None, ) -> Generator: - async def inner_kernel_start(nb): - return await self._jinja_kernel_start(nb, kernel_id, kernel_future) + inner_kernel_start = partial(self._jinja_kernel_start, kernel_id=kernel_id, kernel_future=kernel_future) def inner_cell_generator(nb, kernel_id): return self._jinja_cell_generator(nb, kernel_id) From 3e2d108ee3a6a3b088856bfbd9d1fe08680bbd77 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 08:21:42 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- voila/notebook_renderer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index ec9863283..e8d03771c 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -151,7 +151,9 @@ def generate_content_generator( kernel_id: Union[str, None] = None, kernel_future=None, ) -> Generator: - inner_kernel_start = partial(self._jinja_kernel_start, kernel_id=kernel_id, kernel_future=kernel_future) + inner_kernel_start = partial( + self._jinja_kernel_start, kernel_id=kernel_id, kernel_future=kernel_future + ) def inner_cell_generator(nb, kernel_id): return self._jinja_cell_generator(nb, kernel_id) From 75a8b216276974bcbd8ddfe12bb7fbd31c20fd6e Mon Sep 17 00:00:00 2001 From: David Brochart Date: Thu, 15 Jun 2023 10:33:02 +0200 Subject: [PATCH 3/4] Remove unneeded inner_cell_generator function --- voila/notebook_renderer.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index e8d03771c..f3e5f2bf6 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -155,9 +155,6 @@ def generate_content_generator( self._jinja_kernel_start, kernel_id=kernel_id, kernel_future=kernel_future ) - def inner_cell_generator(nb, kernel_id): - return self._jinja_cell_generator(nb, kernel_id) - # These functions allow the start of a kernel and execution of the # notebook after (parts of) the template has been rendered and send # to the client to allow progressive rendering. @@ -168,7 +165,7 @@ def inner_cell_generator(nb, kernel_id): "frontend": "voila", "main_js": "voila.js", "kernel_start": inner_kernel_start, - "cell_generator": inner_cell_generator, + "cell_generator": self._jinja_cell_generator, "notebook_execute": self._jinja_notebook_execute, } # render notebook in snippets, then return an iterator so we can flush From f730ed7d5514a44375b5841a2812ef96f14bfa34 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Thu, 15 Jun 2023 10:42:40 +0200 Subject: [PATCH 4/4] Change comments a bit --- voila/notebook_renderer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index f3e5f2bf6..c2b392d36 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -155,11 +155,11 @@ def generate_content_generator( self._jinja_kernel_start, kernel_id=kernel_id, kernel_future=kernel_future ) - # These functions allow the start of a kernel and execution of the - # notebook after (parts of) the template has been rendered and send + # kernel_start and cell_generator allow starting the kernel and executing the + # notebook after (parts of) the template has been rendered and sent # to the client to allow progressive rendering. # Template should first call kernel_start, and then decide to use - # notebook_executer cell_generator to implement progressive cell rendering + # notebook_executer cell_generator to implement progressive cell rendering. extra_context = { "frontend": "voila",