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

Update .ipynb notebooks from .py in pre-commit hook #504

Closed
wants to merge 3 commits into from

Conversation

lrlunin
Copy link
Collaborator

@lrlunin lrlunin commented Nov 8, 2024

Hey,

I guess this feature was discussed previously in order to get rid of the additional commit from bot and directly "sync" the .ipynb notebooks with the .py files.

In this commit I add two pre-commit hooks:

  1. jupytext with the --update argument writes to the cell content and does not modify the cell-id and output. The fact that cell-id is not modified makes the changes independent from time or pc. However, the --update also preserves the cell output. Therefore the 2nd hook below is required.
  2. nbstripout is resposible for clean-up the output of .ipynb notebooks. This check is needed for correct work of jupytext but will also be a sign for a user before commit that all changes in the notebooks will be deleted.

This allows further delete the whole action section dedicated to the pip env setup, conversion, commit and push of the notebooks. I believe that this will make the procedure much more transparent and easier. As far as I understand we are also secured with the pre-commit tests running in CI to be sure that nobody will possibly commit to the project without necessary pre-commit hooks executed.

Cheers
Leonid

@lrlunin lrlunin closed this Nov 14, 2024
@lrlunin lrlunin deleted the notebooks-in-pre-commit branch February 12, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant