Skip to content

Commit 7c5c013

Browse files
authored
Merge pull request #225 from rgbkrk/update-display-data
Updatable Displays
2 parents 5d54fe3 + 4776d31 commit 7c5c013

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

docs/messaging.rst

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,12 @@ Message type: ``display_data``::
965965
'data' : dict,
966966

967967
# Any metadata that describes the data
968-
'metadata' : dict
968+
'metadata' : dict,
969+
970+
# Optional transient data introduced in 5.1. Information not to be
971+
# persisted to a notebook or other documents. Intended to live only
972+
# during a live kernel session.
973+
'transient': dict,
969974
}
970975

971976

@@ -994,12 +999,58 @@ and expanded for JSON data::
994999
}
9951000
}
9961001

1002+
1003+
The ``transient`` dict contains runtime metadata that should not be persisted to
1004+
document formats and is fully optional. The only transient key currently defined in Jupyter is
1005+
``display_id``::
1006+
1007+
transient = {
1008+
'display_id': 'abcd'
1009+
}
1010+
9971011
.. versionchanged:: 5.0
9981012

9991013
`application/json` data should be unpacked JSON data,
10001014
not double-serialized as a JSON string.
10011015

1016+
.. versionchanged:: 5.1
1017+
1018+
`transient` is a new field.
1019+
1020+
Update Display Data
1021+
-------------------
1022+
1023+
.. versionadded:: 5.1
1024+
1025+
Displays can now be named with a ``display_id`` within the ``transient`` field of
1026+
``display_data`` or ``execute_result``.
1027+
1028+
When a ``display_id`` is specified for a display, it can be updated later
1029+
with an ``update_display_data`` message. This message has the same format as `display_data`_
1030+
messages and must contain a ``transient`` field with a ``display_id``.
1031+
1032+
.. _update_display_data:
1033+
1034+
Message type: ``update_display_data``::
1035+
1036+
content = {
1037+
1038+
# The data dict contains key/value pairs, where the keys are MIME
1039+
# types and the values are the raw data of the representation in that
1040+
# format.
1041+
'data' : dict,
1042+
1043+
# Any metadata that describes the data
1044+
'metadata' : dict,
1045+
1046+
# Any information not to be persisted to a notebook or other environment
1047+
# Intended to live only during a kernel session
1048+
'transient': dict,
1049+
}
10021050

1051+
Frontends can choose how they update prior outputs (or if they regard this as a
1052+
regular ``display_data`` message). Within the jupyter and nteract_ notebooks,
1053+
all displays that match the ``display_id`` are updated (even if there are multiple).
10031054

10041055
Code inputs
10051056
-----------
@@ -1297,3 +1348,4 @@ Missing things include:
12971348
* Important: finish thinking through the payload concept and API.
12981349

12991350
.. _ZeroMQ: http://zeromq.org
1351+
.. _nteract: https://nteract.io

0 commit comments

Comments
 (0)