mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #2051 from jasongrout/stream-metadata
Add a metadata attribute to messages subheader is removed in favor of the new metadata dict, reducing degeneracy.
This commit is contained in:
commit
8b34dfc405
@ -43,6 +43,7 @@ var IPython = (function (IPython) {
|
||||
session : this.session_id,
|
||||
msg_type : msg_type
|
||||
},
|
||||
metadata : {},
|
||||
content : content,
|
||||
parent_header : {}
|
||||
};
|
||||
@ -220,21 +221,21 @@ var IPython = (function (IPython) {
|
||||
// 'set_next_input': set_next_input_callback
|
||||
// }
|
||||
//
|
||||
// The execute_reply_callback will be passed the content object of the execute_reply
|
||||
// The execute_reply_callback will be passed the content and metadata objects of the execute_reply
|
||||
// message documented here:
|
||||
//
|
||||
// http://ipython.org/ipython-doc/dev/development/messaging.html#execute
|
||||
//
|
||||
// The output_callback will be passed msg_type ('stream','display_data','pyout','pyerr')
|
||||
// of the output and the content object of the PUB/SUB channel that contains the
|
||||
// of the output and the content and metadata objects of the PUB/SUB channel that contains the
|
||||
// output:
|
||||
//
|
||||
// http://ipython.org/ipython-doc/dev/development/messaging.html#messages-on-the-pub-sub-socket
|
||||
//
|
||||
// The clear_output_callback will be passed a content object that contains
|
||||
// stdout, stderr and other fields that are booleans.
|
||||
// stdout, stderr and other fields that are booleans, as well as the metadata object.
|
||||
//
|
||||
// The set_next_input_callback will bepassed the text that should become the next
|
||||
// The set_next_input_callback will be passed the text that should become the next
|
||||
// input cell.
|
||||
|
||||
var content = {
|
||||
@ -313,12 +314,13 @@ var IPython = (function (IPython) {
|
||||
reply = $.parseJSON(e.data);
|
||||
var header = reply.header;
|
||||
var content = reply.content;
|
||||
var metadata = reply.metadata;
|
||||
var msg_type = header.msg_type;
|
||||
var callbacks = this.get_callbacks_for_msg(reply.parent_header.msg_id);
|
||||
if (callbacks !== undefined) {
|
||||
var cb = callbacks[msg_type];
|
||||
if (cb !== undefined) {
|
||||
cb(content);
|
||||
cb(content, metadata);
|
||||
}
|
||||
};
|
||||
|
||||
@ -347,9 +349,10 @@ var IPython = (function (IPython) {
|
||||
|
||||
|
||||
Kernel.prototype._handle_iopub_reply = function (e) {
|
||||
reply = $.parseJSON(e.data);
|
||||
var reply = $.parseJSON(e.data);
|
||||
var content = reply.content;
|
||||
var msg_type = reply.header.msg_type;
|
||||
var metadata = reply.metadata;
|
||||
var callbacks = this.get_callbacks_for_msg(reply.parent_header.msg_id);
|
||||
if (msg_type !== 'status' && callbacks === undefined) {
|
||||
// Message not from one of this notebook's cells and there are no
|
||||
@ -360,7 +363,7 @@ var IPython = (function (IPython) {
|
||||
if (output_types.indexOf(msg_type) >= 0) {
|
||||
var cb = callbacks['output'];
|
||||
if (cb !== undefined) {
|
||||
cb(msg_type, content);
|
||||
cb(msg_type, content, metadata);
|
||||
}
|
||||
} else if (msg_type === 'status') {
|
||||
if (content.execution_state === 'busy') {
|
||||
@ -374,7 +377,7 @@ var IPython = (function (IPython) {
|
||||
} else if (msg_type === 'clear_output') {
|
||||
var cb = callbacks['clear_output'];
|
||||
if (cb !== undefined) {
|
||||
cb(content);
|
||||
cb(content, metadata);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user