Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #854 on branch 0.1.x (Fall back to language_info name when searching for kernel) #855

Merged
merged 1 commit into from Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/app/no_metadata.py
@@ -0,0 +1,17 @@
import pytest


@pytest.fixture
def non_existing_notebook_metadata(base_url):
return base_url + "voila/render/no_metadata.ipynb"


@pytest.fixture
def voila_args(notebook_directory, voila_args_extra):
return ['--VoilaTest.root_dir=%r' % notebook_directory] + voila_args_extra


async def test_non_existing_metadata(http_server_client, non_existing_notebook_metadata):
response = await http_server_client.fetch(non_existing_notebook_metadata)
assert response.code == 200
assert 'Executing without notebook metadata' in response.body.decode('utf-8')
17 changes: 17 additions & 0 deletions tests/notebooks/no_metadata.ipynb
@@ -0,0 +1,17 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('Executing without notebook metadata')"
]
}
],
"metadata": {
},
"nbformat": 4,
"nbformat_minor": 2
}
3 changes: 2 additions & 1 deletion voila/handler.py
Expand Up @@ -183,7 +183,8 @@ async def fix_notebook(self, notebook):
# Find a spec matching the language if the kernel name does not exist in the kernelspecs
if kernel_name not in all_kernel_specs:
missing_kernel_name = kernel_name
kernel_name = await self.find_kernel_name_for_language(kernelspec.language.lower(), kernel_specs=all_kernel_specs)
language = kernelspec.get('language', notebook.metadata.get('language_info', {}).get('name', ''))
kernel_name = await self.find_kernel_name_for_language(language.lower(), kernel_specs=all_kernel_specs)
self.log.warning('Could not find a kernel named %r, will use %r', missing_kernel_name, kernel_name)
# We make sure the notebook's kernelspec is correct
notebook.metadata.kernelspec.name = kernel_name
Expand Down