
org.jetbrains.kotlinx.jupyter.api.libraries.CodeExecution.kt Maven / Gradle / Ivy
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))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy