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

--sync: avoid updating timestamp of *.py if nothing changes #1215

Closed
hhoppe opened this issue Feb 18, 2024 · 11 comments · Fixed by #1227
Closed

--sync: avoid updating timestamp of *.py if nothing changes #1215

hhoppe opened this issue Feb 18, 2024 · 11 comments · Fixed by #1227
Milestone

Comments

@hhoppe
Copy link

hhoppe commented Feb 18, 2024

I use jupytext --sync frequently across many files to synchronize changes in either direction between *.py and *.ipynb.
Often, no synchronization is necessary and it reports:

jupytext --sync **/*.ipynb
[jupytext] Reading notebook.ipynb in format ipynb
[jupytext] Loading notebook.py
[jupytext] Updating the timestamp of notebook.py

Is there any way to avoid updating the timestamp on the *.py file if no synchronization changes occur?
Could this be made the default behavior?

(I have some later lint tool that unfortunately invalidates its cache as a result.)
I see a flag --use-source-timestamp but I'm not sure if it is intended for bidirectional synchronization.

@hhoppe
Copy link
Author

hhoppe commented Feb 18, 2024

(Another minor annoyance of updating the *.py timestamp is that Emacs warns that it is "reverting the buffer" if it has loaded the file -- even though nothing has changed.)

@mwouts mwouts added this to the 1.16.2 milestone Apr 27, 2024
@mwouts
Copy link
Owner

mwouts commented Apr 27, 2024

Hi @hhoppe , thank you for reporting this, and sorry for the delay in getting back to you. Sure that makes sense, let me see what I can do.

@mwouts
Copy link
Owner

mwouts commented Apr 27, 2024

A development version with a tentative fix is available at

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

Would you mind confirming if it does what you are looking for?

@hhoppe
Copy link
Author

hhoppe commented Apr 28, 2024

Thanks for doing this! I'm away this weekend and will try it on Tuesday.

@mwouts
Copy link
Owner

mwouts commented Apr 28, 2024

You're welcome ! No hurry at all. Keep me posted, thanks

@hhoppe
Copy link
Author

hhoppe commented Apr 30, 2024

I'm having difficulty building the development branch -- maybe it's because I am using WSL.
I first had to apt install nodejs, but even then I get a build error

YN0009: │ nx@npm:15.9.7 [9d75b] couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-9020d20b/build.log)

where the log contains

Error: Cannot find module 'fs/promises'

I may not be the best person to test this out.

@mwouts
Copy link
Owner

mwouts commented Apr 30, 2024

Oh I see - it's not obvious to build the Jupyter Lab extension, sorry about that. Thanks for giving it a try anyway! This should be much easier, and faster too:

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

(the drawback is that you won't get the Jupytext menu in JupyterLab, but maybe you mostly care about the command line?)

@hhoppe
Copy link
Author

hhoppe commented Apr 30, 2024

The new install command line unfortunately gives the same build error.

@mwouts
Copy link
Owner

mwouts commented May 1, 2024

No worries! I will test this a bit more on my end, and package the change with the next release, in a few days hopefully.

@max-accenta
Copy link

Hi, I was able to install from the skip_update_timestamp branch on my side (Fedora & python3.11). The feature seems to work as expected, thanks for the work.

@mwouts
Copy link
Owner

mwouts commented May 2, 2024

Hi, I was able to install from the skip_update_timestamp branch on my side (Fedora & python3.11). The feature seems to work as expected, thanks for the work.

Oh great, thank you @max-accenta for testing it, that's super helpful!

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.

3 participants