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

Invalid notebook in test expectation #157

Open
krassowski opened this issue Apr 8, 2023 · 1 comment
Open

Invalid notebook in test expectation #157

krassowski opened this issue Apr 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@krassowski
Copy link
Contributor

Note: the underlying issue might be the cause of jupyter/notebook#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:

@pytest.mark.asyncio
@pytest.mark.parametrize("yjs_client", "0", indirect=True)
async def test_ypy_yjs_0(yws_server, yjs_client):
ydoc = Y.YDoc()
ynotebook = YNotebook(ydoc)
websocket = await connect("ws://localhost:1234/my-roomname")
WebsocketProvider(ydoc, websocket)
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
ynotebook.source = nb
ytest = YTest(ydoc, 3.0)
await ytest.change()
assert ytest.source == nb

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
    }
}
@krassowski krassowski added the bug Something isn't working label Apr 8, 2023
@welcome
Copy link

welcome bot commented Apr 8, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

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! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant