https://kotlinlang.org logo
#datascience
Title
# datascience
i

Ilya Muradyan

08/24/2022, 7:59 PM
Hey, Kotlin-for-data-science users! We'd like to add a small API for Kotlin notebooks which allows to add dependencies without annotations (
@file:DependsOn
and
@file:Repository
). We'd like to make it similar to Gradle dependencies declaration, now it looks like this:
Copy code
USE {
	gradle {
		repositories {
			mavenCentral()
		}
		dependencies {
			implementation("io.github.config4k:config4k:0.4.2")
		}
	}
}
I'd like to ask, what do you think of API entry point name? Now it's
gradle
. There are other options mentioned here: https://github.com/Kotlin/kotlin-jupyter/pull/382#issuecomment-1220831897 Also,
dependsOn
is suggested by @altavir, and I really like it. Your suggestions are welcome!
k

kenkyee

08/24/2022, 8:04 PM
why not just :
Copy code
USE {
		dependencies {		"io.github.config4k:config4k:0.4.2"
		}
}
default to including mavenCentral() and mavenLocal() and only require the repositories if needed…add any others that are common. You’ll always use implementation dependencies in Jupyter notebooks AFAIK. Also, why do you need USE{} ?
i

Ilya Muradyan

08/24/2022, 9:03 PM
Yes
Yes, it's also possible, good idea!
USE
is needed inside a notebook to add a library - I want this API be available both in notebook and integrations, and USE is used to enter library API
There are
repositories
and
dependencies
in the same scope, but they have vararg string arguments, so signatures do not intersect
a

altavir

08/25/2022, 5:42 AM
My idea is to slowly propagate the ideas from notebook to the general scripting. So I am trying to thing of more universal solution.
if USE is requireed, then the inner block is not needed.
c

Carter

09/05/2022, 11:45 AM
Is the intention to make the syntax similar to how we configure standard Gradle projects with kts? Under this proposal, will the repositories declaration support authentication? This was a blocker for me previously trying to consume our own private artifacts in Datalore. The hope was to publish them to GitHub package registry privately with username/password (token) authentication. That way we don’t have to keep manually uploading JARs to Datalore.
i

Ilya Muradyan

09/05/2022, 12:00 PM
You can use authorization now, if it's simple username/password pair
Copy code
@file:Repository("<URL>", "<username>", "<password>")
@file:DependsOn("group:artifact:version")
We can add it to the new API either
c

Carter

09/05/2022, 12:00 PM
Oh nice! Last time I checked on this, it wasn’t available yet. I’ll give it a try. Excited for this to work!
@Ilya Muradyan I had to do some work to get the publishing working. Now that I’ve done that, I seem to have some trouble with consuming it in either a local notebook or on datalore. All I did was add two cells and tried running just those.
Copy code
@file:Repository("<https://maven.pkg.github.com/my-org/my-repo>", "my-username", "my-token")
@file:DependsOn("my-package:my-artifact:0.0.1-SNAPSHOT")
When I run it the error that comes back is:
Copy code
Failed to resolve my-package:my-artifact:0.0.1-SNAPSHOT:
File 'my-package:my-artifact:0.0.1-SNAPSHOT' not found
ArtifactResolutionException: Could not find artifact my-package:my-artifact:jar:0.0.1-SNAPSHOT in https___repo.maven.apache.org_maven2_ (<https://repo.maven.apache.org/maven2/>)
I notice the error doesn’t indicate it is searching my newly declared repository. Am I missing something?
i

Ilya Muradyan

10/04/2022, 12:25 PM
Copy code
my-package:my-artifact:sdk:jar:0.0.1-SNAPSHOT
What is
sdk
here? Have you specified some additional classifier for your dependency? Problem could be caused by wrong artifact coordinates, but I can't check
c

Carter

10/04/2022, 12:36 PM
Sorry,
sdk
was a typo in my example. It isn’t an additional classifier.
The only thing that might make my usage slightly different is that my-artifact is published as Kotlin Multiplatform with a JVM target. So I also did try a -jvm suffix but saw similar results. Why does the log only say that it searched maven central?
Ok, let me check. I thought I had updated it yesterday with the stable version 🤔 . Are you testing stable or dev?
i

Ilya Muradyan

10/04/2022, 12:50 PM
Copy code
pip install -i <https://test.pypi.org/simple/> kotlin-jupyter-kernel==0.11.0.168
Dev
c

Carter

10/04/2022, 12:51 PM
OK, updating to the dev version:
Copy code
kotlin-jupyter-ke~ jetbrains::kotlin-jupyter-kernel-0.11~ --> jetbrains-dev::kotlin-jupyter-kernel-0.11.0.168-py_0
So the error message in the notebook is still incorrect. But I can see it hitting GitHub in the terminal console and Little Snitch is showing that connection to GitHub too. Let me check github package registry next—this is the first time I’m publishing the packages for this project so something could have gone wrong there too on the publish side.
43 Views