Open oscar6echo opened 2 months ago
I guess you're basically asking for HMR (hot module replacement) for the Jupyter kernel. I'm open to accepting PRs that would implement it, but I'm gonna shout out to @rgbkrk for opinions on this one.
As long as it's possible in Deno/V8, I'd start with making a Deno centric API like Deno.reload(module)
. It's not something on the Jupyter protocol, it's a language and/or runtime feature.
I guess you're basically asking for HMR (hot module replacement) for the Jupyter kernel.
Roughly yes. But HMR as I understand it, maybe wrongly, is a full reset.
So for the avoidance of doubt. please let me be specific: Here the objective is to keep the state unchanged while updating the code run for the next cells executed (for a full reset a kernel restart does the job). This is already possible in the example I give but maybe there is a better, more generic, less verbose way to do it, that would benefit deno and its users.
As a heavy user of jupyter (mostly with python kernels) I would like to outline the large benefit of the autoreload IPython extension and suggest that such a feature could be added/documented in deno jupyter.
Why the benefit ?
It allows a Jupyter user to edit and iterate on a Python class in an IDE (say VS Code) and manipulate instances of such class in a Jupyter notebook which acts as a "control center". Upon change in a method, it can be run immediately in the notebook without kernel restart or even class recreation. This is a massive benefit when dealing with states that are long to reach (e.g. long downloads or computations). Additionally this workflow leverages each tool qualities: VS Code with all the linting/formatting/code completion/etc which jupyter cannot match, and jupyter for its step by step execution with visible cell outputs.
(On the other hand working entirely in a notebook does not scale)
Difference with Python:
Python is interpreted while typescript is transpiled. So I guess that the exact same feature is maybe not possible (?)
Tentative implementation:
However by implementing the class in such a way that methods can be replaced after instantiation and leveraging this comment by @nayeemrmn in issue #6946 , I could achieve a decently satisfactory workflow.
See repo ocar6echo/deno-jupyter-autoreload. The code is short enough to be pasted here.
My questions are :
I would be grateful for your view on the topic.