sage cell server, version 2

110 views
Skip to first unread message

Jason Grout

unread,
Jul 20, 2012, 3:38:24 PM7/20/12
to sage-devel, sage-notebook
Hi everyone,

We'd like to announce a beta of the new version of the Sage cell server.
We've set it up at:

aleph2.sagemath.org

It uses websockets (via SockJS, so it falls back to older techniques if
the browser doesn't support websockets) and has been pretty much
completely rewritten to use much more of the new IPython framework.
While hopefully the only changes from aleph you'll notice are that it is
more responsive (something like 25-50% faster for updates on interacts,
it feels like), it also lays the groundwork for interactive javascript
controls and other features we've wanted for a long time.

So please, test it out: aleph2.sagemath.org (if you've embedded aleph in
any webpages, you should be able to just change the address to
aleph2.sagemath.org). Sometime soon, we'll switch aleph.sagemath.org
over to the new version. If you find an issue with aleph2, please let
us know.

Volker and Ivan (and others interested in clients other than our
provided web client): are there libraries on Android and iOS that let
you use websockets naturally, instead of the polling model in aleph
version 1? I found
http://stackoverflow.com/questions/4501121/websockets-client-for-objective-c-preferrably-ios-compatible
and
http://stackoverflow.com/questions/6347499/websocket-library-for-android-ios-and-flash
that seem to indicate that you can incorporate websockets into an app:

SocketRocket for iOS:
http://corner.squareup.com/2012/02/socketrocket-websockets.html

Autobahn for Android: http://autobahn.ws/android

A huge thanks to Ira Hanson, Steven Johnson, and Alex Kramer who worked
tirelessly on this during the summer. And also a huge shoutout to the
IPython team for the great foundation we were able to build on.

We aren't quite ready for a final release. I'll be packaging things up
better over the next month or two.

Thanks,

Jason

Andrea Lazzarotto

unread,
Jul 21, 2012, 5:35:35 AM7/21/12
to sage-n...@googlegroups.com


2012/7/20 Jason Grout <jason...@creativetrax.com>

Hi everyone,

We'd like to announce a beta of the new version of the Sage cell server.  We've set it up at:

aleph2.sagemath.org

That's a great news. :) BTW do you need someone to work with the "presentation part"? I think for it to be really useful on a mobile, some CSS changes are at least to be taken into consideration and maybe I can help a bit.

Best regards,

--
Andrea Lazzarotto - http://andrealazzarotto.com

Ivan Andrus

unread,
Jul 21, 2012, 5:45:11 AM7/21/12
to sage-n...@googlegroups.com
On Jul 20, 2012, at 9:38 PM, Jason Grout wrote:

> Hi everyone,
>
> We'd like to announce a beta of the new version of the Sage cell server. We've set it up at:
>
> aleph2.sagemath.org
>
> It uses websockets (via SockJS, so it falls back to older techniques if the browser doesn't support websockets) and has been pretty much completely rewritten to use much more of the new IPython framework. While hopefully the only changes from aleph you'll notice are that it is more responsive (something like 25-50% faster for updates on interacts, it feels like), it also lays the groundwork for interactive javascript controls and other features we've wanted for a long time.
>
> So please, test it out: aleph2.sagemath.org (if you've embedded aleph in any webpages, you should be able to just change the address to aleph2.sagemath.org). Sometime soon, we'll switch aleph.sagemath.org over to the new version. If you find an issue with aleph2, please let us know.

Well, the iPhone client doesn't work on it because I get a 404 on http://aleph2.sagemath.org/eval. That's all I see at https://github.com/sagemath/sagecell/blob/master/doc/web_service.rst. Is there another branch that I should use, or has the documentation just not been updated yet?

> Volker and Ivan (and others interested in clients other than our provided web client): are there libraries on Android and iOS that let you use websockets naturally, instead of the polling model in aleph version 1? I found http://stackoverflow.com/questions/4501121/websockets-client-for-objective-c-preferrably-ios-compatible and http://stackoverflow.com/questions/6347499/websocket-library-for-android-ios-and-flash that seem to indicate that you can incorporate websockets into an app:
>
> SocketRocket for iOS: http://corner.squareup.com/2012/02/socketrocket-websockets.html
>
> Autobahn for Android: http://autobahn.ws/android
>
> A huge thanks to Ira Hanson, Steven Johnson, and Alex Kramer who worked tirelessly on this during the summer. And also a huge shoutout to the IPython team for the great foundation we were able to build on.
>
> We aren't quite ready for a final release. I'll be packaging things up better over the next month or two.

I'll get something ready by then. Thanks for the heads up.

-Ivan

Jason Grout

unread,
Jul 21, 2012, 6:44:09 AM7/21/12
to sage-n...@googlegroups.com
On 7/21/12 4:35 AM, Andrea Lazzarotto wrote:
>
>
> 2012/7/20 Jason Grout <jason...@creativetrax.com
> <mailto:jason...@creativetrax.com>>
>
> Hi everyone,
>
> We'd like to announce a beta of the new version of the Sage cell
> server. We've set it up at:
>
> aleph2.sagemath.org <http://aleph2.sagemath.org>
>
>
> That's a great news. :) BTW do you need someone to work with the
> "presentation part"? I think for it to be really useful on a mobile,
> some CSS changes are at least to be taken into consideration and maybe I
> can help a bit.

Pull requests are definitely welcome. Please!

We already put in many changes for mobile, but I know there are lots
more to make. While we tested on mobile, it wasn't our primary dev
platform.

For example, if someone wanted to switch the javascript controls to
using jqueryui mobile, that would be fantastic. We will probably look
at this during the fall semester if no one does it before then.

Thanks,

Jason


Andrea Lazzarotto

unread,
Jul 21, 2012, 6:45:41 AM7/21/12
to sage-n...@googlegroups.com


2012/7/21 Jason Grout <jason...@creativetrax.com>

Pull requests are definitely welcome.  Please!

Ok, looks like I'll have to learn to use git. XD I'm mainly used to develop web sites so I'm a bit n00b on this matter, but I'll try to see what I can do. :)

Jason Grout

unread,
Jul 21, 2012, 6:53:07 AM7/21/12
to sage-n...@googlegroups.com
On 7/21/12 5:45 AM, Andrea Lazzarotto wrote:
>
>
> 2012/7/21 Jason Grout <jason...@creativetrax.com
> <mailto:jason...@creativetrax.com>>
>
> Pull requests are definitely welcome. Please!
>
>
> Ok, looks like I'll have to learn to use git. XD I'm mainly used to
> develop web sites so I'm a bit n00b on this matter, but I'll try to see
> what I can do. :)

Learning git is very valuable, but you can also just edit the files
right on the github website without learning git. Just go to the file
to edit [1], click "Edit" in the upper left (after logging in), change
the code (or paste in your new version), and then save and submit pull
request.

Thanks,

Jason


[1] like this:
https://github.com/sagemath/sagecell/blob/master/contrib/ipython-testing/static/sagecell.css

Jason Grout

unread,
Jul 21, 2012, 6:55:58 AM7/21/12
to sage-n...@googlegroups.com
On 7/21/12 4:45 AM, Ivan Andrus wrote:
> On Jul 20, 2012, at 9:38 PM, Jason Grout wrote:
>
>> Hi everyone,
>>
>> We'd like to announce a beta of the new version of the Sage cell
>> server. We've set it up at:
>>
>> aleph2.sagemath.org
>>
>> It uses websockets (via SockJS, so it falls back to older
>> techniques if the browser doesn't support websockets) and has been
>> pretty much completely rewritten to use much more of the new
>> IPython framework. While hopefully the only changes from aleph
>> you'll notice are that it is more responsive (something like 25-50%
>> faster for updates on interacts, it feels like), it also lays the
>> groundwork for interactive javascript controls and other features
>> we've wanted for a long time.
>>
>> So please, test it out: aleph2.sagemath.org (if you've embedded
>> aleph in any webpages, you should be able to just change the
>> address to aleph2.sagemath.org). Sometime soon, we'll switch
>> aleph.sagemath.org over to the new version. If you find an issue
>> with aleph2, please let us know.
>
> Well, the iPhone client doesn't work on it because I get a 404 on
> http://aleph2.sagemath.org/eval. That's all I see at
> https://github.com/sagemath/sagecell/blob/master/doc/web_service.rst.
> Is there another branch that I should use, or has the documentation
> just not been updated yet?

Ah, then that makes sense. We haven't developed the /eval service yet
[1]. But that will be finished before we switch aleph over. I didn't
realize the iOS app used it when I asked about it above.

The docs have not been updated yet. In fact, the code lives in the
contrib/ipython-testing directory so we could easily develop it in
parallel with version 1.

Thanks,

Jason

[1] Alex Kramer made progress here:
https://github.com/sagemath/sagecell/blob/master/contrib/ipython-testing/handlers.py#L175,
but it's not production-ready yet, I think because it is still polling
instead of being event driven.

Ivan Andrus

unread,
Jul 21, 2012, 10:41:51 AM7/21/12
to sage-n...@googlegroups.com
On Jul 21, 2012, at 12:55 PM, Jason Grout wrote:
> On 7/21/12 4:45 AM, Ivan Andrus wrote:
>> Well, the iPhone client doesn't work on it because I get a 404 on
>> http://aleph2.sagemath.org/eval. That's all I see at
>> https://github.com/sagemath/sagecell/blob/master/doc/web_service.rst.
>> Is there another branch that I should use, or has the documentation
>> just not been updated yet?
>
> Ah, then that makes sense. We haven't developed the /eval service yet [1]. But that will be finished before we switch aleph over. I didn't realize the iOS app used it when I asked about it above.

Is there something different that I should be using now?

> The docs have not been updated yet. In fact, the code lives in the contrib/ipython-testing directory so we could easily develop it in parallel with version 1.

I kind of figured. :-)

