sigmaSd / IRust

Cross Platform Rust Repl
https://crates.io/crates/irust
MIT License
622 stars 34 forks source link

Improve Jupyter kernel support #108

Open sigmaSd opened 1 year ago

sigmaSd commented 1 year ago

Discussed in https://github.com/sigmaSd/IRust/discussions/107

Originally posted by **baiguoname** November 30, 2022 Jupyter is amazing, can I use Irust in Jupyter, especially in vscode-jupyter.
baiguoname commented 1 year ago

Any updating in this feature? I believe there are many people like me is waiting for this.

sigmaSd commented 1 year ago

I just want to reiterate that tere is already evcxr which have jupyter support, I'm sure they would accept feature requests for missing features

The problem with jupyterr and rust, is we don't have a real repl yet as in the code needs to be recompiled each time, so it's really slow, compare that to the instantaneous experience of Python and Julia for example

To answer your question, unfortunately I don't have time to work on it now, I'll try to get to it when I can or maybe someone can send a pr

sigmaSd commented 1 year ago

I reread the jupyter docs and the implementation here https://github.com/sigmaSd/IRust/tree/master/crates/irust_repl#jupyter-kernel

what I see is:

But I don't want to go through the effort of adding this, without knowing how people use it, so my plan for now is to wait for feedback on the current implementations:

And I'll try to keep fixing low hanging fruits, until the picture is more clear and I can start on the rework

baiguoname commented 1 year ago

I put the re.exe in the same directory of irust.py, and change the absolute absolute_path/re path in irust.py to relative path re. And then run jupyter from the directory. Then everything works fine, the jupyter just run magically as fast as like running the python on jupyter. But I have an uncertainty: Liking using irust_repl in terminal, each time I executing an input, the already inserted code to the Repl object will run again. I am using irust_repl in an website server, which accept input codes at once and run the all input codes then return output. So the behavior of rerunning the inserted codes have no effect on my website server. But I thought it may have effects when running irust_repl in jupyter. As I know, the common process of using jupyter is running the cells over and over again without restarting the kernel. So if the inserted codes have some heavy task of computing, it will take some unnecessary time to rerun these codes.

sigmaSd commented 1 year ago

Yes unfortunately that's a core limitation to this project, it's just how it works

sigmaSd commented 1 year ago

I improved the installation experience https://github.com/sigmaSd/IRust/blob/master/crates/irust_repl/README.md#jupyter-kernel

Now to use the kernel you just need:

pip install irust_kernel
python -m irust_kernel.install
sigmaSd commented 1 year ago

I added support for evcxr protocol, so now you can use programs that targets it, example: https://github.com/sigmaSd/IRust/blob/master/crates/irust_repl/irust_kernel/evcxr.ipynb