Kotlin / kotlin-jupyter

Kotlin kernel for Jupyter/IPython
Apache License 2.0
1.1k stars 105 forks source link

Add API to integration library to detect jupyter context #352

Closed holgerbrandl closed 2 years ago

holgerbrandl commented 2 years ago

We can use classes from the main kernel artifact to test if code is running within the jupyter kernel. (e.g. try-catch around Class.forName("org.jetbrains.kotlinx.jupyter.ReplForJupyter"))

However, to streamline developer experience this could also be exposed as an integration library function.

ileasile commented 2 years ago

Use JupyterSessionInfo.isRunWithKernel()

holgerbrandl commented 2 years ago

Beautiful, thanks a lot.

holgerbrandl commented 9 months ago

Not sure if this is a regression, but with the latest integration plugin 0.12.0-81 and kotlin 1.9.10 isRunWithKernel() returns true when called from IDE (without any Jypyter in sight). In debug view it seems the provider which is used for the detection is present : image

holgerbrandl commented 8 months ago

I've also tested this with v0.12.0-82-1. It's indeed a regression: JupyterSessionInfo.isRunWithKernel() returns true when running in a simple JVM kotlin application.