-Ivan

Jason Grout

unread,
Jul 22, 2012, 12:48:28 AM7/22/12
to sage-n...@googlegroups.com
On 7/21/12 9:41 AM, Ivan Andrus wrote:
> On Jul 21, 2012, at 12:55 PM, Jason Grout wrote:
>> On 7/21/12 4:45 AM, Ivan Andrus wrote:
>>> Well, the iPhone client doesn't work on it because I get a 404 on
>>> http://aleph2.sagemath.org/eval. That's all I see at
>>> https://github.com/sagemath/sagecell/blob/master/doc/web_service.rst.
>>> Is there another branch that I should use, or has the documentation
>>> just not been updated yet?
>>
>> Ah, then that makes sense. We haven't developed the /eval service yet [1]. But that will be finished before we switch aleph over. I didn't realize the iOS app used it when I asked about it above.
>
> Is there something different that I should be using now?

It would be better to use websockets and process the JSON messages.
Then you could support native interact controls, results updating as
they are output, etc., instead of just getting stdout at the end of the
computation.

Thanks,

Jason


P Purkayastha

unread,
Jul 22, 2012, 1:09:18 AM7/22/12
to sage-n...@googlegroups.com
An unrelated question. Is there any way to stop a computation? Some
small program like this will take forever:

ifact = 1; i = 5;
while i > 0:
ifact *= i;
ifact -= 1; # typo: it should be i, so that we get factorial(i)

