org.jetbrains.kotlinx.jupyter.api.libraries.CodeExecution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-api Show documentation
Show all versions of kotlin-jupyter-api Show documentation
API for libraries supporting Kotlin Jupyter notebooks
package org.jetbrains.kotlinx.jupyter.api.libraries
import kotlinx.serialization.Serializable
import org.jetbrains.kotlinx.jupyter.api.Code
import org.jetbrains.kotlinx.jupyter.api.ExecutionCallback
import org.jetbrains.kotlinx.jupyter.util.CodeExecutionSerializer
import org.jetbrains.kotlinx.jupyter.util.replaceVariables
/**
* Code snippet ready to be evaluated with kernel REPL
*
* @property code Snippet text
* @constructor Create code execution with the given [code]
*/
@Serializable(with = CodeExecutionSerializer::class)
class CodeExecution(val code: Code) {
fun toExecutionCallback(mapping: Map = emptyMap()): ExecutionCallback {
return CodeExecutionCallback(replaceVariables(code, mapping))
}
}