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

Can I disable the 'update timestamp' step? #767

Closed
Midnighter opened this issue Apr 21, 2021 · 7 comments
Closed

Can I disable the 'update timestamp' step? #767

Midnighter opened this issue Apr 21, 2021 · 7 comments
Milestone

Comments

@Midnighter
Copy link

I am trying to create a small workflow using make. The basic idea being that I want to generate data from a notebook (py:percent). Defining the notebook as a prerequisite for the data files in the Makefile, I would like to be able to re-generate those data files where the notebook has been updated (later timestamp than the data file).

So ideally I would like to execute the notebook to generate the data and an .ipynb file as a report containing outputs.

jupytext --to ipynb --execute notebook.py

However, since the data is generated during the execution and jupytext updates the timestamp at the end, make will always consider the generated files outdated. I tried to play with the --pre-commit-mode but couldn't get it to work. Is there another way to prevent jupytext from updating the timestamp?

@Midnighter
Copy link
Author

I was able to solve the problem with a pipe as described in the papermill demo.

@mwouts
Copy link
Owner

mwouts commented Apr 22, 2021

Hi @Midnighter , thank you for sharing your use case. It's a great thing that you've been able to solve the issue.

I think that your original question is nevertheless very interesting. My expectation is that Jupytext should update the timestamp of the .py file only if that file is a paired notebook (because otherwise the paired notebook won't open any more in Jupyter). Was that the case? Can you try to "unpair" it (i.e. remove the "formats" entry under the jupytext metadata)?

If you find out that unpairing is not enough, or if you think it would be legitimate to implement a --no-timestamp-update option, then please let me know.

@Midnighter
Copy link
Author

Ah, you are correct that removing the formats field completely indeed leads to the timestamp not being updated.

I had set the following:

jupytext --set-formats py:percent notebook.py

and expected that to unpair the two as well.

if you think it would be legitimate to implement a --no-timestamp-update option, then please let me know

Now that I know how to properly unpair the files, I don't think such an option is a good idea since it may lead to a broken pair.

@mwouts
Copy link
Owner

mwouts commented Apr 22, 2021

Ok thanks for the update! So if I follow well, a notebook paired with just itself is considered as a paired notebook, and its timestamp gets updated when we do a --to conversion...

Maybe it would make sense to consider that when the destination is not part of the pair, the source notebook does not need to be updated. What do you think?

@Midnighter
Copy link
Author

That'd make sense to me 👍🏼 However, I'm sure there are many other things that you could work on that are more important than this.

@mwouts mwouts added this to the 1.11.2 milestone Apr 25, 2021
@mwouts
Copy link
Owner

mwouts commented Apr 25, 2021

Well precisely there is another question about timestamp updates at #765. I'll try to answer both in the next version.

@mwouts
Copy link
Owner

mwouts commented May 20, 2021

FYI, we have a PR with a new --use-source-timestamp argument at #790.

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

No branches or pull requests

2 participants