-
Notifications
You must be signed in to change notification settings - Fork 283
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
Any interest in a new message type for transient information? #376
Comments
If I understand you correctly, this has no relation to the current kernel info messages (http://jupyter-client.readthedocs.io/en/stable/messaging.html#kernel-info), but would be a new message (maybe with another name to differentiate it)? |
Yes, you are right. Let me think of a name. It is sort of multi-functional so perhaps |
Note that there already is a transient part of a display_data message: http://jupyter-client.readthedocs.io/en/latest/messaging.html#display-data |
New in 5.1, no wonder I do not know it before.
Are we free to send whatever information in this
to the frontend, JLab would simply ignore it, right? Is there a need to formally change the protocol if I submit a PR to handle other fields of |
Undefined but can be passed without causing any error, right? That means if we handle other fields here, JLab would be able to send transient information to the information/inspection panel that I envisioned, without the need to change protocol and without breaking classic Jupyter. |
Undefined means that the behavior is undefined, but it should be passed along too. In the future keys might be defined that conflict, though. |
My understanding is that the transient namespace is similar to metadata: you're free to use it, but it's recommended that you use the name of your extension (or whatever project is defining the meaning) as a namespace, to minimise the risk of clashes. |
@ivanov, @yuvipanda, and I started work on a new message type that is effectively transient, called the Resource Info Request in jupyter/jupyter#264. It's finely scoped to live metrics collection. Pointing this out mostly to get an idea of how wide protocol changes end up getting worked on. I definitely hear you about comms -- they get hairy because of their looseness. It's super great that you want to make a formal message to use! As for the message type you're proposing, I think this makes sense as My typical bar for creating a new message type is that it's scoped to a particular area. In the cases, like this one, where it's generic the big asks are going to be that the spec is formalized as much as possible and that Any frontend will drop messages they don't understand (at least, they should). In practice anything not understood is effectively transient, so you should definitely feel free in experimenting. 😄 As an aside, since it appears there was some confusion about the |
If it's going to work similarly to a That would mean that frontends unaware of the new functionality would treat it as a normal display output, rather than ignoring it. That may or may not make sense, depending on your use case. |
I agree with @takluyver , I was thinking of placing
but then I think it would be better to have something like
In this way, whereas JLab can send the transient data to a dedicated panel, Jupyter and other frontends can handle transient data as regular |
@rgbkrk , I though of using this type of transient message to display metrics and I actually plan to use it to display such information (e.g. the CPU/MEM usage of %taskinfo magic). My concern was that there are so many different types of "metrics" so unless they are defined really rigorously (like what you did in jupyter/jupyter#264), it is easier just to let the kernel decide how to display such information (e.g. a figure generated by the Where to display the transient information certainly depends on what types of information you would like to display. Whereas the metrics could be displayed, for example, as barcharts in a status bar somewhere, I plan to allow arbitrary |
If you do this on the current display data, even with some |
This would be similar to how we made an |
I agree that a new message type makes more sense than hacking Adding a new message type sounds to me like a fundamental change that needs long and careful contemplation but I created a PR with a draft definition anyway. 😄 |
Maybe using You could even make it possible to target an actual display ID and have an updating area just as the output from one cell. |
Yes conceptually speaking a frontend can create a global output area somewhere with a special
|
In general, display_data messages don't support titles. To me, a title sounds like a metadata argument, which doesn't need to be specified in the message content.
This is sounding more like an ipywidget Output widget, in the vein of https://github.com/jupyter-widgets/jupyterlab-sidecar. |
(CC @SylvainCorlay) |
While frontends (can) ignore a display ID it doesn't know about, encouraging this alters the meaning of the spec for update display messages. I'm not opposed, my sense is that we'd want to be explicit about it in our documentation if it would become something to expect.
Do you mean restricted to the current notebook? You're able to use them across cells:
I definitely agree with @jasongrout on that one -- seems like it could be in the
Yeah, it definitely requires sending an overall payload to update rather than individual changes. @minrk and I went with this to make it simple and consistent (and at the time there weren't any output types that were JSON backed where update diffs made sense). |
This is unrealistic because you are asking kernels to keep a copy of all previous status/progress/debug messages and send them altogether each time. The kernel will either have to maintain a global variable or send a variable to each function that might send an update, and passing and rendering of long content can also cause problems. |
Thanks for the ping @jasongrout. I think we can somewhat relate this to #373 which is about other streaming message types than |
On the subject of displaying things in other parts of the UI (outside of the notebook), you may be interested in the sidecar widget for jupyterlab. This allows to have transient displayed data which is not part of the notebook state. To display something in a sidecar with a prescribed title, you can do. from sidecar import Sidecar
sc = Sidecar(title='Some nice title')
with sc:
print('hello, world')
display(rich_output) @BoPeng does this correspond to your use case? |
IMO, this kind of approach has the advantage of not requiring a new message type. |
@SylvainCorlay This message type is designed for kernels to send any transient information to the frontend. It is meant to be
I have seen other replies that suggest some overlapping use cases and alternative implementations. I think one of the goals of the |
Quick precision: comms and widgeta are not specific to Python. The example with the sidecar shows that using the current protocol, you can get capture outputs and display messages and display them in a separate part of the user interface, and not keep it as part of the state of the document. I don't thonk that comms are especially complex. They are well suited for this kind of usecase. The widgets layer makes it even simpler to use. I fear that we inflate the kernel protocol to reinvent what the comms and widgets protocol solve well. |
It is up to the frontend to decide how to display them but here is what I have in mind for JLab:
This message shows a screenshot of proposed interface where an |
It can't be quite that loose. the spec has to make some assertions about how they should be displayed (i.e. among outputs vs somewhere else). It sounds like you mean that these should never appear in the cells that produce them, so while the UI may decide how "somewhere else" works, it is at least nowhere in the notebook itself. That does point to it being a new message, because if it were treated as a display_data message it would not only be saved when it shouldn't be (generally not a big deal), it would appear in the wrong place (a bigger deal). It also sounds like the two cases of a generic "state" message that gets updated and replaced versus a debug/transient log of regular display-data messages. I don't think the append=True/False method on a single message is a good fit for differentiating these two, since these are two very different use cases and behaviors, with different message patterns, requirements, etc. Maybe this should be reserved for the dedicated 'transient log', and the resource_info_request/reply proposal can serve the sticky state message area? The log approach fits the sidecar model very well, with one missing piece: there isn't currently a way without widgets to create a new output area not part. sending outputs with a specified parent will route them to the appropriate area using all of the existing mechanisms without any need for a new message. What's missing, and what widgets are used for, is creating that output area in the first place. If there were an easier way to create a new output area, then I think this case would be totally covered. |
|
Exactly. These messages should not be saved and displayed with the notebook.
I do not think a "log of regular display-data messages" model fits the use cases of transient messages. To my understanding, transient messages are used to assist interactive data analysis where the content of messages quickly become irrelevant or outdated. For example, the status/progress information of a cell would be useless as soon as the execution is completed; status enquires are valid for the time of enquiry only; the debug information can be tossed away as soon as users examine them, and preview of variables would be outdated as soon as users modify the code and re-execute the cell. So in my opinion transient messages are largely outdated when the user starts to execute the next cell. That is to say, whereas multiple transient messages produced from the execution of a cell (e.g. multiple debug messages) should be kept together, there is no need to keep previous messages in a log. |
We should use comms as a last resort. Comms were intended as an escape hatch to make progress on the widgets years ago without needing to establiash changes to the protocol. This is why they have so few constraints on what they can do.
Comms are very understandable for each of us. Their layer is pretty well established. It certainly can be done. That's not what's being questioned. As @BoPeng points out, they require writing an extension. Which means users have to install it to use it. When a protocol gets built in, frontends can implement functionality in the way that makes sense for them (reminder -- there's not just jupyterlab and nteract -- there's console, nbconvert, papermill, cocalc, kaggle, and many others). On top of that, there's always the sticking point of non-backwards compatibility with the widgets. The kernel and the frontend have to stay in sync. You can't move the frontend forward without moving the kernel forward. As an operator, this is problematic because sometimes you need a kernel that matches old versions of libraries (even if trailing by only a week). This request for a protocol addition is a way to make something formal that we can adapt and version along with the rest of the message spec. |
Just a note on the way we've been handling async jobs within the notebook. For a We do clear the progress bar out once it's done. One important part about how this works is that if this notebook was running with a non-interactive frontend (papermill), we are still writing these updates to disk which means that when viewed in a notebook viewer they can see the progress. This does mean we're storing it in the notebook (with update display data). I could imagine us having other transient information that shouldn't persist and would only be useful in a live session. 🤔 |
One nice thing about the resource info proposal is that it is organized into namespaces. Does this approach what you're hoping for in a title? Am I missing something else, like that you're wanting a dedicated pane to be shown with the title? |
This is clearly out of the scope of transient messages. The SoS kernel also has something similar (remote tasks) but instead of a dedicated "live" progress bar, users are asked to use magics such as |
I will let @minrk answer your question. I do think resource info is a nice thing to have and it is great that it has formal definitions and namespaces, and I would suggest a third tab in the inspector panel that I proposed to display such information. That is to say,
All three tabs display "transient" information during interactive data analysis and can be grouped together in an "inspector" panel. |
Oh cool, this is good to know about. |
I disagree with that statement.
Adding a message type also requires extra development, at a deeper level. Also, JupyterLab was built from the start as a collection of plugins. Installing more should not be considered an issue. Also, which plugins are elected to be part of the base installation is not set in stone. |
I believe transient display data is useful to many kernels. We do not see many plugins of this type because it does not worth the trouble to develop plugins for such "simple" purposes, and these plugins are not welcome anyway, just imagine 10 widgets each displaying transient information from their respective kernels. So whereas "installing more plugins" might not be a problem, limiting kernels from displaying useful transient information is a problem and having multiple plugins with similar purposes would be a bigger problem. The benefits of solving the problem "at a deeper level" are therefore providing a unified solution for the display of transient data and saving kernel developers from the need to create specialized plugins. |
I don't think that there are any intrinsic limitation from using the
widgets API for communicating between kernels and front ends.
You can have a single UI component driven by jupyter widgets for multiple
kernel instances and languages.
Starting with widgets can also help narrow what new messages may be needed
in the future should they be added to the protocol. In the mean time you
can already do a lot with comms and the widgets protocol.
Just for the record, it took about a year for the `comm_info` request /
reply messages to be included in the spec.
…On Wed, May 9, 2018, 23:04 Bo ***@***.***> wrote:
Adding a message type also requires extra development, at a deeper level.
Also, JupyterLab was built from the start as a collection of plugins.
Installing more should not be considered an issue.
I believe transient display data is useful to many kernels. We do not see
many plugins of this type because it does not worth the trouble to develop
plugins for such "simple" purposes, and these plugins are not welcome
anyway, just imagine 10 widgets each displaying transient information from
their respective kernels.
So whereas "installing more plugins" might not be a problem, limiting
kernels from displaying useful transient information is a problem and
having multiple plugins with similar purposes would be a bigger problem.
The benefit of solving the problem "at a deeper level" is therefore
providing a unified solution for the display of transient data and saving
kernel developers from the need to create specialized plugins.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#376 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACSXFmuouY5NrfPobXvFs6HMIYI6WOzQks5tw0vagaJpZM4TytF6>
.
|
Kernels are maintained by different developers. Developing a third-party plugin with a widget and customized comm for multiple kernels is unrealistic. Adding a standard UI with a customized comm that could be replaced with a standard message type (in a year?) does not sound like a good idea either. Given the two-body (message/UI) nature of this message type, I believe some consensus on at least the need for a general solution is needed to push a UI forward. I do not know how such a consensus can be reached (a developer meeting? A poll somewhere?) but I guess I have expressed my ideas clear enough here and will just wait. |
In practice, for jupyter, consensus only gets reached through merging pull requests. Developer meetings are good at establishing what's likely to be merged in some future date. Without a prototype, people are commenting on the idea and it's hard to gain a sense of who is in approval as well as what changes are really needed to be made. @BoPeng -- here's what you need to do to get your idea off the ground and seriously evaluated:
|
Already done (#378 (comment)) although this is just an initial proposal and will likely change.
Just did it for JLab: jupyterlab/jupyterlab#4550
Let me start from JLab as I am actively working on it to port my SoS kernel over, but I certainly need/welcome more advocates. |
Just to add that another nice application of this message type would be source code analysis (as discussed here). Basically, many languages have their own linter tools and it would be nice for the kernel to send linter messages to the frontend during interactive data analysis. |
Whereas a
can be translated to a
but the use of Edit: |
Just a quick update: an UI to display this message type has been proposed for JupyterLab (jupyterlab/jupyterlab#4879). |
Done.
A UI is proposed for JupyterLab (jupyterlab/jupyterlab#4879) with a test extension to create and send |
This was originally posted to the jupyterlab issue tracker (jupyterlab/jupyterlab#4514) but I was told that the topic suits here better.
To my understanding right now a kernel can send messages such as
display_data
,stream
,error
, andexecute_reply
to the frontend, and all messages are displayed in the output area of cells. There are however scenarios where messages are meant to be transient and not part of the notebook. For example,a=1
that does not produce any real output, the kernel might want to display the value ofa
as a side effect of the calculation.All these can be achieved through Jupyter/JupyterLab extensions using customized comm channels but it is non-trivial to develop extensions and all extensions would use different approaches to display the information. I am therefore wondering if a new message type for transient information can be added. Basically,
display_data
, but with an additionaltitle
field to indicate what the message is about. The message was originally namedkernel_info
but it conflicts with the existingkernel_info
message so an appropriate name is needed.ioPub
without need for a customized comm.Frontends can
I do not know how difficult it is to add such a message type but I will be happy to contribute to the work if it is potentially acceptable.
The text was updated successfully, but these errors were encountered: