Coder Social home page Coder Social logo

Comments (12)

boazbk avatar boazbk commented on May 16, 2024 2

This can also be an issue if one edits the same notebook from different machines, some might have jupytext installed and some might not. I would suggest you put in the meta data of both the ipynb and text file some hash/version number that would be a more reliable way than just looking at the filesystem filestamp. When the ipynb's version is higher than the textfile's, it should take precedence. (Or maybe there can be some dialog to ask if they should be merged together or not, if this is feasible.)

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

Hello @boazbk , yes I agree, we need to find a reliable way to decide whether we can override the ipynb inputs with that of the text file. In which cases do you think timestamps would fail to identify most recent file? I've been told that make simply uses timestamps. And also timestamps seem convenient as they require no specific action by the user.

As for the action to take when text file timestamp is older than ipynb, I am in favor of refusing to open the paired notebook, with the following message: remove either file, or edit the text file to confirm that it is indeed up to date.

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

@cclauss , thanks for your previous contributions. Would you have recommendations on this precise question? Are you aware of any better approach than timestamps?

from jupytext.

cclauss avatar cclauss commented on May 16, 2024

I have no knowledge on this topic. Sorry.

from jupytext.

boazbk avatar boazbk commented on May 16, 2024

@mwouts I was thinking of cases where for example the notebook is in dropbox or something like that, and was also hoping that it would be possible at least on the ipynb file to update this without user interaction, but I'm not a programmer.

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

Notebooks returned by the content manager have a last_modified field which is a timestamp. This seems to be the timestamp used by Jupyter when warning the user that she/he is about to overwrite a more recent version of the notebook on disk, see this comment.

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

@boazbk: well, I think you're right: using timestamps is not perfect. Actually Jupyter itself has a few issues on the subject - a few people report that the warning on overwriting is triggered with no obvious reason. Therefore I plan to

  • implement and test the check
  • and offer a configuration option... for no checking!

I do think the check is important. Overriding the inputs with an out of date content is not very nice to the user!

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

I have implemented the check. Error message tries to be as explicit as possible. For instance:

[W 00:15:17.325 NotebookApp]
    jupyter.ipynb (last modified 2018-09-11 22:10:31.426083+00:00)
    seems more recent than jupyter.Rmd (last modified 2018-09-11 21:37:20.648049+00:00)
    Please either:
    - open jupyter.Rmd in a text editor, make sure it is up to date, and save it,
    - or delete jupyter.Rmd if not up to date,
    - or increase check margin by adding, say,
        c.ContentsManager.outdated_text_notebook_margin = 5 # in seconds # or float("inf")
    to your .jupyter/jupyter_notebook_config.py file

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

@boazbk , would you mind to try the new version? In order to trigger the message above I expect that you will have to edit (with a text editor) the ipynb file, to make it more recent than the text notebook.

pip install jupytext==0.6.4
# + restart jupyter notebook

Thanks!

from jupytext.

boazbk avatar boazbk commented on May 16, 2024

Will try soon, thanks!

from jupytext.

allenyllee avatar allenyllee commented on May 16, 2024

I use git to version control my .ipynb and .py pairs.

Sometimes, I need to use git stash to temporally save all file changes, but in a situation that the .ipynb had some change while .py doesn't, i.e., without any code change, just execute .ipynb file then the meta data will be changed, but the paired .py doesn't change, when I restore from this stash, the .ipynb's timestamp will be the current time, but the paired .py's timestamp remain unchanged. This will trigger error loading notebook like below:

xxx.ipynb (last modified 2021-06-02 05:42:06.520687+00:00) seems more recent than xxx.py (last modified 2021-06-02 05:06:01.211872+00:00) Please either: - open xxx.py in a text editor, make sure it is up to date, and save it, - or delete xxx.py if not up to date, - or increase check margin by adding, say, outdated_text_notebook_margin = 5 # default is 1 (second) to your jupytext.toml file

It's very annoying. Maybe we should save the timestamp and file hash of last sync into the meta data of all paired files, e.g. the last_sync key in below:

#   jupytext:
#     formats: ipynb,py:percent
#     text_representation:
#       extension: .py
#       format_name: percent
#       format_version: '1.3'
#       jupytext_version: 1.11.2
#     last_sync:
#       timestamp: 2021-06-02 05:42:06.520687+00:00
#       file_hash: XXXXXXXX
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3

When we open an .ipynb file, it'll check the paired .py's timestamp and file_hash under the last_sync section, if match, just work; otherwise, pop the error message.

from jupytext.

mwouts avatar mwouts commented on May 16, 2024

Hi @allenyllee , this is a very old issue so I won't reopen it, but still I think we can do something for you use case - please see #799.

from jupytext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.