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
Clear-all on save option #1280
Comments
If you think about this the other way round (save output cells, True/False), it sounds pretty simple. |
While we continue thinking about the best long-term solutions for VC integration, this could be an easy way to offer a good workflow right away that doesn't require any format changes or any decision on the more complex idea of splitting the nb into input/output files that we discussed a while ago. |
We are planning on implementing a configuration panel soon and we can put this there. |
Yes, that will be perfect. We can discuss on-list a little bit what we want in it, what pieces of information visible in the panel will be available as worksheet metadata (so they persist across runs of the same notebook), etc. |
I am not sure I understand how this would relate to the soon-to-appear configuration panel (or where that is being discussed), but I have hacked together a potential solution to this problem: https://github.com/mforbes/ipython If this is an appropriate direction, I can clean this up and submit a proper PR. I have been trying this out for a while, and am discussing this here: http://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control |
I think this is slighlty too much restrictive. There should be another issue open about that, bu we would like a post-save hook that run any kind of conversion(s) with nbconvert afterward, so that you could, each time you save, have a clean version but also html, pdf, ... etc potentially with custom templates. (nbconvert support ipynb->ipynb also) Finally for the |
I totally agree with this being too restrictive, but could not find a way of adding a hook. There was PR #3312 about hooks – closed as not "the direction we want to go" – and minimal discussion in issue #977. I cannot find any further discussion about adding hooks: Is progress towards hooks being discussed somewhere? The problem I have with relying on The second issue (outstanding in all methods as far as I can see) is: how does one incorporate pulled "clean" changes into one's working notebook? Probably something along the lines of first merging the two "clean" versions, then inserting the new content into the working notebook (removing any outdated output). Any suggestions? (Some way of updating one notebook from another seems to be required for this. I am not sure if that is the jurisdiction of |
Has there been any progress on this issue? I've noticed that @minrk has posted scripts (https://gist.github.com/minrk/6176788 and https://gist.github.com/minrk/3719849; thank you for posting!). These are great in the short term, and their only disadvantage is kludging together a configuration that works, and like the original poster noted, remembering to clear all output before saving is something I'm bound to screw up if I don't script it. Is there any plan to bundle these scripts (or similar functionality in a command line script) as part of IPython? I also noticed that there was some discussion of adding configuration options so that users could disable saving output. Last time I accessed http://ipython.org/ipython-doc/dev/config/options/notebook.html, I didn't see any options that would save only input cells. Is there still a plan to implement this feature? |
There is no immediate plan to implement these as part of IPython itself. |
I agree that the autosave / save as script (--script) would be most useful if they could be set at document level. For example if I start up a ipynb server with the |
This would be extremely useful for us, please consider adding just an optional flag! |
Would be really nice if IPython supported this natively since the notebooks would become much more version control friendly. |
Please implement a |
having a notebook option to clear output (and probably input cell number) on save would be great, as it would make ipynb much more VCS-friendly by keeping the diff noise lower. |
Agreed, you pretty much have to do it if you check in the notebooks into version control. |
Fortunately, #6896 just landed, adding a generic pre-save hook, with which you can do any manipulations on the notebook structure prior to saving, including stripping out any information you don't want to be saved. |
that's great, thanks! any chance of getting a usage example for the pre-save hook into the docs? E.g., right now I'm not entirely clear how I would convince Ipython to clean my notebooks before saving... |
The PR description includes such an example. |
hm, I saw this previously but didn't grok it correctly, apparently. Now I do. Still, the PR description will probably soon be lost in the mists of time, right? |
Do I hear a PR coming from your repo to our doc ? |
heh, you're of course correct to call me out on this. :D |
Advantages of docs is that you don't need to install to test :-P. You should even be able to edit the docs directly from github. |
Finally getting around to this (soon I hope). |
Any update on this? |
I sometimes forget to clear all before saving and checking the notebook into revision control, and it produces harder to read diffs and file sizes larger than I want to be commiting. Being able to set an option within a notebook to only save in cleared format would be very useful. Even nicer would be if it didn't clear the open notebook, just the saved version.
The text was updated successfully, but these errors were encountered: