rapaio-jupyter-kernel icon indicating copy to clipboard operation
rapaio-jupyter-kernel copied to clipboard

option for jbang install variation

Open maxandersen opened this issue 2 years ago • 8 comments
trafficstars

I realized that this is possible:

add a kernel.json with this:

{
  "argv": [
    "jbang",
    "--verbose",
    "--enable-preview",
    "--java",
    "21",
    "-R--add-modules",
    "-Rjava.base,jdk.incubator.vector",
    "io.github.padreati:rapaio-jupyter-kernel:RELEASE",
    "{connection_file}"
  ],
  "display_name": "Java (JBang Rapaio Jupyter)",
  "language": "java",
  "interrupt_mode": "message",
  "env": {
    "RJK_COMPILER_OPTIONS": "",
    "RJK_INIT_SCRIPT": "",
    "RJK_TIMEOUT_MILLIS": "-1"
  }
}

no install of the .jar necessary and you can use RELEASE like here or specific version and you have rapaio working on your jupyter :)

maxandersen avatar Nov 04 '23 07:11 maxandersen

just leaving it here to share - not sure if can become something provided. like a --jbang option to the installer.

maxandersen avatar Nov 04 '23 07:11 maxandersen

like, doing this on google colab:

!pip3 install jbang
import jbang
jbang.exec("--java", "21", "io.github.padreati:rapaio-jupyter-kernel:RELEASE", "-i", "-auto").stdout

rapaio jupyter actually becomes available as a possible runtime to select.

now imagine if we had a --jbang option or somehow could have it generate with java call to jbang install java 21...that could be interesting for #24

maxandersen avatar Nov 04 '23 07:11 maxandersen

I did try this on collab:

%%bash 
echo '{
  "argv": [
    "/root/.jbang/bin/jbang",
    "--verbose",
    "--enable-preview",
    "--java",
    "21",
    "-R--add-modules",
    "-Rjava.base,jdk.incubator.vector",
    "io.github.padreati:rapaio-jupyter-kernel:RELEASE",
    "{connection_file}"
  ],
  "display_name": "Java (JBang Rapaio Jupyter)",
  "language": "java",
  "interrupt_mode": "message",
  "env": {
    "RJK_COMPILER_OPTIONS": "",
    "RJK_INIT_SCRIPT": "",
    "RJK_TIMEOUT_MILLIS": "-1"
  }
}' > /root/.local/share/jupyter/kernels/rapaio-jupyter-kernel/kernel.json

and it does regsiter but then I realized the ipc issue in #24 prevents this from working anyway.

bummer :)

maxandersen avatar Nov 04 '23 07:11 maxandersen

so I managed to get this working. not only with rapaio but with other java kernels.

!pip install jbang
import jbang
jbang.exec("trust add https://github.com/jupyter-java")
jbang.exec("install-kernel@jupyter-java rapaio")

On google colab if detected it will wire up an ipc proxy.

Started documenting this and more at https://github.com/jupyter-java.

maxandersen avatar Nov 25 '23 08:11 maxandersen

Impressive work. I will advertise that as the default option for installing the kernel. The more I know about jbang, the more I like it. I tried that and my preferred way is to add the --enable-preview option.

!pip install jbang
import jbang
jbang.exec("trust add https://github.com/jupyter-java")
jbang.exec("install-kernel@jupyter-java rapaio --enable-preview")

padreati avatar Feb 23 '24 23:02 padreati

This works too, directly from jbang without the pip stage (thanks to the https://github.com/jupyter-java/jbang-catalog):

$ jbang install-kernel@jupyter-java rapaio

Or maybe it only works because I also installed the jbang module in Python?

dsyer avatar Jun 19 '24 07:06 dsyer

@maxandersen are you maintaining that jupyter-java repo? I submitted a couple of PRs ages ago, e.g: https://github.com/jupyter-java/jbang-catalog/pull/2.

dsyer avatar Sep 02 '24 13:09 dsyer

@dsyer damn - somehow i missed those! let me check!

maxandersen avatar Sep 02 '24 13:09 maxandersen