Skip to content

Codepod-exported ipynb not compliant to NBFormat 4.0 #411

Open
@forrestbao

Description

@forrestbao

The attachment of this issue is an ipynb exported from this Codepod repo. It has some format issues incompatible with NBFormat 4.0:

  1. #/metadata has no property called name
  2. id is a mandatory field for each cell under #/cells But it's missing for all cells exported. id is not a field in metadata of a cell.
  3. All cells' output_type is display_data. This is not right. There are four types: execute_result, display_data, error (see below), and stream. display_data has no property called execute_count but execute_result has. In many cases in the attached example ipynb, the output should be steam? For example, this cell
        {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "id": "w1o7rfvk37nkk2p8105s",
        "geoScore": 0.0021
      },
      "source": [
        "'''\n",
        "CodePod Scope structure: \n",
        "'''\n",
        "1+1\n"
      ],
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "2\n"
            ]
          }
        }
      ]
    },
  4. Erroneous cells are handled completely wrong. One of the pods contains error and traceback info. But the corresponding json is incorrectly as
    {
          "cell_type": "code",
          "execution_count": 3,
          "metadata": {
            "id": "xs1x514pd2o089p0uzub",
            "geoScore": 0.0012
          },
          "source": [
            "'''\n",
            "CodePod Scope structure: \n",
            "'''\n",
            "foo(4)\n"
          ],
          "outputs": [
            {
              "output_type": "display_data",
              "data": {
                "text/plain": [
                  "error\n"
                ]
              }
            }
          ]
        },

where the outputs/output_type should have been error, and data is NOT an allowed field for an error. Required fields, expect output_type are all missing. See specs here.
5. What is the geoScore property for each cell?
6. Why is a scope and the first pod under it mixed together? Like this:
json { "cell_type": "code", "execution_count": 0, "metadata": { "id": "yla4ktyffvgxenaivved", "geoScore": 0.0011 }, "source": [ "'''\n", "CodePod Scope structure: Another test scope\n", "'''\n", "def foo(x):\n", " return x * x\n" ], "outputs": [] },
The scope should have become one separate cell of raw or even markdown type. In Markdown, the header level (#, ##, ###, ...) should be proportional to the scope level.
7. And, can we beautify the JSON output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions