Do you know if it's possible to create a jupyter-n...
# datascience
h
Do you know if it's possible to create a jupyter-notebook in a kotlin-project which has access to the project classes (and its dependencies)? I know I could publish to maven-local but this always feels a bit clumsy for quick exploration/prototyping.
i
It's possible in Kotlin Notebook, it builds the project and uses it as a notebook dependency by default
a
Another way is to use build target via use/file. Kotlin Notebook configuration is still a bit clumsy in multi-module project.
h
Thanks @Ilya Muradyan nice pointer. They lack graphics support though. Thanks @altavir, what's a "build target via use/file." and how would I use it?
a
You can add a jar or a directory with class files via %use directive (I am not sure, but I think gradle-like API should support that as well). If you have jupyter plugin declaration inside your jar, then it will also include dependencies. So all you need is to point
use
to your
build/libs/<whatever>.jar
ouput.
You can even set up gradle for continous build. But I did not try that.
i
@holgerbrandl What do you mean by "graphics support"?
a
It has graphic support.
h
Sure I know and use the plugin. I'm just wondering about how to wire my current project into the dependencies of a notebook
a
It should automatically load the current classpath into the notebook. As I said it is a bit tricky to configure right now because the configuration panel is confusing. It requires both python runtime and it is not cleae, which module classpath does it use.
h
Interesting I will give it another try them
a
As I said earlier, I did not manage to make it work properly in MPP project.
But it works as stand alone notebook from Idea well enough.
h
Amazing, this works indeed. It's a wonderful feature, but also too hidden IMHO and more importantly following an unclear model (from a user perspective), as normally all dependencies in a jupyter notebook need to be declared with
use
or
DependsOn
. Here some, hidden dependency seems to be injected, which is nice but also comes as an unexpected surprise. Having a more declarative way of binding the current project into the notebook (e.g.
%use module("foo")
) would imho be easier to follow I think. FYI @Ilya Muradyan
i
@altavir btw, it shouldn't require python runtime anymore. Jupyter server functionality is now implemented in Java inside IDE process. But it still requires Python intellij plugin
@holgerbrandl thank you for your feedback! Depending on particular modules is indeed doable, but what UX should we provide for setting these dependencies up is unclear
a
@Ilya Muradyan It does not work without Python interpreter right now. There is a Kotlin notebook tab in the settings, but when I try to select JVM in it, it hangs indedefinitely.
r
@altavir Are you on the latest nightly?
a
No, I use the default plugin version. I mostly use DataLore for notebooks, so I check IDE support only occasionally.
h
@Ilya Muradyan Regarding
%use module("foo")
is there a youtrack ticket to watch?
@altavir Regarding "it should load the current classpath": It seems to load only classes that are defined in the project (as sources), but it fails to load any classes from my grade dependencies. Is this a known issue?
i
h
With latest IDE and plugin it still seems to rely on the python plugin. And what's even more confusing from a user perspective is that it's not clear how to do so (second screenshot): clearly I can't change my module SDK (because it must be kotlin I think), so where should python be configured?
i
Do you create Kotlin Notebook?
a
I had the same behavior the last time I tried it.
h
Yes I had created a fresh project via the ide wizard Kotlin Gradle, and then added a single kotlin Jupiter notebook. In another project (same PC) kernel integration worked, but I could not spot any difference in project configurations.
r
@holgerbrandl it seems your screenshot doesn’t look like Kotlin Notebook, but a python one. In Kotlin there’s no debug button in the toolbar
h
Thanks @roman.belov. Indeed, my notebook was a python one. The kernel combobox was not shown on my too-narrow laptop screen. Conceptually, I find the distinction made by the IDE here a bit artificial: Jupyter notebooks, are in my understanding generic in nature, and just the selected kernel defines the language. So from a workflow perspective, I'd assume that I would always create a jupyter notebook first, and second select the kernel to be used (which then allowsthe IDE to configure language settings accordingly).
r
Kotlin notebooks in IDEA already work on their own server written completely in Kotlin (but with the same protocol). So technically it’s not a Jupyter notebook anymore ) We did it specifically for simplifying the set up process and start of notebooks, otherwise you still needed to specify Jupyter-server and python runtime, which is very inconvenient for most of the Kotlin developers in IDEA. In future, there will be no dependency on Python plugin and so no entry with Jupyter Notebook in the menu.
h
Interesting. Indeed, there's typically quite some friction with such polyglot tooling. With the python plugin being not part of the process anymore, do you consider making the kotlin notebook plugin part of Intellij CE?
r
Yes, we are considering it. But at the moment it is still unclear whether this is technically possible or not. But that’s definitely something we want
a
In any case, open source implementation for the stand-alone notebook server would be superb.
436 Views