Skip to content

Commit e0b27ba

Browse files
authored
Merge pull request #209 from Kotlin/minKernelVersion
Min kernel version fix
2 parents e83f8d2 + e06216b commit e0b27ba

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,24 @@ import kotlin.reflect.KClass
5555
import kotlin.reflect.KProperty
5656
import kotlin.reflect.full.isSubtypeOf
5757

58+
/** Users will get an error if their Kotlin Jupyter kernel is older than this version. */
59+
private const val MIN_KERNEL_VERSION = "0.11.0.198"
60+
5861
internal val newDataSchemas = mutableListOf<KClass<*>>()
5962

60-
internal class Integration(private val notebook: Notebook, private val options: MutableMap<String, String?>) :
61-
JupyterIntegration() {
63+
internal class Integration(
64+
private val notebook: Notebook,
65+
private val options: MutableMap<String, String?>,
66+
) : JupyterIntegration() {
6267

6368
override fun Builder.onLoaded() {
69+
try {
70+
setMinimalKernelVersion(MIN_KERNEL_VERSION)
71+
} catch (_: NoSuchMethodError) { // will be thrown on version < 0.11.0.198
72+
throw IllegalStateException(
73+
getKernelUpdateMessage(notebook.kernelVersion, MIN_KERNEL_VERSION, notebook.jupyterClientType)
74+
)
75+
}
6476
val codeGen = ReplCodeGenerator.create()
6577
val config = JupyterConfiguration()
6678

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.jetbrains.kotlinx.dataframe.jupyter
2+
3+
import org.jetbrains.kotlinx.jupyter.api.JupyterClientType
4+
import org.jetbrains.kotlinx.jupyter.api.JupyterClientType.DATALORE
5+
import org.jetbrains.kotlinx.jupyter.api.JupyterClientType.KOTLIN_NOTEBOOK
6+
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion
7+
8+
private const val UPDATING_DATALORE_URL = "https://github.com/Kotlin/kotlin-jupyter/tree/master#datalore"
9+
private const val UPDATING_KOTLIN_NOTEBOOK_URL = "https://github.com/Kotlin/kotlin-jupyter#kotlin-notebook"
10+
private const val UPDATING = "https://github.com/Kotlin/kotlin-jupyter/tree/master#updating"
11+
12+
internal fun getKernelUpdateMessage(
13+
kernelVersion: KotlinKernelVersion,
14+
minKernelVersion: String,
15+
clientType: JupyterClientType,
16+
): String = buildString {
17+
append("Your Kotlin Jupyter kernel version appears to be out of date (version $kernelVersion). ")
18+
appendLine("Please update it to version $minKernelVersion or newer to be able to use DataFrame.")
19+
append("Follow the instructions at: ")
20+
21+
when (clientType) {
22+
DATALORE -> appendLine(UPDATING_DATALORE_URL)
23+
KOTLIN_NOTEBOOK -> appendLine(UPDATING_KOTLIN_NOTEBOOK_URL)
24+
else -> appendLine(UPDATING)
25+
}
26+
}

gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[versions]
2-
ksp = "1.7.20-1.0.8"
3-
kotlinJupyter = "0.11.0-187"
2+
ksp = "1.8.0-RC-1.0.8"
3+
kotlinJupyter = "0.11.0-198"
44
ktlint = "3.4.5"
5-
kotlin = "1.7.20"
6-
dokka = "1.6.20"
5+
kotlin = "1.8.0-RC"
6+
dokka = "1.7.20"
77
libsPublisher = "0.0.60-dev-30"
88
# "Bootstrap" version of the dataframe, used in the build itself to generate @DataSchema APIs,
99
# dogfood Gradle / KSP plugins in tests and idea-examples modules

plugins/dataframe-gradle-plugin/src/integrationTest/kotlin/org/jetbrains/dataframe/gradle/SchemaGeneratorPluginIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class SchemaGeneratorPluginIntegrationTest : AbstractDataFramePluginIntegrationT
436436
437437
kotlin {
438438
sourceSets {
439-
js {
439+
js(IR) {
440440
browser()
441441
}
442442
}

0 commit comments

Comments
 (0)