On 12/14/11 2:09 PM, Volker Braun wrote:
On Wednesday, December 14, 2011 7:37:33 PM UTC, jason wrote:

     > 1) When evaluating a cell, I also get all previous responses back
     > (previous msg_ids). Is there a way to omit the history?

    You can specify a starting "sequence number" for the message history.
    When you get the history back, each message has a sequence number.


That didn't work for me when I tried it a few days ago. What I did was
1) keep parent_header->session a fixed UUID
2) make multiple requests with new parent_header->msg_id UUIDs

Then the sequence number starts at 0 for each new msg_id. But now I
realized that the single cell server web page sends each command with a
new session and a new msg_id. Am I doing it wrong?


Yes, I think so. It would be good to read at least the ideas behind the ipython messaging spec.

Typically messages are in a request-reply pattern (with possibly multiple replies). A request will have a header field. A reply will contain the request's header field as the parent_header field. That way you can determine which messages are replying to which request. A message should never generate its own parent_header (it should always just copy in the header from the message it is replying to). (yes, I know that we violate that occasionally by just copying in certain fields rather than the whole header.)

The header field is what a message gets to set itself. The header.msg_id should be a unique identifier for the message. The header.session should be an identifier for the session, and should be the same across all messages in a session.

Right now, our initial requests and output_poll requests don't use JSON, but rather use POST or GET fields. I think this should probably change to make things consistent, or we should just really set up a web service that accepts JSON queries.

To send an initial computation, use the following POST data sent to the /eval URL:

commands: string of commands to execute
session_id: make up some string identifier, it shouldn't matter what it is
msg_id: make up some other string identifier, it shouldn't matter what it is
sage_mode: whether to execute using Sage ("True") or plain python ("False")

To poll for output, send a GET request to /output_poll with the following fields:

computation_id: the session id from the original /eval message (yes, we should change that name to session_id instead of computation_id)

sequence: the first sequence number to get back (starting with 0). Messages for the session with sequence number greater than or equal to this will be sent back to you.

The webserver takes care of converting your /eval message into the appropriate ipython-like execute_request JSON message. You shouldn't have to deal with any parent_header information anywhere.

Thanks,

Jason

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to