mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
https://jupytext.readthedocs.io
MIT License
6.65k stars 386 forks source link

Update the timestamp of the py file only if it is older than that of the nb file #1227

Closed mwouts closed 6 months ago

mwouts commented 6 months ago

Closes #1215

github-actions[bot] commented 6 months ago

Thank you for making this pull request.

Did you know? You can try it on Binder: Binder:lab or Binder:notebook.

Also, the version of Jupytext developed in this PR can be installed with pip:

HATCH_BUILD_HOOKS_ENABLE=true pip install git+https://github.com/mwouts/jupytext.git@skip_update_timestamp

(this requires nodejs, see more at Developing Jupytext)

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.76%. Comparing base (7963f5f) to head (bd50cbe).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1227 +/- ## ========================================== + Coverage 97.73% 97.76% +0.02% ========================================== Files 29 29 Lines 4464 4468 +4 ========================================== + Hits 4363 4368 +5 + Misses 101 100 -1 ``` | [Flag](https://app.codecov.io/gh/mwouts/jupytext/pull/1227/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marc+Wouts) | Coverage Δ | | |---|---|---| | [external](https://app.codecov.io/gh/mwouts/jupytext/pull/1227/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marc+Wouts) | `75.14% <71.42%> (-0.03%)` | :arrow_down: | | [functional](https://app.codecov.io/gh/mwouts/jupytext/pull/1227/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marc+Wouts) | `88.52% <100.00%> (+0.01%)` | :arrow_up: | | [integration](https://app.codecov.io/gh/mwouts/jupytext/pull/1227/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marc+Wouts) | `77.28% <85.71%> (-0.01%)` | :arrow_down: | | [unit](https://app.codecov.io/gh/mwouts/jupytext/pull/1227/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marc+Wouts) | `66.56% <85.71%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marc+Wouts#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

max-accenta commented 6 months ago

Hi @mwouts, sorry to bother you but after the recent change, this feature only works with the --sync command.

If I run jupytext --sync notebook.py I get:

[jupytext] Reading notebook.py in format py
[jupytext] Loading notebook.ipynb
[jupytext] Updating notebook.ipynb
[jupytext] Unchanged notebook.py

however with jupytext --to ipynb notebook.py --output notebook.ipynb I get:

[jupytext] Reading notebook.py in format py
[jupytext] Writing notebook.ipynb (destination file replaced [use --update to preserve cell outputs and ids])
[jupytext] Updating the timestamp of notebook.py

and the python file's timestamp is updated.

Is there a reason we can't get the same behavior for --to as for --sync ? Thanks