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

Warning "File Changed" in JupyterLab after reloading notebook from disk #978

Closed
ser3n1ty87 opened this issue Jul 12, 2022 · 7 comments · Fixed by #983
Closed

Warning "File Changed" in JupyterLab after reloading notebook from disk #978

ser3n1ty87 opened this issue Jul 12, 2022 · 7 comments · Fixed by #983

Comments

@ser3n1ty87
Copy link

Hi!

I am using JupyterLab together with Jupytext (which is great btw) and paired one of my notebooks my-notebook.ipynb with a percent script my-notebook.py.
When I am doing bigger changes and refactoring I am usually using Vim/Neovim for modifying the my-notebook.py directly.
For getting those changes back into my my-notebook.ipynb file I am using "Reload Notebook from Disk" in JupyterLab.
This also works as expected as I can see that the code part of my .ipynb notebook (in memory) is now equivalent to the content of the .py script.
However, whenever I now want to save the .ipynb notebook to disk I get the following warning:

File Changed
"my-notebook.ipynb" has changed on disk since the last time it was opened or saved. 
Do you want to overwrite the file on disk with the version open here, or load the version on disk (revert)?

Basically, it doesn't matter if I choose to revert or overwrite then as the .ipynb file gets correctly saved.

Even though this issue is only a little inconvenience, I am wondering: Is this to be expected or am I doing something wrong here?
May it be that this warning has something to do with the timestamp which the .ipynb notebook (in memory) "inherits" when reloading from disk w.r.t. the timestamps of the ipynb notebook (on disk) and the .py script (on disk)?

@mwouts
Copy link
Owner

mwouts commented Jul 12, 2022

Hi @ser3n1ty87 , thank you for the detailed report! Well that is not expected, as you have reloaded the notebook you should not see that message. I'll try to reproduce this in a test (but I can't do this now, hopefully I'll have some time for this next week).

@mwouts
Copy link
Owner

mwouts commented Jul 13, 2022

Just a quick question, do you think you could take a note of the timestamps of each operations? I mean, timestamp of when you save the notebook in Jupyter (or timestamp of files on disk just after you do so), then the timestamp after the edit in Vim, and finally the timestamps when you get the warning in Jupyter when you try to save there? Is there any change if you exit Vim after you edit the .py file (I guess you don't have any autosave in Vim, do you?)

@ser3n1ty87
Copy link
Author

Hi @mwouts,

sorry for the delay...
Here are the timestamps of the two files after each operation:

  • initially (.py and .ipynb are paired and I saved the notebook from jupyterlab)

    • File: ‘tci_obserrstat.ipynb’
      Size: 14599781 Blocks: 28544 IO Block: 16777216 regular file
      Access: 2022-07-19 07:42:19.524311176 +0000
      Modify: 2022-07-19 07:42:19.456953000 +0000
      Change: 2022-07-19 07:42:19.456114828 +0000
    • File: ‘tci_obserrstat.py’
      Size: 15499 Blocks: 32 IO Block: 16777216 regular file
      Access: 2022-07-19 07:41:26.704664165 +0000
      Modify: 2022-07-19 07:42:19.488502000 +0000
      Change: 2022-07-19 07:42:19.487717701 +0000
  • after doing some modification to .py file from vim (vim is directly closed afterwards)

    • File: ‘tci_obserrstat.ipynb’
      Size: 14599781 Blocks: 28544 IO Block: 16777216 regular file
      Access: 2022-07-19 07:42:19.524311176 +0000
      Modify: 2022-07-19 07:42:19.456953000 +0000
      Change: 2022-07-19 07:42:19.456114828 +0000
    • File: ‘tci_obserrstat.py’
      Size: 15506 Blocks: 32 IO Block: 16777216 regular file
      Access: 2022-07-19 07:46:01.222566592 +0000
      Modify: 2022-07-19 07:46:01.222394056 +0000
      Change: 2022-07-19 07:46:01.222394056 +0000
  • after reloading the notebook in jupyterlab and trying to save (warning is still open)

    • File: ‘tci_obserrstat.ipynb’
      Size: 14599781 Blocks: 28544 IO Block: 16777216 regular file
      Access: 2022-07-19 07:42:19.524311176 +0000
      Modify: 2022-07-19 07:42:19.456953000 +0000
      Change: 2022-07-19 07:42:19.456114828 +0000
    • File: ‘tci_obserrstat.py’
      Size: 15506 Blocks: 32 IO Block: 16777216 regular file
      Access: 2022-07-19 07:46:01.222566592 +0000
      Modify: 2022-07-19 07:46:01.222394056 +0000
      Change: 2022-07-19 07:46:01.222394056 +0000
  • after having chosen to 'overwrite' in the warning dialogue

    • File: ‘tci_obserrstat.ipynb’
      Size: 14599818 Blocks: 28544 IO Block: 16777216 regular file
      Access: 2022-07-19 07:50:24.979114805 +0000
      Modify: 2022-07-19 07:50:24.880597000 +0000
      Change: 2022-07-19 07:50:24.879923319 +0000
    • File: ‘tci_obserrstat.py’
      Size: 15506 Blocks: 32 IO Block: 16777216 regular file
      Access: 2022-07-19 07:46:01.222111000 +0000
      Modify: 2022-07-19 07:50:24.912669000 +0000
      Change: 2022-07-19 07:50:24.912201825 +0000

There also isn't any difference if I close vim or not and I also don't have any autosave configured in vim.

@mwouts
Copy link
Owner

mwouts commented Jul 20, 2022

Thank you @ser3n1ty87 for taking the time to gathering all this information ! That is really helpful. I should be able to reproduce (and fix this) in a new test. I'll keep you posted.

@mwouts
Copy link
Owner

mwouts commented Jul 20, 2022

Hi @ser3n1ty87 , I have prepared a fix for this. Would you mind giving a try to the upcoming version? You can install it with

BUILD_JUPYTERLAB_EXTENSION=1 pip install git+https://github.com/mwouts/jupytext.git@fix_978

Please let me know if that solves the issue on your end. And thank you so much for reporting this!

@ser3n1ty87
Copy link
Author

Hi @mwouts, I just tested your fix and the issue seems to be solved now.
Thank you very much!

@mwouts
Copy link
Owner

mwouts commented Jul 29, 2022

Thank you @ser3n1ty87 for the confirmation. I'll integrate the fix and deliver a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants