Notebook format json

Where are the various notebook format versions (json) stored? I see nbformat have the various versions defined, though not sure, if this is kept in sync and its up-to-date.

My jupterlab version is

(base) jovyan@cac89e6a8e74:~$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.4.3
qtconsole        : not installed
ipython          : 7.26.0
ipykernel        : 6.1.0
jupyter client   : 6.1.12
jupyter lab      : 3.1.6
nbconvert        : 6.1.0
ipywidgets       : not installed
nbformat         : 5.1.3
traitlets        : 5.0.5

I have a run book, which has the following version:

 "nbformat": 4,
 "nbformat_minor": 5

and if i look at a markdown type cell, it looks like this:

   "cell_type": "markdown",
   "execution_count": 0,
   "id": "5de6a7c1-7386-481d-b6ca-a2efa2b8dc30",
   "metadata": {
    "jupyter": {
     "source_hidden": true
    "tags": [],
    "title": "1 Is this affecting all pods"
   "outputs": [],
   "source": [
    "First, determine (if you can) whether this issue affects all pods.\n",
    "You might do this by:\n",
    "<a id=\"1.0\"></a>\n",
    "* Checking the logs for your pods for network lookup errors\n",
    "* Checking an external observability system to determine if all pods are showing similar errors\n",
    "kubectl execing onto the pods to try and curl or nslookup DNS lookups manually (see step 9)\n",
    "The last option may be problematic if your pods' images do not contain these utilities.\n",
    "If the issue affects all pods, then it is likely that some core component, such as the CoreDNS pods have failed. Bear this in mind as you read on.\n",
    "If the issue affects only a subset of pods, then some other factor might be at play. Bear this in mind as you read on.\n",
    "These factors may include:\n",
    "DNS configuration on the node\n",
    "DNS configuration on the pod/workload"

As you can see, it has outputs and execution_count fields, however, these fields are not defined in the markdown_cell format here

This causes nbformat to complain whenever i run nbformat on these notebooks.

I am not sure if this PR would help, as its talking about 4.6 version.

My question is how to get these fields in the 4.5 version of the schema?

How to ensure that notebook and nbformat version are in sync?

The nbformat python package contains the JSON schemas for various notebook format versions. For version 4, the various schema definitions are here: nbformat/nbformat/v4 at master · jupyter/nbformat · GitHub

1 Like

Thanks @jasongrout for the prompt reply. However as i mentioned above, i see a mismatch between nbformat 4.5 version vs whats contained in the .ipynb file. So, not sure, what to trust here?

Did you create this notebook in JupyterLab, Jupyter Notebook, or imported from a third-party client? I checked a few notebooks generated by JupyterLab and markdown cells do not have execution_count nor outputs fields, complying with the specification. Maybe the notebook is indeed malformed by edition in a client which does not obey specification?

1 Like

Thanks a lot @krassowski @jasongrout , it indeed came out to be the issue with the client which was modifying it wrongly, treating the markdown same as code.