Skip to content

Commit 2b2fefa

Browse files
committed
Revert MIN_KERNEL_VERSION to 0.11.0.198
Insted respond with different output for kernel version >= 0.11.0.311
1 parent 0371330 commit 2b2fefa

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import kotlin.reflect.KProperty
3535
import kotlin.reflect.full.isSubtypeOf
3636

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

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

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import org.jetbrains.kotlinx.dataframe.size
1010
import org.jetbrains.kotlinx.jupyter.api.*
1111
import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration
1212

13+
/** Starting from this version, dataframe integration will respond with additional data for rendering in Kotlin Notebooks plugin. */
14+
private const val MIN_KERNEL_VERSION_FOR_NEW_TABLES_UI = "0.11.0.311"
15+
1316
internal class JupyterHtmlRenderer(
1417
val display: DisplayConfiguration,
1518
val builder: JupyterIntegration.Builder,
@@ -32,14 +35,6 @@ internal inline fun <reified T : Any> JupyterHtmlRenderer.render(
3235
df.nrow
3336
}
3437

35-
val jsonEncodedDf = json {
36-
obj(
37-
"nrow" to df.size.nrow,
38-
"ncol" to df.size.ncol,
39-
"columns" to df.columnNames(),
40-
"kotlin_dataframe" to encodeFrame(df.rows().take(limit).toDataFrame())
41-
)
42-
}.toJsonString()
4338
val html = df.toHTML(
4439
reifiedDisplayConfiguration,
4540
extraHtml = initHtml(
@@ -50,7 +45,19 @@ internal inline fun <reified T : Any> JupyterHtmlRenderer.render(
5045
contextRenderer
5146
) { footer }
5247

53-
notebook.renderAsIFrameAsNeeded(html, jsonEncodedDf)
48+
if (notebook.kernelVersion >= KotlinKernelVersion.from(MIN_KERNEL_VERSION_FOR_NEW_TABLES_UI)!!) {
49+
val jsonEncodedDf = json {
50+
obj(
51+
"nrow" to df.size.nrow,
52+
"ncol" to df.size.ncol,
53+
"columns" to df.columnNames(),
54+
"kotlin_dataframe" to encodeFrame(df.rows().take(limit).toDataFrame())
55+
)
56+
}.toJsonString()
57+
notebook.renderAsIFrameAsNeeded(html, jsonEncodedDf)
58+
} else {
59+
notebook.renderHtmlAsIFrameIfNeeded(html)
60+
}
5461
}
5562

5663
internal fun Notebook.renderAsIFrameAsNeeded(data: HtmlData, jsonEncodedDf: String): MimeTypedResult {

0 commit comments

Comments
 (0)