jupyter_ydoc icon indicating copy to clipboard operation
jupyter_ydoc copied to clipboard

Unable to open Notebook without metadata

Open martinRenou opened this issue 1 year ago • 8 comments

Description

I am getting the following:

    Traceback (most recent call last):
      File "/home/martinrenou/micromamba/envs/glue-lab/lib/python3.11/site-packages/tornado/websocket.py", line 944, in _accept_connection
        await open_result
      File "/home/martinrenou/micromamba/envs/glue-lab/lib/python3.11/site-packages/jupyter_collaboration/handlers.py", line 236, in open
        if self.room.document.source != model["content"]:
           ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/martinrenou/micromamba/envs/glue-lab/lib/python3.11/site-packages/jupyter_ydoc/ybasedoc.py", line 60, in source
        return self.get()
               ^^^^^^^^^^
      File "/home/martinrenou/micromamba/envs/glue-lab/lib/python3.11/site-packages/jupyter_ydoc/ynotebook.py", line 213, in get
        metadata=meta["metadata"],
                 ~~~~^^^^^^^^^^^^
    KeyError: 'metadata'

Leading to not being able to open the Notebook (it's an empty area on Jupyterlab)

martinRenou avatar May 04 '23 13:05 martinRenou

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:

welcome[bot] avatar May 04 '23 13:05 welcome[bot]

We could certainly fix it. But such notebook is invalid:

https://github.com/jupyter/nbformat/blob/633a433d13436247c5994f571911c74a1ec507d4/nbformat/v4/nbformat.v4.5.schema.json#L6

fcollonval avatar May 04 '23 13:05 fcollonval

It's unclear to me as to why I ended up with this invalid Notebook though

martinRenou avatar May 04 '23 14:05 martinRenou

Hi @martinRenou. What version of jupyter_ydoc are you using?

In theory, this was fixed in https://github.com/jupyter-server/jupyter_ydoc/pull/158

hbcarlos avatar May 04 '23 14:05 hbcarlos

I'm using 1.0.2

martinRenou avatar May 04 '23 14:05 martinRenou

Did you played with your local installation? The reported line number in the error is not consistent with the code.

Line 213 of ynotebook at v1.0.2 is:

https://github.com/jupyter-server/jupyter_ydoc/blob/39ddee8dde55d9a601ac98912800bce1075d6fca/jupyter_ydoc/ynotebook.py#L213

Metadata query is at line 223 in v1.0.2:

https://github.com/jupyter-server/jupyter_ydoc/blob/39ddee8dde55d9a601ac98912800bce1075d6fca/jupyter_ydoc/ynotebook.py#L223

Could you try forcing a re installation?

fcollonval avatar May 04 '23 15:05 fcollonval

Indeed 🤔

code /home/martinrenou/micromamba/envs/glue-lab/lib/python3.11/site-packages/jupyter_ydoc/ynotebook.py

gives me

Screenshot from 2023-05-04 17-19-21

So I'd say the traceback is lying!

martinRenou avatar May 04 '23 15:05 martinRenou

You may be trolled by inconsistent byte-code version. Do you get .pyc files for ynotebook.py. If so you could give a try of removing them.

fcollonval avatar May 04 '23 16:05 fcollonval