Suppose I do this typo and realize just a bit too late that it has gone
into an infinite loop. An interrupt/cancel button would make it possible
to cancel this computation. If I close the page, will the computation
stop running on the server?

Jason Grout

unread,
Jul 22, 2012, 1:27:50 AM7/22/12
to sage-n...@googlegroups.com
The server has a CPU time limit for computations. There is underlying
capability for interrupting too, but it's not exposed yet.

Thanks,

Jason


Jason Grout

unread,
Jul 23, 2012, 5:44:28 AM7/23/12
to sage-n...@googlegroups.com
Wait; I was confused. Ignore what I said in the above paragraph; you
were doing things correctly with /eval.

For version 2 of the server, it goes like this:

POST or GET request aleph2.sagemath.org/kernel, with a custom HTTP header of

Accept: application/json

That will return a JSON dictionary that looks like this:

{"kernel_id": "ce20fada-f757-45e5-92fa-05e952dd9c87", "ws_url":
"ws://localhost:8888/"}

Then open up websocket channels to the two URLs:

shell channel: <ws_url>/kernel/<kernel_id>/shell
iopub channel: <ws_url>/kernel/<kernel_id>/iopub

Then send an execute_request message on the shell channel, following the
ipython format [1].

Then listen on the iopub channel for messages until you get a kernel
status idle message, and also listen on the shell channel until you get
an execute_reply message.

