Closed catacgc closed 1 year ago
Hi! If you want to share a notebook you definitely can't guarantee that dependencies from your project will be present in the place you run it. But you can do this in case your library is distributed via Maven. Condition might be more complicated i.e. include some environment variable detection
if (notebook.jupyterClientType != JupyterClientType.KOTLIN_NOTEBOOK) {
USE {
dependencies {
implementation("your:library:artifact")
}
}
}
Yes, that's exactly what I am looking for, I gave it a try and got half way in terms of usability:
%use dataframe, lets-plot, @file[.jupyter_kotlin/libraries/this-project-library.json]
where .jupyter_kotlin/libraries/this-project-library.json
is
{
"description": "Utility library for this project",
"properties": [
{ "name": "v", "value": "1.0.0" }
],
"init": [
"if (notebook.jupyterClientType != JupyterClientType.KOTLIN_NOTEBOOK) { USE { repositories {mavenLocal()}; dependencies { implementation(\"jupyter.notebook:library:1.0\") }}}"
],
"imports": [
"jupyter.notebook.HttpSyncClient",
"io.ktor.client.request.*",
"io.ktor.client.statement.*",
"io.ktor.http.*"
]
}
and a gradle publishing task
plugins {
id("maven-publish")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "jupyter.notebook"
artifactId = "library"
version = "1.0"
from(components["java"])
}
}
}
A few things stand out to me here:
the .jupyter_kotlin/libraries
convention stated here does not work. I cannot just %use this-project-library
the one-line init code is too convoluted, would be interesting to add a file-reference option. e.g. @init.kt
or something like that
I have a very simple project with a kotlin library and a notebook using files from that library.
When I ran within IDEA everything runs with no problem. When I ran from the command line a with a jupyer lab instance, my kotlin library dependency is not found, which would be expected.
Is there a convention to make it work in both scenarious?