From ed780b9c0090a6be307b9548de01778128181f1e Mon Sep 17 00:00:00 2001 From: martinRenou Date: Thu, 22 Jun 2023 16:41:05 +0000 Subject: [PATCH 1/4] Backport PR #1334: Do not clean up resources after execution --- voila/notebook_renderer.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index 4a0848cdf..a4d5a3b25 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -252,8 +252,6 @@ async def _jinja_notebook_execute(self, nb, kernel_id): # (it seems to be local to our block) nb.cells = result.cells - await self._cleanup_resources() - async def _jinja_cell_generator(self, nb, kernel_id): """Generator that will execute a single notebook cell at a time""" nb, _ = ClearOutputPreprocessor().preprocess( @@ -303,12 +301,6 @@ async def _jinja_cell_generator(self, nb, kernel_id): finally: yield output_cell - await self._cleanup_resources() - - async def _cleanup_resources(self): - await ensure_async(self.executor.km.cleanup_resources()) - await ensure_async(self.executor.kc.stop_channels()) - async def load_notebook(self, path): model = await ensure_async(self.contents_manager.get(path=path)) From 10e569ab7d085408e7171e26c1fba37c71daeb3d Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 26 Jun 2023 10:10:06 +0200 Subject: [PATCH 2/4] Only clean kernel client --- voila/notebook_renderer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index a4d5a3b25..a2de1ba91 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -252,6 +252,8 @@ async def _jinja_notebook_execute(self, nb, kernel_id): # (it seems to be local to our block) nb.cells = result.cells + await self._cleanup_resources() + async def _jinja_cell_generator(self, nb, kernel_id): """Generator that will execute a single notebook cell at a time""" nb, _ = ClearOutputPreprocessor().preprocess( @@ -301,6 +303,11 @@ async def _jinja_cell_generator(self, nb, kernel_id): finally: yield output_cell + await self._cleanup_resources() + + async def _cleanup_resources(self): + await ensure_async(self.executor.kc.stop_channels()) + async def load_notebook(self, path): model = await ensure_async(self.contents_manager.get(path=path)) From 6961139517a45addf4ee65821a4b863194e2e7b6 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 26 Jun 2023 11:04:52 +0200 Subject: [PATCH 3/4] Fix CI --- .github/workflows/main.yml | 4 ++-- packages/voila/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e6af2d39d..52ad57fed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: - name: Create the conda environment shell: bash -l {0} - run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 flake8 ipywidgets matplotlib xeus-cling openssl=1.1.1l "traitlets>=5.0.3,<6" + run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 flake8 ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" - name: Install dependencies shell: bash -l {0} @@ -82,7 +82,7 @@ jobs: - name: Create the conda environment shell: bash -l {0} - run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 flake8 ipywidgets matplotlib xeus-cling openssl=1.1.1l "traitlets>=5.0.3,<6" + run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov pytest-rerunfailures nodejs yarn=1 flake8 ipywidgets matplotlib xeus-cling "traitlets>=5.0.3,<6" - name: Install dependencies shell: bash -l {0} diff --git a/packages/voila/package.json b/packages/voila/package.json index 2c9ed767d..bedcb4456 100644 --- a/packages/voila/package.json +++ b/packages/voila/package.json @@ -45,9 +45,9 @@ }, "style": "style/index.css", "scripts": { - "build": "npm run build:lib && webpack", + "build": "jlpm run build:lib && webpack", "build:lib": "tsc", - "build:prod": "npm run build:lib && webpack --production", + "build:prod": "jlpm run build:lib && webpack --production", "clean": "jlpm run clean:lib", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "test": "echo \"Error: no test specified\" && exit 1", From cd526d5cfd62f2f91b2bc5016a4ad3724b54f023 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 26 Jun 2023 11:12:27 +0200 Subject: [PATCH 4/4] OpenSSL issue workaround --- packages/jupyterlab-preview/package.json | 1 + packages/jupyterlab-preview/webpack.lab.config.js | 6 ++++++ packages/voila/webpack.config.js | 7 +++++++ 3 files changed, 14 insertions(+) create mode 100644 packages/jupyterlab-preview/webpack.lab.config.js diff --git a/packages/jupyterlab-preview/package.json b/packages/jupyterlab-preview/package.json index a13617cc5..19635570e 100644 --- a/packages/jupyterlab-preview/package.json +++ b/packages/jupyterlab-preview/package.json @@ -72,6 +72,7 @@ }, "jupyterlab": { "extension": true, + "webpackConfig": "webpack.lab.config.js", "schemaDir": "schema", "outputDir": "../../voila/labextension", "discovery": { diff --git a/packages/jupyterlab-preview/webpack.lab.config.js b/packages/jupyterlab-preview/webpack.lab.config.js new file mode 100644 index 000000000..e7a395519 --- /dev/null +++ b/packages/jupyterlab-preview/webpack.lab.config.js @@ -0,0 +1,6 @@ +const crypto = require('crypto'); + +// Workaround for loaders using "md4" by default, which is not supported in FIPS-compliant OpenSSL +const cryptoOrigCreateHash = crypto.createHash; +crypto.createHash = algorithm => + cryptoOrigCreateHash(algorithm === 'md4' ? 'sha256' : algorithm); diff --git a/packages/voila/webpack.config.js b/packages/voila/webpack.config.js index 374574989..104660320 100644 --- a/packages/voila/webpack.config.js +++ b/packages/voila/webpack.config.js @@ -1,5 +1,12 @@ var path = require('path'); +const crypto = require('crypto'); + +// Workaround for loaders using "md4" by default, which is not supported in FIPS-compliant OpenSSL +const cryptoOrigCreateHash = crypto.createHash; +crypto.createHash = algorithm => + cryptoOrigCreateHash(algorithm === 'md4' ? 'sha256' : algorithm); + var rules = [ { test: /\.css$/, use: ['style-loader', 'css-loader'] }, // required to load font-awesome