You'll get a kernel dead message on the iopub channel when the cell
times out. If you don't have interacts, it will time out pretty much
immediately. If you do have interacts, then the timeout is something 30
or 60 seconds between execute_requests.

I put up a short client illustrating this at
https://github.com/sagemath/sagecell/blob/master/contrib/sagecell-client/sagecell-client.py
(requires the python websocket-client package to be installed).

Also, we changed interact messages to be more standard IPython messages.
They are no longer "interact_prepare" messages, but instead come as
"display_data" messages with a mime type of "application/sage-interact".

Thanks,

Jason


[1] http://ipython.org/ipython-doc/dev/development/messaging.html#execute

Jason Grout

unread,
Jul 23, 2012, 5:50:05 AM7/23/12
to sage-n...@googlegroups.com
On 7/23/12 4:44 AM, Jason Grout wrote:
> That will return a JSON dictionary that looks like this:
>
> {"kernel_id": "ce20fada-f757-45e5-92fa-05e952dd9c87", "ws_url":
> "ws://localhost:8888/"}

If you request from aleph2, the ws_url should be ws://aleph2.sagemath.org/.

Thanks,

Jason

Jason Grout

unread,
Jul 24, 2012, 1:42:27 AM7/24/12
to sage-n...@googlegroups.com
On 7/20/12 2:38 PM, Jason Grout wrote:
> We'd like to announce a beta of the new version of the Sage cell server.
> We've set it up at:
>
> aleph2.sagemath.org

We've addressed a number of issues that people brought up with version
2. Thanks everyone for the feedback!

I just switched aleph.sagemath.org to be an alias for
aleph2.sagemath.org (which also automatically switches
interact.sagemath.org and the wiki to use aleph version 2). Version 1
is still active at aleph1.sagemath.org (that's "aleph one"). If you
have shortened temporary links with aleph version 1, they will still
work with aleph1.sagemath.org (just change the address). We'll keep
aleph1.sagemath.org up for a little bit, anyway, so that people can
access their shortened URLs and so that the iOS and Android apps will
keep working.

Keep the feedback coming!

Thanks,

Jason

[1] Technical detail: The android and iphone apps still work since I set
things up so that if you use aleph.sagemath.org/eval or /output_poll or
/files (those are URLs specific to aleph version 1), it will
automatically still send you to aleph version 1. That way the apps can
migrate to use the aleph2 way of doing things when they have time.

Benjamin Jones

unread,
Jul 24, 2012, 10:51:58 PM7/24/12
to sage-n...@googlegroups.com
The Wiki isn't loading, e.g. http://wiki.sagemath.org/SageAppliance
sits and spins, looking for aleph.sagemath.org. This must be somehow
related to the change?

--
Benjamin Jones

Jason Grout

unread,
Jul 25, 2012, 12:23:04 AM7/25/12
to sage-n...@googlegroups.com
On 7/24/12 9:51 PM, Benjamin Jones wrote:

>
> The Wiki isn't loading, e.g. http://wiki.sagemath.org/SageAppliance
> sits and spins, looking for aleph.sagemath.org. This must be somehow
> related to the change?

It should be up now. Thanks for the heads up.

Jason

Reply all
Reply to author
Forward
0 new messages