This commit is contained in:
Alexander Nozik 2019-10-29 21:20:14 +03:00
parent dce9199b78
commit 245b5ebc52
31 changed files with 204 additions and 135 deletions

View File

@ -105,8 +105,8 @@ open class Context(
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"parent" to parent?.name "parent" to parent?.name
"properties" to properties.seal() "properties" put properties.seal()
"plugins" to plugins.map { it.toMeta() } "plugins" put plugins.map { it.toMeta() }
} }
} }

View File

@ -66,10 +66,10 @@ interface Plugin : Named, ContextAware, Provider, MetaRepr {
fun detach() fun detach()
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"context" to context.name "context" put context.name.toString()
"type" to this::class.simpleName "type" to this::class.simpleName
"tag" to tag "tag" put tag
"meta" to meta "meta" put meta
} }
companion object { companion object {

View File

@ -37,9 +37,9 @@ data class PluginTag(
override fun toString(): String = listOf(group, name, version).joinToString(separator = ":") override fun toString(): String = listOf(group, name, version).joinToString(separator = ":")
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"name" to name "name" put name
"group" to group "group" put group
"version" to version "version" put version
} }
companion object { companion object {

View File

@ -20,9 +20,9 @@ interface Data<out T : Any> : Goal<T>, MetaRepr{
val meta: Meta val meta: Meta
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"type" to (type.simpleName?:"undefined") "type" put (type.simpleName?:"undefined")
if(!meta.isEmpty()) { if(!meta.isEmpty()) {
"meta" to meta "meta" put meta
} }
} }

View File

@ -39,10 +39,10 @@ interface DataNode<out T : Any> : MetaRepr {
val items: Map<NameToken, DataItem<T>> val items: Map<NameToken, DataItem<T>>
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"type" to (type.simpleName ?: "undefined") "type" put (type.simpleName ?: "undefined")
"items" to { "items" put {
this@DataNode.items.forEach { this@DataNode.items.forEach {
it.key.toString() to it.value.toMeta() it.key.toString() put it.value.toMeta()
} }
} }
} }
@ -196,19 +196,19 @@ class DataTreeBuilder<T : Any>(val type: KClass<out T>) {
/** /**
* Append data to node * Append data to node
*/ */
infix fun String.to(data: Data<T>) = set(toName(), data) infix fun String.put(data: Data<T>) = set(toName(), data)
/** /**
* Append node * Append node
*/ */
infix fun String.to(node: DataNode<T>) = set(toName(), node) infix fun String.put(node: DataNode<T>) = set(toName(), node)
infix fun String.to(item: DataItem<T>) = set(toName(), item) infix fun String.put(item: DataItem<T>) = set(toName(), item)
/** /**
* Build and append node * Build and append node
*/ */
infix fun String.to(block: DataTreeBuilder<T>.() -> Unit) = set(toName(), DataTreeBuilder(type).apply(block)) infix fun String.put(block: DataTreeBuilder<T>.() -> Unit) = set(toName(), DataTreeBuilder(type).apply(block))
fun update(node: DataNode<T>) { fun update(node: DataNode<T>) {

View File

@ -8,9 +8,9 @@ internal class DataTreeBuilderTest{
@Test @Test
fun testDataUpdate(){ fun testDataUpdate(){
val updateData = DataNode<Any>{ val updateData = DataNode<Any>{
"update" to { "update" put {
"a" to Data.static("a") "a" put Data.static("a")
"b" to Data.static("b") "b" put Data.static("b")
} }
} }

View File

@ -14,18 +14,18 @@ class YamlMetaFormatTest{
@Test @Test
fun testYamlMetaFormat(){ fun testYamlMetaFormat(){
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"node" to { "node" put {
"b" to "DDD" "b" put "DDD"
"c" to 11.1 "c" put 11.1
"d" to { "d" put {
"d1" to { "d1" put {
"d11" to "aaa" "d11" put "aaa"
"d12" to "bbb" "d12" put "bbb"
} }
"d2" to 2 "d2" put 2
} }
"array" to doubleArrayOf(1.0, 2.0, 3.0) "array" put doubleArrayOf(1.0, 2.0, 3.0)
} }
} }
val string = meta.toString(YamlMetaFormat) val string = meta.toString(YamlMetaFormat)

View File

@ -33,7 +33,7 @@ class RemoteFunctionClient(override val context: Context, val responder: Respond
meta(meta) meta(meta)
type = REQUEST_TYPE type = REQUEST_TYPE
meta { meta {
SIZE_KEY to values.size SIZE_KEY put values.size
} }
data { data {
val inputFormat: IOFormat<T> = getInputFormat(meta, valueType) val inputFormat: IOFormat<T> = getInputFormat(meta, valueType)

View File

@ -8,7 +8,7 @@ class EnvelopeFormatTest {
val envelope = Envelope.invoke { val envelope = Envelope.invoke {
type = "test.format" type = "test.format"
meta{ meta{
"d" to 22.2 "d" put 22.2
} }
data{ data{
writeDouble(22.2) writeDouble(22.2)

View File

@ -11,11 +11,11 @@ class MetaFormatTest {
@Test @Test
fun testBinaryMetaFormat() { fun testBinaryMetaFormat() {
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"node" to { "node" put {
"b" to "DDD" "b" put "DDD"
"c" to 11.1 "c" put 11.1
"array" to doubleArrayOf(1.0, 2.0, 3.0) "array" put doubleArrayOf(1.0, 2.0, 3.0)
} }
} }
val bytes = meta.toBytes(BinaryMetaFormat) val bytes = meta.toBytes(BinaryMetaFormat)
@ -26,11 +26,11 @@ class MetaFormatTest {
@Test @Test
fun testJsonMetaFormat() { fun testJsonMetaFormat() {
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"node" to { "node" put {
"b" to "DDD" "b" put "DDD"
"c" to 11.1 "c" put 11.1
"array" to doubleArrayOf(1.0, 2.0, 3.0) "array" put doubleArrayOf(1.0, 2.0, 3.0)
} }
} }
val string = meta.toString(JsonMetaFormat) val string = meta.toString(JsonMetaFormat)

View File

@ -14,11 +14,11 @@ class MetaSerializerTest {
@Test @Test
fun testMetaSerialization() { fun testMetaSerialization() {
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"node" to { "node" put {
"b" to "DDD" "b" put "DDD"
"c" to 11.1 "c" put 11.1
"array" to doubleArrayOf(1.0, 2.0, 3.0) "array" put doubleArrayOf(1.0, 2.0, 3.0)
} }
} }
@ -30,11 +30,11 @@ class MetaSerializerTest {
@Test @Test
fun testCborSerialization() { fun testCborSerialization() {
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"node" to { "node" put {
"b" to "DDD" "b" put "DDD"
"c" to 11.1 "c" put 11.1
"array" to doubleArrayOf(1.0, 2.0, 3.0) "array" put doubleArrayOf(1.0, 2.0, 3.0)
} }
} }

View File

@ -26,9 +26,9 @@ fun IOPlugin.resolveIOFormatName(type: KClass<*>): Name {
} }
inline fun <reified T : Any, reified R : Any> IOPlugin.generateFunctionMeta(functionName: String): Meta = buildMeta { inline fun <reified T : Any, reified R : Any> IOPlugin.generateFunctionMeta(functionName: String): Meta = buildMeta {
FUNCTION_NAME_KEY to functionName FUNCTION_NAME_KEY put functionName
INPUT_FORMAT_KEY to resolveIOFormatName(T::class) INPUT_FORMAT_KEY put resolveIOFormatName(T::class).toString()
OUTPUT_FORMAT_KEY to resolveIOFormatName(R::class) OUTPUT_FORMAT_KEY put resolveIOFormatName(R::class).toString()
} }
inline fun <reified T : Any, reified R : Any> FunctionServer.function( inline fun <reified T : Any, reified R : Any> FunctionServer.function(

View File

@ -9,8 +9,8 @@ import kotlin.test.assertTrue
class FileEnvelopeTest { class FileEnvelopeTest {
val envelope = Envelope { val envelope = Envelope {
meta { meta {
"a" to "AAA" "a" put "AAA"
"b" to 22.2 "b" put 22.2
} }
dataType = "hep.dataforge.test" dataType = "hep.dataforge.test"
dataID = "myData" // добавил только что dataID = "myData" // добавил только что

View File

@ -48,7 +48,7 @@ class EnvelopeServerTest {
val request = Envelope.invoke { val request = Envelope.invoke {
type = "test.echo" type = "test.echo"
meta { meta {
"test.value" to 22 "test.value" put 22
} }
data { data {
writeDouble(22.7) writeDouble(22.7)

View File

@ -72,7 +72,7 @@ class NodeDescriptor(config: Config) : ItemDescriptor(config) {
* The list of value descriptors * The list of value descriptors
*/ */
val values: Map<String, ValueDescriptor> val values: Map<String, ValueDescriptor>
get() = config.getAll(VALUE_KEY.toName()).entries.associate { (name, node) -> get() = config.getIndexed(VALUE_KEY.toName()).entries.associate { (name, node) ->
name to ValueDescriptor.wrap(node.node ?: error("Value descriptor must be a node")) name to ValueDescriptor.wrap(node.node ?: error("Value descriptor must be a node"))
} }
@ -93,7 +93,7 @@ class NodeDescriptor(config: Config) : ItemDescriptor(config) {
* The map of children node descriptors * The map of children node descriptors
*/ */
val nodes: Map<String, NodeDescriptor> val nodes: Map<String, NodeDescriptor>
get() = config.getAll(NODE_KEY.toName()).entries.associate { (name, node) -> get() = config.getIndexed(NODE_KEY.toName()).entries.associate { (name, node) ->
name to wrap(node.node ?: error("Node descriptor must be a node")) name to wrap(node.node ?: error("Node descriptor must be a node"))
} }

View File

@ -61,7 +61,7 @@ class Laminate(layers: List<Meta>) : MetaBase() {
} }
else -> map { else -> map {
when (it) { when (it) {
is MetaItem.ValueItem -> MetaItem.NodeItem(buildMeta { Meta.VALUE_KEY to it.value }) is MetaItem.ValueItem -> MetaItem.NodeItem(buildMeta { Meta.VALUE_KEY put it.value })
is MetaItem.NodeItem -> it is MetaItem.NodeItem -> it
} }
}.merge() }.merge()

View File

@ -2,7 +2,10 @@ package hep.dataforge.meta
import hep.dataforge.names.Name import hep.dataforge.names.Name
import hep.dataforge.names.asName import hep.dataforge.names.asName
import hep.dataforge.values.EnumValue
import hep.dataforge.values.Value import hep.dataforge.values.Value
import hep.dataforge.values.asValue
import kotlin.jvm.JvmName
/** /**
* DSL builder for meta. Is not intended to store mutable state * DSL builder for meta. Is not intended to store mutable state
@ -12,41 +15,105 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
override fun wrapNode(meta: Meta): MetaBuilder = if (meta is MetaBuilder) meta else meta.builder() override fun wrapNode(meta: Meta): MetaBuilder = if (meta is MetaBuilder) meta else meta.builder()
override fun empty(): MetaBuilder = MetaBuilder() override fun empty(): MetaBuilder = MetaBuilder()
infix fun String.to(value: Any) { infix fun String.put(value: Value){
if (value is Meta) { set(this,value)
this@MetaBuilder[this] = value
}
this@MetaBuilder[this] = Value.of(value)
} }
infix fun String.to(meta: Meta) { infix fun String.put(string: String){
set(this,string.asValue())
}
infix fun String.put(number: Number){
set(this,number.asValue())
}
infix fun String.put(boolean: Boolean){
set(this, boolean.asValue())
}
infix fun String.put(enum: Enum<*>){
set(this, EnumValue(enum))
}
@JvmName("putValues")
infix fun String.put(iterable: Iterable<Value>){
set(this, iterable.asValue())
}
@JvmName("putNumbers")
infix fun String.put(iterable: Iterable<Number>){
set(this, iterable.map { it.asValue() }.asValue())
}
@JvmName("putStrings")
infix fun String.put(iterable: Iterable<String>){
set(this, iterable.map { it.asValue() }.asValue())
}
infix fun String.put(array: DoubleArray){
set(this, array.asValue())
}
infix fun String.putValue(any: Any?){
set(this, Value.of(any))
}
infix fun String.put(meta: Meta) {
this@MetaBuilder[this] = meta this@MetaBuilder[this] = meta
} }
infix fun String.to(value: Iterable<Meta>) { infix fun String.put(repr: MetaRepr){
set(this,repr.toMeta())
}
@JvmName("putMetas")
infix fun String.put(value: Iterable<Meta>) {
this@MetaBuilder[this] = value.toList() this@MetaBuilder[this] = value.toList()
} }
infix fun String.to(metaBuilder: MetaBuilder.() -> Unit) { infix fun String.put(metaBuilder: MetaBuilder.() -> Unit) {
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder) this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
} }
infix fun Name.to(value: Any) { infix fun Name.put(value: Value){
if (value is Meta) { set(this,value)
this@MetaBuilder[this] = value
}
this@MetaBuilder[this] = Value.of(value)
} }
infix fun Name.to(meta: Meta) { infix fun Name.put(string: String){
set(this,string.asValue())
}
infix fun Name.put(number: Number){
set(this,number.asValue())
}
infix fun Name.put(boolean: Boolean){
set(this, boolean.asValue())
}
infix fun Name.put(enum: Enum<*>){
set(this, EnumValue(enum))
}
@JvmName("putValues")
infix fun Name.put(iterable: Iterable<Value>){
set(this, iterable.asValue())
}
infix fun Name.put(meta: Meta) {
this@MetaBuilder[this] = meta this@MetaBuilder[this] = meta
} }
infix fun Name.to(value: Iterable<Meta>) { infix fun Name.put(repr: MetaRepr){
set(this,repr.toMeta())
}
@JvmName("putMetas")
infix fun Name.put(value: Iterable<Meta>) {
this@MetaBuilder[this] = value.toList() this@MetaBuilder[this] = value.toList()
} }
infix fun Name.to(metaBuilder: MetaBuilder.() -> Unit) { infix fun Name.put(metaBuilder: MetaBuilder.() -> Unit) {
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder) this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
} }
} }

View File

@ -164,7 +164,7 @@ fun MutableMeta<*>.append(name: Name, value: Any?) {
if (newIndex.isNotEmpty()) { if (newIndex.isNotEmpty()) {
set(name, value) set(name, value)
} else { } else {
val index = (getAll(name).keys.mapNotNull { it.toIntOrNull() }.max() ?: -1) + 1 val index = (getIndexed(name).keys.mapNotNull { it.toIntOrNull() }.max() ?: -1) + 1
set(name.withIndex(index.toString()), value) set(name.withIndex(index.toString()), value)
} }
} }

View File

@ -7,7 +7,7 @@ import hep.dataforge.names.toName
* Get all items matching given name. * Get all items matching given name.
*/ */
@DFExperimental @DFExperimental
fun Meta.getAll(name: Name): Map<String, MetaItem<*>> { fun Meta.getIndexed(name: Name): Map<String, MetaItem<*>> {
val root = when (name.length) { val root = when (name.length) {
0 -> error("Can't use empty name for that") 0 -> error("Can't use empty name for that")
1 -> this 1 -> this
@ -24,14 +24,14 @@ fun Meta.getAll(name: Name): Map<String, MetaItem<*>> {
} }
@DFExperimental @DFExperimental
fun Meta.getAll(name: String): Map<String, MetaItem<*>> = getAll(name.toName()) fun Meta.getIndexed(name: String): Map<String, MetaItem<*>> = this@getIndexed.getIndexed(name.toName())
/** /**
* Get all items matching given name. * Get all items matching given name.
*/ */
@DFExperimental @DFExperimental
fun <M : MetaNode<M>> M.getAll(name: Name): Map<String, MetaItem<M>> { fun <M : MetaNode<M>> M.getIndexed(name: Name): Map<String, MetaItem<M>> {
val root: MetaNode<M>? = when (name.length) { val root: MetaNode<M>? = when (name.length) {
0 -> error("Can't use empty name for that") 0 -> error("Can't use empty name for that")
1 -> this 1 -> this
@ -48,4 +48,4 @@ fun <M : MetaNode<M>> M.getAll(name: Name): Map<String, MetaItem<M>> {
} }
@DFExperimental @DFExperimental
fun <M : MetaNode<M>> M.getAll(name: String): Map<String, MetaItem<M>> = getAll(name.toName()) fun <M : MetaNode<M>> M.getIndexed(name: String): Map<String, MetaItem<M>> = getIndexed(name.toName())

View File

@ -34,4 +34,4 @@ val Value.doubleArray: DoubleArray
} }
fun Value.toMeta() = buildMeta { Meta.VALUE_KEY to this } fun Value.toMeta() = buildMeta { Meta.VALUE_KEY put this }

View File

@ -9,13 +9,13 @@ class MetaBuilderTest {
@Test @Test
fun testBuilder() { fun testBuilder() {
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"b" to listOf(1, 2, 3) "b" put listOf(1, 2, 3)
this["c"] = "myValue".asValue() this["c"] = "myValue".asValue()
"node" to { "node" put {
"e" to 12.2 "e" put 12.2
"childNode" to { "childNode" put {
"f" to true "f" put true
} }
} }
} }
@ -27,12 +27,12 @@ class MetaBuilderTest {
fun testSNS(){ fun testSNS(){
val meta = buildMeta { val meta = buildMeta {
repeat(10){ repeat(10){
"b.a[$it]" to it "b.a[$it]" put it
} }
}.seal() }.seal()
assertEquals(10, meta.values().count()) assertEquals(10, meta.values().count())
val nodes = meta.getAll("b.a") val nodes = meta.getIndexed("b.a")
assertEquals(3, nodes["3"]?.int) assertEquals(3, nodes["3"]?.int)
} }

View File

@ -11,12 +11,12 @@ class MetaExtensionTest {
@Test @Test
fun testEnum(){ fun testEnum(){
val meta = buildMeta{"enum" to TestEnum.test} val meta = buildMeta{"enum" put TestEnum.test}
meta["enum"].enum<TestEnum>() meta["enum"].enum<TestEnum>()
} }
@Test @Test
fun testEnumByString(){ fun testEnumByString(){
val meta = buildMeta{"enum" to TestEnum.test.name} val meta = buildMeta{"enum" put TestEnum.test.name}
println(meta["enum"].enum<TestEnum>()) println(meta["enum"].enum<TestEnum>())
} }

View File

@ -17,16 +17,16 @@ class MetaTest {
@Test @Test
fun metaEqualityTest() { fun metaEqualityTest() {
val meta1 = buildMeta { val meta1 = buildMeta {
"a" to 22 "a" put 22
"b" to { "b" put {
"c" to "ddd" "c" put "ddd"
} }
} }
val meta2 = buildMeta { val meta2 = buildMeta {
"b" to { "b" put {
"c" to "ddd" "c" put "ddd"
} }
"a" to 22 "a" put 22
}.seal() }.seal()
assertEquals<Meta>(meta1, meta2) assertEquals<Meta>(meta1, meta2)
} }
@ -34,13 +34,13 @@ class MetaTest {
@Test @Test
fun metaToMap(){ fun metaToMap(){
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"b" to { "b" put {
"c" to "ddd" "c" put "ddd"
} }
"list" to (0..4).map { "list" put (0..4).map {
buildMeta { buildMeta {
"value" to it "value" put it
} }
} }
} }

View File

@ -7,12 +7,12 @@ class MutableMetaTest{
@Test @Test
fun testRemove(){ fun testRemove(){
val meta = buildMeta { val meta = buildMeta {
"aNode" to { "aNode" put {
"innerNode" to { "innerNode" put {
"innerValue" to true "innerValue" put true
} }
"b" to 22 "b" put 22
"c" to "StringValue" "c" put "StringValue"
} }
}.toConfig() }.toConfig()

View File

@ -9,8 +9,8 @@ class StyledTest{
fun testSNS(){ fun testSNS(){
val meta = buildMeta { val meta = buildMeta {
repeat(10){ repeat(10){
"b.a[$it]" to { "b.a[$it]" put {
"d" to it "d" put it
} }
} }
}.seal().withStyle() }.seal().withStyle()
@ -18,9 +18,9 @@ class StyledTest{
val bNode = meta["b"].node val bNode = meta["b"].node
val aNodes = bNode?.getAll("a") val aNodes = bNode?.getIndexed("a")
val allNodes = meta.getAll("b.a") val allNodes = meta.getIndexed("b.a")
assertEquals(3, aNodes?.get("3").node["d"].int) assertEquals(3, aNodes?.get("3").node["d"].int)
assertEquals(3, allNodes["3"].node["d"].int) assertEquals(3, allNodes["3"].node["d"].int)

View File

@ -27,12 +27,12 @@ class DynamicMetaTest {
@Test @Test
fun testMetaToDynamic(){ fun testMetaToDynamic(){
val meta = buildMeta { val meta = buildMeta {
"a" to 22 "a" put 22
"array" to arrayOf(1, 2, 3) "array" put listOf(1, 2, 3)
"b" to "myString" "b" put "myString"
"ob" to { "ob" put {
"childNode" to 18 "childNode" put 18
"booleanNode" to true "booleanNode" put true
} }
} }

View File

@ -3,7 +3,9 @@ package hep.dataforge.scripting
import hep.dataforge.context.Global import hep.dataforge.context.Global
import hep.dataforge.meta.get import hep.dataforge.meta.get
import hep.dataforge.meta.int import hep.dataforge.meta.int
import hep.dataforge.workspace.* import hep.dataforge.workspace.SimpleWorkspaceBuilder
import hep.dataforge.workspace.context
import hep.dataforge.workspace.target
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
@ -17,7 +19,7 @@ class BuildersKtTest {
context("test") context("test")
target("testTarget"){ target("testTarget"){
"a" to 12 "a" put 12
} }
} }
} }
@ -30,7 +32,7 @@ class BuildersKtTest {
context("test") context("test")
target("testTarget"){ target("testTarget"){
"a" to 12 "a" put 12
} }
""".trimIndent() """.trimIndent()
val workspace = Builders.buildWorkspace(script) val workspace = Builders.buildWorkspace(script)

View File

@ -26,8 +26,8 @@ class DataDependency(val filter: DataFilter, val placement: Name = EmptyName) :
} }
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"data" to filter.config "data" put filter.config
"to" to placement "to" put placement.toString()
} }
} }
@ -39,8 +39,8 @@ class AllDataDependency(val placement: Name = EmptyName) : Dependency() {
} }
override fun toMeta() = buildMeta { override fun toMeta() = buildMeta {
"data" to "@all" "data" put "@all"
"to" to placement "to" put placement.toString()
} }
} }
@ -67,9 +67,9 @@ abstract class TaskDependency<out T : Any>(
} }
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"task" to name "task" put name.toString()
"meta" to meta "meta" put meta
"to" to placement "to" put placement.toString()
} }
} }

View File

@ -31,9 +31,9 @@ data class TaskModel(
//TODO add pre-run check of task result type? //TODO add pre-run check of task result type?
override fun toMeta(): Meta = buildMeta { override fun toMeta(): Meta = buildMeta {
"name" to name "name" put name.toString()
"meta" to meta "meta" put meta
"dependsOn" to { "dependsOn" put {
val dataDependencies = dependencies.filterIsInstance<DataDependency>() val dataDependencies = dependencies.filterIsInstance<DataDependency>()
val taskDependencies = dependencies.filterIsInstance<TaskDependency<*>>() val taskDependencies = dependencies.filterIsInstance<TaskDependency<*>>()
setIndexed("data".toName(), dataDependencies.map { it.toMeta() }) setIndexed("data".toName(), dataDependencies.map { it.toMeta() })

View File

@ -62,7 +62,7 @@ fun WorkspaceBuilder.target(name: String, block: MetaBuilder.() -> Unit) {
fun WorkspaceBuilder.target(name: String, base: String, block: MetaBuilder.() -> Unit) { fun WorkspaceBuilder.target(name: String, base: String, block: MetaBuilder.() -> Unit) {
val parentTarget = targets[base] ?: error("Base target with name $base not found") val parentTarget = targets[base] ?: error("Base target with name $base not found")
targets[name] = parentTarget.builder() targets[name] = parentTarget.builder()
.apply { "@baseTarget" to base } .apply { "@baseTarget" put base }
.apply(block) .apply(block)
.seal() .seal()
} }

View File

@ -121,7 +121,7 @@ class SimpleWorkspaceTest {
val customPipeTask = task<Int>("custom") { val customPipeTask = task<Int>("custom") {
mapAction<Int> { mapAction<Int> {
meta = meta.builder().apply { meta = meta.builder().apply {
"newValue" to 22 "newValue" put 22
} }
name += "new" name += "new"
result { result {
@ -142,7 +142,7 @@ class SimpleWorkspaceTest {
@Test @Test
fun testMetaPropagation() { fun testMetaPropagation() {
val node = workspace.run("sum") { "testFlag" to true } val node = workspace.run("sum") { "testFlag" put true }
val res = node.first()?.get() val res = node.first()?.get()
} }