All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.jupyter.api.libraries.CodeExecution.kt Maven / Gradle / Ivy

There is a newer version: 0.12.0-335
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy