[IPython-User] PLEASE make autosave standard

Matthias BUSSONNIER bussonniermatthias@gmail....
Wed Nov 7 08:13:38 CST 2012


custom js to autosave backup file at the end of this mail.

longer answer :

Le 7 nov. 2012 à 13:43, Tom a écrit :

> "But please consider your tone carefully, and try to remember that (nearly?) everyone working on IPython is doing so on a volunteer basis, in their spare time."
> I stated the "take-home message" so provocatively not to belittle people's hard work, but because I want to make people think about how the current situation looks to a user and to reflect on whether that really reflects the priorities they want to set.  

Yes, and being crash resistant is a high priority. 

> (I think lack of autosave should be prio-blocker.)
recovering from crash is convenient, you should not rely on your software to always do things for you. 
Backing up your hard drive should be prio-blocker, do your os prevent you from using it if you don't have a second hard drive ? 

I so far commit my notebook every hour or so and sync. C-m S is in my finger almost as much than <esc>:w (even if vim have swap file).
I work on multiple notebook branch that I use to work on my PhD, and I take care of using minimal config to get the lambda user behavior. 
So far I haven't lost much data, and half of it was because of bad fiddling with autosave/ auto git commit on which I spend **literally** hours going through every commit sha and copy/pasting files to get smith back.

Autosaving **is really bad** with current notebook version as you can open the same notebook in 2 browser tabs.

> "Despite IPython's long history, the notebook is less than a year old"
> True, but that's what makes autosave so important. Emacs, for example, used to crash every few hours, but autosave ensured that users didn't lose significant amounts of data. That's what allowed people to use Emacs productively even though it was a new and buggy tool (far more crash-prone than iPython).  In 25 years, I don't remember ever losing data from an Emacs crash.

And we hope to be able to have a nice solution too. 

> "But code talks. If you truly believe both that this is an important feature (I'm with you on that one), and that the right design decisions are self-evident/the implementation is straightforward (I'm a good deal less certain about that), give it a go and open a pull request."
> As far as I can glean from the responses and previous discussions, the project maintainers are not going to accept an Emacs-like autosave solution; they want a "correct" solution that satisfies numerous other requirements and future plans (that I don't understand). So, while I can cobble up a solution that works for me personally (and, in fact, have done so), I don't have a solution that would be accepted into the distribution.

Not **by default** but a doubt a clean implementation of a --autosave-emacslike flag for notebook would be refused. 
There are many features of IPython that are disable by default, because we strongly believe that having them enabled is more harmful for user who don't know they exist, so as their implication.

For example GreedyCompletion ( "aString".<tab> will propose : capitalize , center, count … etc) , %autocall , %store … have in some case nasty side effect.

We'll be happy if you have a solution that you write it on the python wiki.
It might be a good starting point to at least see what is needed.

Pasted on the end of this mail is my try on that. 
It is not well tested, configurability is ~ 0
Create the file ~/.ipython/profile_default/static/js/custom.js
With the given content, and notebook backup file  will be saved every 5mn ( you might need to restart the server for that and clear browser cache)
It does not need to be enable.

Just remind : 
Autosaving **is really bad** with current notebook version as you can open the same notebook in 2 browser tabs.
So open the same notebook in 2 browser tabs it will probably not work, (probably meaning the content of the backup file will alternate over time)

> Of course, I realize that nobody is under any obligation to cater to my requirements or use cases.  But I am trying to plan for what to use in my curriculum a year from now. iPython is otherwise a great tool for education and learning-by-doing, but lack of crash recovery is a deal-breaker for many such use cases, at least for me.

We do hope IPython notebook wil become much more powerful that what is is now. 
Sadly with the little time we have to work on it we have to make concession an d wait for the right way and right time to implement a feature. 
It took a long time to refactor IPython between 0.10.1 and 0.11 starting add  half baked feature would open the door to lot's of half baked stuff, meaning that :
1) We will be stuck with it.
2) We will think that this half baked solution is enough and not work on it.

This is the main reason why we try to force ourselves to do 1 feature totally, the right way. Or not do it at all.
We should also take into account that a non negligible part of our users are running from master, so it is difficult to change things to test on the master branch.

Any feature which is not fully done is : 
 - in a side repository of the IPython team.
 - in one of our branches
 - in a gist
 - on the ML
 - on the wiki.
The main advantage is you do not need our permission to update it, once it is perfected it might even becomes part of python itself, but being separate if help with loose coupling and also does not make assumption of uncuttable API.

// ~/.ipython/profile_default/static/js/custom.js
var make_backup = function(){
    var json = IPython.notebook.toJSON();
    var s = JSON.stringify(json)
    var settings = {
                    processData : false,
                    cache : false,
                    type : 'POST',
                    dataType : 'json',
                    data : s,
                    headers : {'Content-Type': 'application/json' },
                    success : function (data, status, xhr) {
                                console.log('save success');

    var qs = $.param({name:IPython.notebook.notebook_name+'.bkp', format:'json'});
    var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs;
    $.ajax(url, settings);
var seconde = 1000
var minute = 60*seconde

// comment following line to disable.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20121107/ebcda0cb/attachment-0001.html 

More information about the IPython-User mailing list