Discover more from hrbrmstr's Daily Drop
Bonus Drop #29 (2023-10-15): Cracking The Nut
Consuming A New JS Jupyter Kernel
Today's title is a (major) stretch on an older idiom/proverb that ultimately reduces to: “if you desire something good or appealing, you must make the necessary effort to achieve it”. This is quite appropro, too, since today just happens to be where the planet was when your friendly neighborhood hrbrmstr emerged (ref). That does mean you'll be doing most of the work/digging after we introduce the resource.
I’m also using the emergence celebration occasion to riff from “Through the Looking-Glass” and am unlocking the normally paywalled Bonus Drop for all. Unbirthdays are way cooler than birthdays, and I suspect none of my subscribers share this day in common with me. I also suspect the Bonus Drop sponsors won’t mind sharing.
hrbrmstr's Daily Drop is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.
Jupyter Kernel For Deno
Despite not being a fan of Jupyter notebooks, they are useful in a pinch (I mean, we use manure to grow crops, so we can definitely use the digital equivalent of it — Python — for other types of positive production, right?).
If you've got a local Deno installation, you may need to do:
$ deno upgrade
before heading into the next section.
The v1.37 intro blog has more setup info and basic examples if you want to dig in a bit more, too.
Kicking The Tyres
Now that Deno is installed to the latest version, and you have Jupyter infesting your system, you can install the new kernel via:
$ deno jupyter --unstable
Once more, v1.37 intro blog does a fine job explaining the initial setup and creation of a new notebook. Lean on it if you’re new to this space. It’s a great resource.
The notebook cells are TypeScript cells, not vanilla JS cells, as Deno inherently groks TypeScript. While I prefer JSDoc type hints over TypeScript-proper, having a typed shim over JS machinations isn't such a bad thing, especially if you're going to use Deno for more data-science-y work.
If you’re not mildly familiar with Deno, I highly suggest running through the “Basics” section of Deno by Example before jumping to the next section. Folks familiar with NPM should also tap this link before progressing.
Drop & Run
As noted in the preamble, there are Many Happy Returns of the Day for me to tend to. But, you are not being left empty-handed!
I've made a pretty thorough, but short, example of how to use the new Deno kernel to:
import some JS packages
load up some JSON data
create a fake DOM (so we can render things properly)
build an Observable Plot
display said plot
Now, one SUPER COOL thing about Deno having a Jupyter kernel is that we can now use it Quarto documents! To that end, I've “code-tools” enabled this Quarto rendered HTML, so you can see the source that generated the document.
Aside: Deno seems like it might just be a better alternative to the OJS runtime that you get out of the box with Quarto, but I'll need to dig into that more to fully stand by the assertion.
For the Notebook fans out there, I've rendered this ipynb to this HTML via the standard
nbconvert dance. I also tested the notebook in Jupyter, Jupyter Lab, and the VS Code Jupyter environment. It works great in all those contexts.
Keep kicking the tyres and give a shout if you end up making something with this new runtime! ☮