Moved TaskBuilder to common.
This commit is contained in:
parent
61c2530c91
commit
530b1c1b76
@ -39,7 +39,7 @@ class AllDataDependency(val placement: Name = EmptyName) : Dependency() {
|
||||
}
|
||||
|
||||
override fun toMeta() = buildMeta {
|
||||
"data" to "*"
|
||||
"data" to "@all"
|
||||
"to" to placement
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import kotlin.reflect.KClass
|
||||
|
||||
@TaskBuildScope
|
||||
class TaskBuilder(val name: String) {
|
||||
private var modelTransform: TaskModelBuilder.(Meta) -> Unit = { data("*") }
|
||||
private var modelTransform: TaskModelBuilder.(Meta) -> Unit = { allData() }
|
||||
var descriptor: NodeDescriptor? = null
|
||||
private val dataTransforms: MutableList<DataTransformation> = ArrayList()
|
||||
|
||||
@ -40,6 +40,20 @@ class TaskBuilder(val name: String) {
|
||||
this.modelTransform = modelTransform
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a transformation on untyped data
|
||||
*/
|
||||
fun rawTransform(
|
||||
from: String = "",
|
||||
to: String = "",
|
||||
block: TaskEnv.(DataNode<*>) -> DataNode<*>
|
||||
) {
|
||||
dataTransforms += DataTransformation(from, to){context, model, data->
|
||||
val env = TaskEnv(EmptyName, model.meta, context)
|
||||
env.block(data)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Any> transform(
|
||||
inputType: KClass<out T>,
|
||||
from: String = "",
|
||||
|
@ -0,0 +1,5 @@
|
||||
package hep.dataforge.workspace
|
||||
|
||||
//fun <T1: Any, T2: Any, R: Any> TaskBuilder.zip(
|
||||
// val firstNo
|
||||
//) = rawTransform { }
|
Loading…
Reference in New Issue
Block a user