Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Transmit Cell Metadata #70

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updating to transmit metadata in message header
  • Loading branch information
jflam committed Jun 14, 2021
commit 0bd5cd25fc8887c6101ab646057e5bc283532ce9
19 changes: 10 additions & 9 deletions zz-cell-metadata/transmit-cell-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,19 @@ The general form of a message is:
"header" : {
"msg_id": "...",
"msg_type": "...",
"metadata": {},
//...
},
"parent_header": {},
"metadata": {},
"content": {},
"buffers": [],
}
```

We propose the addition of a new `metadata` dict to the `header` dict schema
in [nbformat](https://nbformat.readthedocs.io/en/latest/). This will be used
to transmit the cell metadata for the executed cell.
We propose adding cell metadata to the existing `message.metadata` dict
[see Jupyter client
docs](https://jupyter-client.readthedocs.io/en/stable/messaging.html#metadata).
This will be used to transmit the cell metadata for the executed cell.

In cases where Jupyter extensions generate their own metadata, that keys for
jflam marked this conversation as resolved.
Show resolved Hide resolved
the metadata should be namespaced using an extension-specific prefix. The
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be a good idea to recommend a sub-dictionary as well for this. There's no requirement (or even recommendation) that metadata be a one-level dict. If an extension has more than one or two settings, it probably makes sense to nest a dict.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea; do you think that existing implementations might make the incorrect assumption that there aren't nested dicts, i.e., this change would break existing implementations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in the python layer all of the library interactions within jupyter / nteract don't expect single layer dicts. I'd be surprised if the UIs did either since there's already multi-layer dicts present in nbformat fields.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be nothing that prevents transmission (and a space-limited journal; storage) of nested dicts i.e. with schema: JSONschema-validateable [nested] JSON and/or W3C SHACL-validateable JSON-LD with URIs for migrateable Linked Data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any risk associated with it. Dicts are generally nested throughout Jupyter and the only spec for metadata is that it's a JSONable dict, which can have aribtrary depth, just like is already true for header, content, etc. which can also have nested fields.

Expand Down Expand Up @@ -214,14 +215,14 @@ Below is the corresponding EXECUTE message:
"header" : {
"msg_id": "...",
"msg_type": "...",
"metadata": {
"allthekernels:kernel": "python3",
"collapsed": True,
"scrolled": False,
},
//...
},
"parent_header": {},
"metadata": {
"allthekernels:kernel": "python3",
"collapsed": True,
"scrolled": False,
},
"content": {
"code": "1+1",
},
Expand Down