Pass cell/notebook metadata through to kernel

167 views
Skip to first unread message

Christopher Brooks

unread,
Sep 24, 2017, 12:50:43 PM9/24/17
to Project Jupyter
Hi,

We've created our own kernel wrapper which just calls the regular python kernel but does some logging. I'd like to log some cell metadata as well, but it doesn't look like this is being passed on the wire (at least, not from my digging with the chrome dev tools). Is there a way to configure the jupyter frontend to pass this metadata across to the kernel? If not configure, suggestions on what methods we might need to overwrite in the front end to achieve this? Could a client side extension handle this, or do we have to do more significant surgery?

Regards,

Chris

MinRK

unread,
Sep 25, 2017, 4:57:02 AM9/25/17
to Project Jupyter

This is certainly technically possible because there is a metadata field in the messages. However, it may be tricky to pluck the metadata from the cell and add it to the request, given the current APIs.

The cell submits the execution here and there’s no clear way to override that to add additional arguments. Similarly, kernel.execute doesn’t expose the metadata field as an argument.

So I’d say that the ‘real’ fix is to:

  1. expose metadata args in the kernel API (especially execute, but all message-sending methods should support it)
  2. allow passing metadata to execute somehow in the CodeCell API

You might be able to work around the current state with some finagling, but it will probably be difficult to do it in a reliable way without some support from the API. Perhaps jupyterlab has better support for the metadata field that would make this easier.

-Min


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/a8bb9619-7c9d-4c08-aa68-f5cd16a5f382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Grout

unread,
Sep 25, 2017, 8:55:25 AM9/25/17
to Project Jupyter

On Mon, Sep 25, 2017 at 2:57 AM MinRK <benja...@gmail.com> wrote:

This is certainly technically possible because there is a metadata field in the messages. However, it may be tricky to pluck the metadata from the cell and add it to the request, given the current APIs.

The cell submits the execution here and there’s no clear way to override that to add additional arguments. Similarly, kernel.execute doesn’t expose the metadata field as an argument.

So I’d say that the ‘real’ fix is to:

  1. expose metadata args in the kernel API (especially execute, but all message-sending methods should support it)
  2. allow passing metadata to execute somehow in the CodeCell API

You might be able to work around the current state with some finagling, but it will probably be difficult to do it in a reliable way without some support from the API. Perhaps jupyterlab has better support for the metadata field that would make this easier.

-Min

On Sun, Sep 24, 2017 at 6:50 PM, Christopher Brooks <broo...@umich.edu> wrote:
Hi,

We've created our own kernel wrapper which just calls the regular python kernel but does some logging. I'd like to log some cell metadata as well, but it doesn't look like this is being passed on the wire (at least, not from my digging with the chrome dev tools). Is there a way to configure the jupyter frontend to pass this metadata across to the kernel? If not configure, suggestions on what methods we might need to overwrite in the front end to achieve this? Could a client side extension handle this, or do we have to do more significant surgery?

Regards,

Chris

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/a8bb9619-7c9d-4c08-aa68-f5cd16a5f382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Christopher Brooks

unread,
Sep 28, 2017, 11:45:27 AM9/28/17
to Project Jupyter
Thanks Min, this is very helpful. So I think our plan now is to monkeypatch the client side CodeCell.execute() and change the contents to send across metadata as well, then have our kernel wrapper deserialize this an extra data before passing things to the stock ipython kernel. Hacky, but would get us a proof of concept. If this seems to work for our use case, we'll consider submission criteria for lab once it's out!

Appreciate the deep link to the code, made this quick on our end!

Chris


On Monday, September 25, 2017 at 4:57:02 AM UTC-4, Min RK wrote:

This is certainly technically possible because there is a metadata field in the messages. However, it may be tricky to pluck the metadata from the cell and add it to the request, given the current APIs.

The cell submits the execution here and there’s no clear way to override that to add additional arguments. Similarly, kernel.execute doesn’t expose the metadata field as an argument.

So I’d say that the ‘real’ fix is to:

  1. expose metadata args in the kernel API (especially execute, but all message-sending methods should support it)
  2. allow passing metadata to execute somehow in the CodeCell API

You might be able to work around the current state with some finagling, but it will probably be difficult to do it in a reliable way without some support from the API. Perhaps jupyterlab has better support for the metadata field that would make this easier.

-Min

On Sun, Sep 24, 2017 at 6:50 PM, Christopher Brooks <broo...@umich.edu> wrote:
Hi,

We've created our own kernel wrapper which just calls the regular python kernel but does some logging. I'd like to log some cell metadata as well, but it doesn't look like this is being passed on the wire (at least, not from my digging with the chrome dev tools). Is there a way to configure the jupyter frontend to pass this metadata across to the kernel? If not configure, suggestions on what methods we might need to overwrite in the front end to achieve this? Could a client side extension handle this, or do we have to do more significant surgery?

Regards,

Chris

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages