Skip to content

Conversation

takluyver
Copy link
Member

See gh-484

@takluyver takluyver added this to the 5.1 milestone Jul 27, 2017
// We want to check last_modified (disk) > that.last_modified (our last save)
// In some cases the filesystem reports an inconsistent time,
// so we allow 0.5 seconds difference before complaining.
if ((last_modified.getTime() - that.last_modified.getTime()) > 500) { // 500 ms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Math.abs() to allow it to go in either direction?

Copy link
Contributor

@blink1073 blink1073 Jul 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, reading the original code, I take that back.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need it to go in either direction - we want to show the message if the on-disk timestamp is newer than the timestamp from when we last saved it. The other way round would be weird.

@lcnature
Copy link

lcnature commented Jul 27, 2017

Hi, I tried to install in editable mode. It seems that even after I have left the tab for a while, if I press Ctrl+s to save the notebook, it still throws the warning of whether I want to overwrite change outside this tab.
Is there any log I can pull out to help understand this issue?

jupyter-notebook --version tells me it is 5.1.0.dev, so I suppose it is the newest one?

This is my conda environment:
bleach 2.0.0
cycler 0.10.0 py36_0
Cython 0.26
dbus 1.10.20 0
decorator 4.1.2
entrypoints 0.2.3
expat 2.1.0 0
fontconfig 2.12.1 3
freetype 2.5.5 2
glib 2.50.2 1
gst-plugins-base 1.8.0 0
gstreamer 1.8.0 0
html5lib 0.999999999
icu 54.1 0
ipykernel 4.6.1
ipython 6.1.0
ipython-genutils 0.2.0
jedi 0.10.2
Jinja2 2.9.6
jpeg 9b 0
jsonschema 2.6.0
jupyter-client 5.1.0
jupyter-core 4.3.0
libffi 3.2.1 1
libgcc 5.2.0 0
libgfortran 3.0.0 1
libiconv 1.14 0
libpng 1.6.27 0
libxcb 1.12 1
libxml2 2.9.4 0
MarkupSafe 1.0
matplotlib 2.0.2 np113py36_0
mistune 0.7.4
mkl 2017.0.3 0
mpi4py 2.0.0
nbconvert 5.2.1
nbformat 4.3.0
nibabel 2.1.0
nilearn 0.3.1
nitime 0.7
nodejs 6.11.0 0 conda-forge
numpy 1.13.1 py36_0
openssl 1.0.2l 0
pandocfilters 1.4.1
pcre 8.39 1
pexpect 4.2.1
pickleshare 0.7.4
pip 9.0.1 py36_1
prompt-toolkit 1.0.15
ptyprocess 0.5.2
pybind11 2.1.1
Pygments 2.2.0
pymanopt 0.2.2
pyparsing 2.2.0
pyparsing 2.1.4 py36_0
pyqt 5.6.0 py36_2
python 3.6.2 0
python-dateutil 2.6.1 py36_0
python-dateutil 2.6.1
pytz 2017.2 py36_0
pyzmq 16.0.2
qt 5.6.2 5
readline 6.2 2
scikit-learn 0.18.2 np113py36_0
scipy 0.19.1 np113py36_0
setuptools 27.2.0 py36_0
simplegeneric 0.8.1
sip 4.18 py36_0
six 1.10.0
six 1.10.0 py36_0
sqlite 3.13.0 0
terminado 0.6
testpath 0.3.1
Theano 0.9.0
tk 8.5.18 0
tornado 4.5.1
traitlets 4.3.2
typing 3.6.1
wcwidth 0.1.7
webencodings 0.5.1
wheel 0.29.0 py36_0
xz 5.2.2 1
zlib 1.2.8 3

@takluyver
Copy link
Member Author

Can you try adding this in to the Javascript just before the check, and see in the browser's console how different the two timestamps are:

console.log(last_modified);
console.log(that.last_modified);

@lcnature
Copy link

Sorry, it was my mistake. I installed master branch instead of from your repo. So I just incorporated the change to my master branch copy and no waning is thrown now in the tab.
I turned on debug level logging and here is what I got in the terminal when I pressed Ctr+s to save notebook. Is there anything wrong?

[I 11:10:31.779 NotebookApp] Saving file at /plosCB_2.ipynb
[D 11:10:31.780 NotebookApp] Saving /mnt/scratch/RSA_Bayesian/scripts/plosCB_2.ipynb
[D 11:10:31.817 NotebookApp] copystat on /mnt/scratch/RSA_Bayesian/scripts/.~plosCB_2.ipynb failed
    Traceback (most recent call last):
      File "/home/mingbo/jupyter-source/notebook/notebook/services/contents/fileio.py", line 53, in copy2_safe
        shutil.copystat(src, dst)
      File "/home/mingbo/anaconda3/envs/test_jupyter/lib/python3.6/shutil.py", line 225, in copystat
        _copyxattr(src, dst, follow_symlinks=follow)
      File "/home/mingbo/anaconda3/envs/test_jupyter/lib/python3.6/shutil.py", line 157, in _copyxattr
        names = os.listxattr(src, follow_symlinks=follow_symlinks)
    OSError: [Errno 22] Invalid argument: '/mnt/scratch/RSA_Bayesian/scripts/plosCB_2.ipynb'
[D 11:10:31.887 NotebookApp] 200 PUT /api/contents/plosCB_2.ipynb (127.0.0.1) 109.43ms
[D 11:10:31.916 NotebookApp] copystat on /mnt/scratch/RSA_Bayesian/scripts/.ipynb_checkpoints/plosCB_2-checkpoint.ipynb failed
    Traceback (most recent call last):
      File "/home/mingbo/jupyter-source/notebook/notebook/services/contents/fileio.py", line 53, in copy2_safe
        shutil.copystat(src, dst)
      File "/home/mingbo/anaconda3/envs/test_jupyter/lib/python3.6/shutil.py", line 225, in copystat
        _copyxattr(src, dst, follow_symlinks=follow)
      File "/home/mingbo/anaconda3/envs/test_jupyter/lib/python3.6/shutil.py", line 157, in _copyxattr
        names = os.listxattr(src, follow_symlinks=follow_symlinks)
    OSError: [Errno 22] Invalid argument: '/mnt/scratch/RSA_Bayesian/scripts/plosCB_2.ipynb'
[D 11:10:31.917 NotebookApp] 201 POST /api/contents/plosCB_2.ipynb/checkpoints (127.0.0.1) 19.21ms

@takluyver
Copy link
Member Author

Thanks, that sounds like it's working correctly.

The errors you see are something separate, though probably also a consequence of the shared filesystem. They're already being caught and logged, so it should be OK.

@gnestor
Copy link
Contributor

gnestor commented Jul 27, 2017

Excellent @takluyver!!

@gnestor gnestor merged commit cf6d305 into jupyter:master Jul 27, 2017
@pluviosilla
Copy link

pluviosilla commented Jan 11, 2019

I still get this error occasionally (in Jupyter 5.4.0) when opening a notebook I've downloaded from Github or Kaggle. Here's a quick fix if you need relief and don't have time to go on a safari hunt for a solution: %autosave 0

It doesn't fix the problem and you still will get a dozen error messages every time you save the notebook, but at least you can work without error dialogs popping up every 4 or 5 seconds.

@graphedge
Copy link

Something closely-related is still a challenge in 5.7.0: ipython/ipython#8456

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants