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
JupyterLab 4.0.0a31 collaborative notebook sometimes not respect nbformat_minor in file #13606
Comments
Comment says
But that's not the same as what I've seen, the downgrad does exist After trying |
It looks like it is caused by "clearing the cache and forcing a refresh", if the object is reinitialized, does that cause this situation? |
Hi @Wh1isper,
Indeed that's why we make sure not to override the content on disk from the constructor.
No, the Context's constructor synchronously instantiates the NotebookModel, and then the DocumentProvider (which opens the WebSocket and makes the back-end initialize the content). The timestamp of the initialization of When a second client joins, the document is already in memory in the back-end (the timestamp in the back-end is newer), but before sending it to the new client, the back-end creates a snapshot (an update with the current state of the document) and sends that to the client. Again, since we make a snapshot, the timestamp of the initialization of
Maybe. I'm trying to reproduce it to ensure we don't have the race condition, but I'm unable to reproduce it. |
@Wh1isper What version of JupyterLab are you using? Are you using the collaborative mode? |
@hbcarlos jupyterlab 4.0.0a31 with collaborative mode |
Some additional information pip list
I am using folloing scipt as entrypoint with python 3.8 in WSL ubuntu-2004 import re
import shutil
import sys
import os
from pkg_resources import load_entry_point
shutil.rmtree('./server_dir', ignore_errors=True)
shutil.rmtree('./id', ignore_errors=True)
if os.path.exists('.jupyter_ystore.db'):
os.remove('.jupyter_ystore.db')
os.makedirs('./server_dir')
os.makedirs('./id')
shutil.copy('Untitled.ipynb', 'server_dir/Untitled.ipynb')
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.argv.append('--debug')
sys.argv.append('--collaborative')
sys.argv.append('--config=jupyter_server_config.py')
path_fix = os.environ.get('PATH').split(':')
sys.path.extend(path_fix)
sys.exit(
load_entry_point('jupyterlab', 'console_scripts', 'jupyter-lab')()
) |
Jupyter server config import os
_here = os.path.dirname(__file__)
c.ServerApp.ip = '0.0.0.0' # listen on all IPs
c.ServerApp.token = '' # disable authentication
c.ServerApp.allow_origin = '*' # allow access from anywhere
c.ServerApp.disable_check_xsrf = True # allow cross-site requests
c.ServerApp.root_dir = os.path.abspath(os.path.join(_here, './server_dir'))
import jupyter_server_fileid
c.FileIdExtension.file_id_manager_class = jupyter_server_fileid.manager.LocalFileIdManager
c.LocalFileIdManager.db_path = os.path.join(_here, './id/db.sqlit') |
@hbcarlos succeed.mp4The second screen recording is a failure, you will find that the code highlighting is very slow to appear, I found through the breakpoint here the failed.mp4 |
Hi @Wh1isper, thanks for such detail. I can reproduce it now. I reproduced this issue by shutting down the server and launching it without closing the client (the browser tab with the document open). Then when reloading the client, I can see that the ´nbformat_minor´ attribute changed. Are you closing the client every time you shut down the server, or do you just reload the existing client? |
@hbcarlos In my case this problem can occur both ways, closing, reopening the tab or just refreshing the page |
Description
I think this is due to a
NotebookModel
'sconstructor
problem, initialized value overwrite the original value of the file.Here we initialize the value:
https://github.com/jupyterlab/jupyterlab/blob/master/packages/notebook/src/model.ts#L115
and value is 4
https://github.com/jupyterlab/jupyterlab/blob/master/packages/nbformat/src/index.ts#L22
As far as I know, the
crdt
algorithm determines the order of operations based on the timestamp, and it is possible that the time of this initialization operation is after the server initializesyroom
, so that the algorithm will consider it an active modificationhttps://github.com/jupyter-server/jupyter_server_ydoc/blob/v0.4.0/jupyter_server_ydoc/handlers.py#L211
So, when the nbformat_minor in the file is 5, there is a high probability that the nbformat_minor=4 in the constructor will override it, causing the file to be accidentally downgraded
I lack front-end knowledge, but I verified with breakpoints
jupyter_server_ydoc
does not tamper with nbformat_minor, which is modified from self.room.document.source, which is the web clientReproduce
Try collabroative open this file
Expected behavior
Do not downgrade nbformat_minor, cell_id is important and helpful for backend execution code in jupyter_kernel_executor
Context
Troubleshoot Output
Command Line Output
Browser Output
The text was updated successfully, but these errors were encountered: