jupyter-server / jupyter_ydoc

Jupyter document structures for collaborative editing using Yjs/pycrdt
https://jupyter-ydoc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
29 stars 17 forks source link

Invalid notebook in test expectation #157

Open krassowski opened 1 year ago

krassowski commented 1 year ago

Note: the underlying issue might be the cause of https://github.com/jupyter/notebook/issues/6828.

The nb0.ipynb notebook used as an expectation in tests is invalid and does not even render on GitHub:

Screenshot from 2023-04-08 16-08-49

It is used in this test:

https://github.com/jupyter-server/jupyter_ydoc/blob/1ec81ffc7c276c15757d52c0dac130d73ace8a9b/tests/test_ypy_yjs.py#L51-L62

And contains two code cells with id set to null:

{
    "cells": [
        {
            "cell_type": "code",
            "source": [
                "print('Hello, World!')"
            ],
            "metadata": {},
            "outputs": [],
            "execution_count": null,
            "id": null
        },
        {
            "cell_type": "code",
            "source": "print('Hello, World!')",
            "metadata": {},
            "outputs": [],
            "execution_count": null,
            "id": null
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "Python 3 (ipykernel)",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.10.2"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 5
}

While execution_count can be null, id cannot, compare specification:

Code cells are the primary content of Jupyter notebooks. They contain source code in the language of the document’s associated kernel, and a list of outputs associated with executing that code. They also have an execution_count, which must be an integer or null.

Since the 4.5 schema release, all cells have an id field which must be a string of length 1-64 with alphanumeric, -, and _ as legal characters to use. These ids must be unique to any given Notebook following the nbformat spec.

And schema:

"execution_count": {
  "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  "type": ["integer", "null"],
  "minimum": 0
}
"definitions": {
    "cell_id": {
      "description": "A string field representing the identifier of this particular cell.",
      "type": "string",
      "pattern": "^[a-zA-Z0-9-_]+$",
      "minLength": 1,
      "maxLength": 64
    }
}
welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada: