-
Notifications
You must be signed in to change notification settings - Fork 391
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
Automatic conversion to .py upon git commit? #121
Comments
Thanks @lebigot , that's a very nice idea. I think a pre-commit hook that generates the I am interested by the subject, and will try a bit, but I at this time I do not have a lot of experience with git. If someone can contribute the hooks and/or more links, he/she is very welcome to contribute! |
I am also interested in automatic conversion using a pre-commit hook. AFAIK such a hook would work by first calling So @lebigot the solution you tried might actually be working fine. I may be able to find time to toy with this idea. |
I briefly discussed this with a Git grandmaster. What we want here seems to be made of two separate elements:
In the following days I will experiment in these two directions. Let's see what we can do... |
Thanks @theolamayo for your interest! Please try that, and let us know - I saw that there are examples of pre commit hooks directly in the |
I wrote a very simple hook that converts all About converting only staged notebooks (and maybe then unstaging the notebooks so that they aren't commited), the https://github.com/gitpython-developers/GitPython library could be useful. And indeed, |
I have just contributed a pre-commit mode to Jupytext command line. It will add the python representation (or the markdown one, or even multiple representations) of every staged notebook to the current commit. @lebigot , @theolamayo , could you please have a look the documentation, and test the release candidate? The RC is available on pip. Please let me know if the hook works as intended. Thanks!
|
I tested it quickly and it works as expected, thank you! |
Thanks @theolamayo for testing! And for the tip. We should include it in the readme. Do you want to add it below the pre commit hook example? |
Okay I will create a PR. |
Thanks everyone. This has been made available with version 0.8.6. |
For those of us who prefer not to change the global Jupyter config or notebook metadata (and pair a notebook with a .py or something else), it would be nice to have a documented git pre-commit (?) hook that automatically converts some .ipynb notebooks into versioned .py files.
I tried once but failed, as I am not fully sure yet of how pre-commits work (the .py was generated, but effectively after the commit).
If I were to investigate this again I would either:
Some references (that I don't master yet):
The text was updated successfully, but these errors were encountered: