-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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(jupyter-kernel): accept nested objects from display calls #20537
feat(jupyter-kernel): accept nested objects from display calls #20537
Conversation
2eb9464
to
acadecd
Compare
@domoritz -- jupyter kernel for deno pushing vegalite for rendering ^^ |
acadecd
to
c2be89e
Compare
I will have to take a closer look at this! It may actually fix the promise error reported in a different bug, but I'm not totally sure we want to go through JSON for everything. |
Unless I'm mistaken this is only for when an object has the |
By the way I only started learning Rust because of this project so please feel free to treat my code as such. 🙃 |
d2ddd4a
to
8c879da
Compare
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.
One small change, but I think this looks good.
This doesn't handle the case when someone throws inside of their |
cli/tools/jupyter/server.rs
Outdated
eprintln!("Unexpected response from Jupyter.display: {:?}", json_str); | ||
eprintln!( | ||
"Unexpected response from Jupyter.display: {:?}", | ||
response.result.clone().value.unwrap_or_default() |
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.
Skip the unwrap_or_default
call here as the "debug"-style print (ie: :?
) will show us the None
.
Looking good! One very small last change and we can merge this. |
350ecdd
to
b1599ea
Compare
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!
Thanks for the quick fixes, @rgbkrk |
Thanks for the review! We can do some really cool things now. 😄 |
…for("Jupyter.display")` (#20546) Fast follow up to #20537. Before: ![image](https://github.com/denoland/deno/assets/836375/8a12e83d-9008-419b-bd1f-24c0ac90afd3) After: <img width="235" alt="image" src="https://github.com/denoland/deno/assets/836375/467bf381-278e-4577-a980-7b0ddb08d2af"> --------- Co-authored-by: Matt Mastracci <[email protected]>
Closes #20535.
Screenshots
JSON
Vegalite
Implementation
Instead of going the route of recursively getting all the objects under
application/.*json
keys, I went withJSON.stringify
ing in denospace then parsing it from rust. One of the key benefits of serializing and deserializing is that non-JSON-able entries will get stripped automatically. This also keeps the code pretty simple.In the future we should only do this for
application/.*json
keys.cc @mmastrac