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
feat(unstable): add Deno.jupyter.broadcast
API
#20656
Conversation
@rgbkrk this adds |
It looks like you need more of the payload (data, metadata). I'll dive in shortly with this branch. |
I think it's ok to show I still need some way to send |
runtime/js/90_deno_ns.js
Outdated
async sendIo(content) { | ||
await core.opAsync("op_jupyter_send_io", content); | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆒 now I know
PR to add the ability to send an arbitrary IOPub message: bartlomieju#4 |
feat(jupyter): accept message type in jupyter io publish call
runtime/js/90_deno_ns.js
Outdated
@@ -178,6 +178,11 @@ const denoNsUnstable = { | |||
Kv: kv.Kv, | |||
KvU64: kv.KvU64, | |||
KvListIterator: kv.KvListIterator, | |||
jupyter: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Deno.jupyter
should only exist if we're running within the context of deno jupyter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually want to make it a getter that will throw an informative error in non-Jupyter context 👍
What else do we need for this? Tests? I'm delighted to start using it within libraries. |
@rgbkrk no blockers, I'll try to finish it tonight so we can ship it in |
Deno.jupyter
API
Deno.jupyter
APIDeno.jupyter.broadcast
API
function enableJupyter() { | ||
denoNsUnstable.jupyter = { | ||
async broadcast(msgType, content) { | ||
await core.opAsync("op_jupyter_broadcast", msgType, content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ensureFastOps
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes no difference since it's using serde_json::Value
which has no chance to ever be a fast call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better performing than opAsync
in general because it doesn't use the spread operator -- we generate overloads for the correct number of args.
In this case it's not critical but generally we should avoid using opAsync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it in a follow up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
() => Deno.jupyter, | ||
"Deno.jupyter is only available in `deno jupyter` subcommand.", | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should we test the actual functionality under Deno.jupyter
? Do we have to somehow monkeypatch to allow it then test it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added another cell in integration_test.ipynb
notebook - if you run it manually there should be no changes in Git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhh beautiful
* @category Jupyter */ | ||
export function broadcast( | ||
msgType: string, | ||
content: Record<string, unknown>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
"traceback": [ | ||
"Stack trace:", | ||
"TypeError: Cannot read properties of undefined (reading 'broadcast')", | ||
" at <anonymous>:2:20" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooops, git played a fool out of me. This should have been actual output. I will fix it in a follow up
Closes #20591