Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Min kernel version fix #209

Merged
merged 7 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,24 @@ import kotlin.reflect.KClass
import kotlin.reflect.KProperty
import kotlin.reflect.full.isSubtypeOf

/** Users will get an error if their Kotlin Jupyter kernel is older than this version. */
private const val MIN_KERNEL_VERSION = "0.11.0.198"

internal val newDataSchemas = mutableListOf<KClass<*>>()

internal class Integration(private val notebook: Notebook, private val options: MutableMap<String, String?>) :
JupyterIntegration() {
internal class Integration(
private val notebook: Notebook,
private val options: MutableMap<String, String?>,
) : JupyterIntegration() {

override fun Builder.onLoaded() {
try {
setMinimalKernelVersion(MIN_KERNEL_VERSION)
} catch (_: NoSuchMethodError) { // will be thrown on version < 0.11.0.198
throw IllegalStateException(
getKernelUpdateMessage(notebook.kernelVersion, MIN_KERNEL_VERSION, notebook.jupyterClientType)
)
}
val codeGen = ReplCodeGenerator.create()
val config = JupyterConfiguration()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.jetbrains.kotlinx.dataframe.jupyter

import org.jetbrains.kotlinx.jupyter.api.JupyterClientType
import org.jetbrains.kotlinx.jupyter.api.JupyterClientType.DATALORE
import org.jetbrains.kotlinx.jupyter.api.JupyterClientType.KOTLIN_NOTEBOOK
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion

private const val UPDATING_DATALORE_URL = "https://github.com/Kotlin/kotlin-jupyter/tree/master#datalore"
private const val UPDATING_KOTLIN_NOTEBOOK_URL = "https://github.com/Kotlin/kotlin-jupyter#kotlin-notebook"
private const val UPDATING = "https://github.com/Kotlin/kotlin-jupyter/tree/master#updating"

internal fun getKernelUpdateMessage(
kernelVersion: KotlinKernelVersion,
minKernelVersion: String,
clientType: JupyterClientType,
): String = buildString {
append("Your Kotlin Jupyter kernel version appears to be out of date (version $kernelVersion). ")
appendLine("Please update it to version $minKernelVersion or newer to be able to use DataFrame.")
append("Follow the instructions at: ")

when (clientType) {
DATALORE -> appendLine(UPDATING_DATALORE_URL)
KOTLIN_NOTEBOOK -> appendLine(UPDATING_KOTLIN_NOTEBOOK_URL)
else -> appendLine(UPDATING)
}
}
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
ksp = "1.7.20-1.0.8"
kotlinJupyter = "0.11.0-187"
ksp = "1.8.0-RC-1.0.8"
kotlinJupyter = "0.11.0-198"
ktlint = "3.4.5"
kotlin = "1.7.20"
dokka = "1.6.20"
kotlin = "1.8.0-RC"
dokka = "1.7.20"
libsPublisher = "0.0.60-dev-30"
# "Bootstrap" version of the dataframe, used in the build itself to generate @DataSchema APIs,
# dogfood Gradle / KSP plugins in tests and idea-examples modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class SchemaGeneratorPluginIntegrationTest : AbstractDataFramePluginIntegrationT

kotlin {
sourceSets {
js {
js(IR) {
browser()
}
}
Expand Down