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

Error accessing notebook.metadata.language_info.file_extension #108

Closed
chrisjsewell opened this issue Mar 12, 2020 · 5 comments
Closed

Error accessing notebook.metadata.language_info.file_extension #108

chrisjsewell opened this issue Mar 12, 2020 · 5 comments

Comments

@chrisjsewell
Copy link
Contributor

chrisjsewell commented Mar 12, 2020

Copied from executablebooks/MyST-NB#63

jupyter-sphinx expects the presence of notebook.metadata.language_info.file_extension here:

ext = notebook.metadata.language_info.file_extension

However, it appears that this is not actual a necessary attribute of the notebook metadata, as exampled by the working notebook below:

{
 "nbformat": 4,
 "nbformat_minor": 2,
 "metadata": {
  "language_info": {
   "name": "python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   }
  },
  "orig_nbformat": 2,
  "file_extension": ".py",
  "mimetype": "text/x-python",
  "name": "python",
  "npconvert_exporter": "python",
  "pygments_lexer": "ipython3",
  "version": 3
 },
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(use/api)=\n",
    "\n",
    "# Python API"
   ]
  }
 ]
}

Note, the notebook was initially created by VS Code:

Name: Python
Id: ms-python.python
Description: Linting, Debugging (multi-threaded, remote), Intellisense, Jupyter Notebooks, code formatting, refactoring, unit tests, snippets, and more.
Version: 2020.2.64397
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python 

perhaps just have notebook.metadata.language_info.get("file_extension", ".py")

@chrisjsewell
Copy link
Contributor Author

Wait a minute, looking at this again, I guess this is a bug in the VS Code extension, that it is adding data to metadata rather than metadata.language_info!

@akhmerov
Copy link
Member

akhmerov commented Mar 12, 2020

Thanks for reporting!

It shouldn't be .ipynb—that's the file extension of the programming language used in the notebook. The field, interestingly, is right there outside of kernel_info or language_info. By checking other notebooks, it seems the line is a typo, and should become notebook.metadata.file_extension.

Nevermind, seems like a bug in VS Code extension.

@chrisjsewell
Copy link
Contributor Author

yeh doh, raising an issue on there now

@akhmerov
Copy link
Member

I have confirmed, as per jupyter client kernel API, that file_extension is a compulsory metadata field in the kernel spec.

@chrisjsewell
Copy link
Contributor Author

stupid VS Code lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants