WIP: output extractor: infer data encoding from output metadata #858
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed with @minrk, with more media formats being added to the mimebundle, the logic of output extraction becomes harder to extend. For example if an application adds a new base64 encoded mimetype,
ExtractOutputPreprocessor
would need to be explicitly patched to handle this.This PR defines an alternative mechanism for extensions communicating how to handle their outputs, specifically by defining
output.metadata[mime_type]['encoding']
entry, which instructs the frontend how the output must be interpreted. Currently there are only 3 supported encodings:json
for json objectsutf8
for unicode stringsbase64
for binary dataThis would for example allow to extend
IPython.display.Audio
andIPython.display.Video
objects to publish the source files directly. One concern, however, is that they would still need to provide_repr_html_
and therefore would need to double the amount of data in the notebook.