<div dir="ltr">Very cool, thanks William!</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Oct 13, 2013 at 12:22 AM, William Stein <span dir="ltr"><<a href="mailto:wstein@gmail.com" target="_blank">wstein@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, Sep 13, 2013 at 10:44 AM, Brian Granger <<a href="mailto:ellisonbg@gmail.com">ellisonbg@gmail.com</a>> wrote:<br>


> Thanks for this link, that is helpful.<br>
<br>
</div>Prompted by your message, I just also BSD licensed the IPython<br>
integration code I wrote for <a href="https://cloud.sagemath.com" target="_blank">https://cloud.sagemath.com</a><br>
<br>
It's here:<br>
<br>
<a href="https://gist.github.com/williamstein/6955561" target="_blank">https://gist.github.com/williamstein/6955561</a><br>
<br>
This has all the monkey patching, setting things up in an iframe, the<br>
other in-memory document format I use that is diff friendly (instead<br>
of json).  It's everything I used to integrate into my sync framework.<br>
<span class="HOEnZb"><font color="#888888"><br>
William<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> Cheers,<br>
><br>
> Brian<br>
><br>
> On Thu, Sep 12, 2013 at 4:04 PM, William Stein <<a href="mailto:wstein@gmail.com">wstein@gmail.com</a>> wrote:<br>
>> On Thu, Sep 12, 2013 at 2:53 PM, Brian Granger <<a href="mailto:ellisonbg@gmail.com">ellisonbg@gmail.com</a>> wrote:<br>
>>> William,<br>
>>><br>
>>> Thanks for notes.  This is really exciting and we are very interested<br>
>>> in getting live sync to work with IPython itself.  I am traveling this<br>
>>> week, but will try to have a look soon.  Is the code available<br>
>>> somewhere to look at?<br>
>><br>
>> Unfortunately, this implementation is very entangled as part of<br>
>> something I'm building as part of a startup company with UW's Center<br>
>> for commercialization, and I can't just open source everything.  But<br>
>> the algorithm is here:<br>
>><br>
>>   <a href="https://neil.fraser.name/writing/sync/" target="_blank">https://neil.fraser.name/writing/sync/</a><br>
>><br>
>> and the author of that paper has an open source Python implementation,<br>
>> I think...<br>
>><br>
>><br>
>>><br>
>>> Cheers,<br>
>>><br>
>>> Brian<br>
>>><br>
>>> On Tue, Sep 10, 2013 at 9:11 AM, William Stein <<a href="mailto:wstein@gmail.com">wstein@gmail.com</a>> wrote:<br>
>>>> Hi,<br>
>>>><br>
>>>> Somewhat by accident I spent the last two weeks implementing hosted<br>
>>>> IPython notebooks with sync for <a href="https://cloud.sagemath.com" target="_blank">https://cloud.sagemath.com</a>.<br>
>>>> Initially I had just plan to simplify the port forwarding setup, since<br>
>>>> what Ondrej Certik was doing with multiple forward and reverse port<br>
>>>> forwards seemed complicated.  But then I became concerned about<br>
>>>> multiple users (or users with multiple browsers) overwriting each<br>
>>>> other's notebooks, because cloud.sagemath projects are frequently<br>
>>>> shared between multiple people, and everything else does realtime<br>
>>>> sync.    I had planned just to add some very minimal merge-on-save<br>
>>>> functionality to avoid major issues, but somehow got sucked into<br>
>>>> realtime sync (even with the other person's cursor showing).<br>
>>>><br>
>>>> It would be enormously helpful to me if a couple of expert IPython<br>
>>>> users were to try out what I implemented and just ask a bunch of<br>
>>>> questions.<br>
>>>><br>
>>>> 1. Go to <a href="https://cloud.sagemath.com" target="_blank">https://cloud.sagemath.com</a> and make an account; this is<br>
>>>> completely free, and is hosted on computers at University of<br>
>>>> Washington.<br>
>>>><br>
>>>> 2. Create a new project.<br>
>>>><br>
>>>> 3. Click +New, then click "IPython" (or paste in a link to an ipython<br>
>>>> notebook, or upload a file).<br>
>>>><br>
>>>> 4. An IPython notebook server will start, the given .ipynb file should<br>
>>>> load in a same-domain iframe, and then some of the ipython notebook<br>
>>>> code is and iframe contents are monkey patched, in order to support<br>
>>>> sync and better integration with <a href="https://cloud.sagemath.com" target="_blank">https://cloud.sagemath.com</a>.<br>
>>>><br>
>>>> 5. Open the ipynb file in multiple browsers, and see that changes in<br>
>>>> one appear in the other, including moving cells around, creating new<br>
>>>> cells, editing markdown (the rendered version appears elsewhere), etc.<br>
>>>>   Anything that sets the notebook.dirty flag in IPython causes a sync<br>
>>>> (evaluating a cell that creates no output doesn't set this flag, at<br>
>>>> least in 1.0.0, which is a bug in IPython, I guess).<br>
>>>><br>
>>>> Since this is all very new and the first (I guess) realtime sync<br>
>>>> implementation on top of IPython, there are probably a lot of issues.<br>
>>>>  Note that if you click the "i" info button to the right, you'll get a<br>
>>>> link to the standard IPython<br>
>>>><br>
>>>> The other thing of interest is a little Python script called<br>
>>>> "ipython-notebook", which I wrote.  It basically makes it easy to run<br>
>>>> an IPython notebook server as a daemon, get the port it is running on,<br>
>>>> etc.  It's pretty simple but satisfies my use case, and has<br>
>>>> JSON-output, to make it web friendly.    As I've written it, my script<br>
>>>> passes several base_url options through by default, which are needed<br>
>>>> for cloud.sagemath.  Anyway, I've attached it to this email (with a<br>
>>>> BSD license) in case there is any interest.<br>
>>>><br>
>>>> Regarding the monkey patching in 4 above, the right thing to do would<br>
>>>> be to explain exactly what hooks/changes in the IPython html client I<br>
>>>> need in order to do sync, etc., make sure these makes sense to the<br>
>>>> IPython devs, and send a pull request (or have a coding sprint in<br>
>>>> Seattle or Berkeley?).  As an example, in order to do sync<br>
>>>> *efficiently*, I have to be able to set a given cell from JSON -- it's<br>
>>>> critical to do this in place when possible, since the overhead of<br>
>>>> creating a new cell is huge (due probably to the overhead of creating<br>
>>>> CodeMirror editors); however, the fromJSON method in IPython assumes<br>
>>>> that the cell is brand new -- it would be nice to add an option to<br>
>>>> make a cell fromJSON without assuming it is empty.<br>
>>>><br>
>>>> The ultimate outcome of this could be a clean well-defined way of<br>
>>>> doing sync for IPython notebooks using any third-party sync<br>
>>>> implementation.  IPython might provide their own sync service and<br>
>>>> there are starting to be others available these days -- e.g., Google<br>
>>>> has one: <a href="https://developers.google.com/drive/realtime/" target="_blank">https://developers.google.com/drive/realtime/</a>, and maybe<br>
>>>> Guido van Rosum helped write one for Dropbox recently?<br>
>>>><br>
>>>> Subdirectories:   I noticed, incidentally, that the wakari version of<br>
>>>> the IPython notebook server allows one to load ipynb files that are in<br>
>>>> any subdirectory, whereas the standard IPython notebook server<br>
>>>> doesn't.  For cloud.sagemath, I just spawn a new IPython notebook<br>
>>>> server for each directory that a user accesses files in right now.<br>
>>>> This seems cludgy, so I'm interested in the situation regarding adding<br>
>>>> support for subdirectories.<br>
>>>><br>
>>>> -- William<br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> William Stein<br>
>>>> Professor of Mathematics<br>
>>>> University of Washington<br>
>>>> <a href="http://wstein.org" target="_blank">http://wstein.org</a><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> IPython-dev mailing list<br>
>>>> <a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
>>>> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
>>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Brian E. Granger<br>
>>> Cal Poly State University, San Luis Obispo<br>
>>> <a href="mailto:bgranger@calpoly.edu">bgranger@calpoly.edu</a> and <a href="mailto:ellisonbg@gmail.com">ellisonbg@gmail.com</a><br>
>>> _______________________________________________<br>
>>> IPython-dev mailing list<br>
>>> <a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
>>> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
>><br>
>><br>
>><br>
>> --<br>
>> William Stein<br>
>> Professor of Mathematics<br>
>> University of Washington<br>
>> <a href="http://wstein.org" target="_blank">http://wstein.org</a><br>
>> _______________________________________________<br>
>> IPython-dev mailing list<br>
>> <a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
>> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
><br>
><br>
><br>
> --<br>
> Brian E. Granger<br>
> Cal Poly State University, San Luis Obispo<br>
> <a href="mailto:bgranger@calpoly.edu">bgranger@calpoly.edu</a> and <a href="mailto:ellisonbg@gmail.com">ellisonbg@gmail.com</a><br>
> _______________________________________________<br>
> IPython-dev mailing list<br>
> <a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br>
<br>
<br>
--<br>
William Stein<br>
Professor of Mathematics<br>
University of Washington<br>
<a href="http://wstein.org" target="_blank">http://wstein.org</a><br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br></div>