From b7618cc08fa3632ded6974c046a8d8a33c59e58f Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 9 Oct 2023 13:35:39 +0300 Subject: [PATCH] update build versions --- build.gradle.kts | 6 +- gradle.properties | 7 +- gradle/wrapper/gradle-wrapper.properties | 2 +- numass-analysis/build.gradle.kts | 4 +- numass-data-model/build.gradle.kts | 15 +- numass-data-proto/build.gradle.kts | 2 +- .../kotlin/ru/inr/mass/data/proto/Point.kt | 133 +++++++++++------- .../inr/mass/data/proto/NumassProtoPlugin.kt | 2 - .../data/proto/TaggedNumassEnvelopeFormat.kt | 73 +++------- numass-data-server/build.gradle.kts | 85 +++++------ .../mass/data/server/NumassCommonPlugin.kt | 2 - .../ru/inr/mass/data/server/NumassJsPlugin.kt | 3 - numass-model/build.gradle.kts | 9 +- .../kotlin/ru/inr/mass/models/FSS.kt | 2 +- .../kotlin/ru/inr/mass/models/NBkgSpectrum.kt | 2 +- .../main/kotlin/ru/inr/mass/scripts/fit.kt | 6 +- .../mass/workspace/NumassWorkspacePlugin.kt | 2 - .../kotlin/ru/inr/mass/workspace/dataUtils.kt | 2 +- .../kotlin/ru/inr/mass/workspace/plots.kt | 2 +- settings.gradle.kts | 1 - 20 files changed, 171 insertions(+), 189 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ee4db13..639b645 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,12 +13,12 @@ allprojects { } group = "ru.inr.mass" - version = "0.1.4-dev-1" + version = "0.1.4-dev-2" } -val dataforgeVersion by extra("0.6.0-dev-15") +val dataforgeVersion by extra("0.6.2") val tablesVersion: String by extra("0.2.0-dev-3") -val kmathVersion by extra("0.3.1-dev-9") +val kmathVersion by extra("0.3.1") val visionForgeVersion: String by rootProject.extra("0.3.0-dev-6") diff --git a/gradle.properties b/gradle.properties index 4897b9d..87fa69b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,12 +5,11 @@ kotlin.code.style=official kotlin.mpp.stability.nowarn=true - -kotlin.jupyter.add.scanner=false +kotlin.js.compiler=ir org.gradle.configureondemand=true org.gradle.parallel=true org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G -toolsVersion=0.13.3-kotlin-1.7.20 -compose.version=1.2.2 +toolsVersion=0.14.10-kotlin-1.9.0 +compose.version=1.5.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..db9a6b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/numass-analysis/build.gradle.kts b/numass-analysis/build.gradle.kts index bdc8b0d..6076065 100644 --- a/numass-analysis/build.gradle.kts +++ b/numass-analysis/build.gradle.kts @@ -8,7 +8,9 @@ val dataforgeVersion: String by rootProject.extra val kmathVersion: String by rootProject.extra val tablesVersion: String by rootProject.extra -kotlin.sourceSets { +kscience { + jvm() + js() commonMain { dependencies { api(projects.numass.numassDataModel) diff --git a/numass-data-model/build.gradle.kts b/numass-data-model/build.gradle.kts index a670f18..6159224 100644 --- a/numass-data-model/build.gradle.kts +++ b/numass-data-model/build.gradle.kts @@ -6,7 +6,11 @@ plugins { val dataforgeVersion: String by rootProject.extra -kotlin.sourceSets { +kscience{ + jvm() + js() + useSerialization() + commonMain { dependencies { api("space.kscience:dataforge-context:$dataforgeVersion") @@ -14,15 +18,14 @@ kotlin.sourceSets { api("org.jetbrains.kotlinx:kotlinx-datetime:${space.kscience.gradle.KScienceVersions.dateTimeVersion}") } } - jvmMain{ +} + +kotlin.sourceSets{ + getByName("jvmMain"){ dependencies{ api("ch.qos.logback:logback-classic:1.2.3") } } } -kscience{ - useSerialization() -} - diff --git a/numass-data-proto/build.gradle.kts b/numass-data-proto/build.gradle.kts index c47065c..b9093cd 100644 --- a/numass-data-proto/build.gradle.kts +++ b/numass-data-proto/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("space.kscience.gradle.jvm") - id("com.squareup.wire") version "4.4.1" + id("com.squareup.wire") version "4.9.1" `maven-publish` } diff --git a/numass-data-proto/src/gen/kotlin/ru/inr/mass/data/proto/Point.kt b/numass-data-proto/src/gen/kotlin/ru/inr/mass/data/proto/Point.kt index 1ccfaa2..ee8a3c2 100644 --- a/numass-data-proto/src/gen/kotlin/ru/inr/mass/data/proto/Point.kt +++ b/numass-data-proto/src/gen/kotlin/ru/inr/mass/data/proto/Point.kt @@ -4,6 +4,7 @@ package ru.inr.mass.`data`.proto import com.squareup.wire.* import com.squareup.wire.Syntax.PROTO_3 +import com.squareup.wire.internal.JvmField import com.squareup.wire.internal.immutableCopyOf import com.squareup.wire.internal.redactElements import okio.ByteString @@ -19,6 +20,7 @@ public class Point( tag = 1, adapter = "ru.inr.mass.data.proto.Point${'$'}Channel#ADAPTER", label = WireField.Label.REPEATED, + schemaIndex = 0, ) public val channels: List = immutableCopyOf("channels", channels) @@ -26,10 +28,10 @@ public class Point( message = "Shouldn't be used in Kotlin", level = DeprecationLevel.HIDDEN, ) - public override fun newBuilder(): Nothing = throw + override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin") - public override fun equals(other: Any?): Boolean { + override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is Point) return false if (unknownFields != other.unknownFields) return false @@ -37,7 +39,7 @@ public class Point( return true } - public override fun hashCode(): Int { + override fun hashCode(): Int { var result = super.hashCode if (result == 0) { result = unknownFields.hashCode() @@ -47,7 +49,7 @@ public class Point( return result } - public override fun toString(): String { + override fun toString(): String { val result = mutableListOf() if (channels.isNotEmpty()) result += """channels=$channels""" return result.joinToString(prefix = "Point{", separator = ", ", postfix = "}") @@ -66,23 +68,23 @@ public class Point( null, "numass-proto.proto" ) { - public override fun encodedSize(`value`: Point): Int { + override fun encodedSize(`value`: Point): Int { var size = value.unknownFields.size size += Channel.ADAPTER.asRepeated().encodedSizeWithTag(1, value.channels) return size } - public override fun encode(writer: ProtoWriter, `value`: Point): Unit { + override fun encode(writer: ProtoWriter, `value`: Point) { Channel.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.channels) writer.writeBytes(value.unknownFields) } - public override fun encode(writer: ReverseProtoWriter, `value`: Point): Unit { + override fun encode(writer: ReverseProtoWriter, `value`: Point) { writer.writeBytes(value.unknownFields) Channel.ADAPTER.asRepeated().encodeWithTag(writer, 1, value.channels) } - public override fun decode(reader: ProtoReader): Point { + override fun decode(reader: ProtoReader): Point { val channels = mutableListOf() val unknownFields = reader.forEachTag { tag -> when (tag) { @@ -96,7 +98,7 @@ public class Point( ) } - public override fun redact(`value`: Point): Point = value.copy( + override fun redact(`value`: Point): Point = value.copy( channels = value.channels.redactElements(Channel.ADAPTER), unknownFields = ByteString.EMPTY ) @@ -116,6 +118,7 @@ public class Point( tag = 1, adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.OMIT_IDENTITY, + schemaIndex = 0, ) public val id: Long = 0L, blocks: List = emptyList(), @@ -128,6 +131,7 @@ public class Point( tag = 2, adapter = "ru.inr.mass.data.proto.Point${'$'}Channel${'$'}Block#ADAPTER", label = WireField.Label.REPEATED, + schemaIndex = 1, ) public val blocks: List = immutableCopyOf("blocks", blocks) @@ -135,10 +139,10 @@ public class Point( message = "Shouldn't be used in Kotlin", level = DeprecationLevel.HIDDEN, ) - public override fun newBuilder(): Nothing = throw + override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin") - public override fun equals(other: Any?): Boolean { + override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is Channel) return false if (unknownFields != other.unknownFields) return false @@ -147,7 +151,7 @@ public class Point( return true } - public override fun hashCode(): Int { + override fun hashCode(): Int { var result = super.hashCode if (result == 0) { result = unknownFields.hashCode() @@ -158,7 +162,7 @@ public class Point( return result } - public override fun toString(): String { + override fun toString(): String { val result = mutableListOf() result += """id=$id""" if (blocks.isNotEmpty()) result += """blocks=$blocks""" @@ -181,26 +185,26 @@ public class Point( null, "numass-proto.proto" ) { - public override fun encodedSize(`value`: Channel): Int { + override fun encodedSize(`value`: Channel): Int { var size = value.unknownFields.size if (value.id != 0L) size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.id) size += Block.ADAPTER.asRepeated().encodedSizeWithTag(2, value.blocks) return size } - public override fun encode(writer: ProtoWriter, `value`: Channel): Unit { + override fun encode(writer: ProtoWriter, `value`: Channel) { if (value.id != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id) Block.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.blocks) writer.writeBytes(value.unknownFields) } - public override fun encode(writer: ReverseProtoWriter, `value`: Channel): Unit { + override fun encode(writer: ReverseProtoWriter, `value`: Channel) { writer.writeBytes(value.unknownFields) Block.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.blocks) if (value.id != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id) } - public override fun decode(reader: ProtoReader): Channel { + override fun decode(reader: ProtoReader): Channel { var id: Long = 0L val blocks = mutableListOf() val unknownFields = reader.forEachTag { tag -> @@ -217,7 +221,7 @@ public class Point( ) } - public override fun redact(`value`: Channel): Channel = value.copy( + override fun redact(`value`: Channel): Channel = value.copy( blocks = value.blocks.redactElements(Block.ADAPTER), unknownFields = ByteString.EMPTY ) @@ -237,6 +241,7 @@ public class Point( tag = 1, adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.OMIT_IDENTITY, + schemaIndex = 0, ) public val time: Long = 0L, frames: List = emptyList(), @@ -247,6 +252,7 @@ public class Point( tag = 3, adapter = "ru.inr.mass.data.proto.Point${'$'}Channel${'$'}Block${'$'}Events#ADAPTER", label = WireField.Label.OMIT_IDENTITY, + schemaIndex = 2, ) public val events: Events? = null, /** @@ -256,6 +262,7 @@ public class Point( tag = 4, adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.OMIT_IDENTITY, + schemaIndex = 3, ) public val length: Long = 0L, /** @@ -266,6 +273,7 @@ public class Point( adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.OMIT_IDENTITY, jsonName = "binSize", + schemaIndex = 4, ) public val bin_size: Long = 0L, unknownFields: ByteString = ByteString.EMPTY, @@ -277,6 +285,7 @@ public class Point( tag = 2, adapter = "ru.inr.mass.data.proto.Point${'$'}Channel${'$'}Block${'$'}Frame#ADAPTER", label = WireField.Label.REPEATED, + schemaIndex = 1, ) public val frames: List = immutableCopyOf("frames", frames) @@ -284,10 +293,10 @@ public class Point( message = "Shouldn't be used in Kotlin", level = DeprecationLevel.HIDDEN, ) - public override fun newBuilder(): Nothing = throw + override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin") - public override fun equals(other: Any?): Boolean { + override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is Block) return false if (unknownFields != other.unknownFields) return false @@ -299,7 +308,7 @@ public class Point( return true } - public override fun hashCode(): Int { + override fun hashCode(): Int { var result = super.hashCode if (result == 0) { result = unknownFields.hashCode() @@ -313,7 +322,7 @@ public class Point( return result } - public override fun toString(): String { + override fun toString(): String { val result = mutableListOf() result += """time=$time""" if (frames.isNotEmpty()) result += """frames=$frames""" @@ -342,7 +351,7 @@ public class Point( null, "numass-proto.proto" ) { - public override fun encodedSize(`value`: Block): Int { + override fun encodedSize(`value`: Block): Int { var size = value.unknownFields.size if (value.time != 0L) size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.time) size += Frame.ADAPTER.asRepeated().encodedSizeWithTag(2, value.frames) @@ -353,7 +362,7 @@ public class Point( return size } - public override fun encode(writer: ProtoWriter, `value`: Block): Unit { + override fun encode(writer: ProtoWriter, `value`: Block) { if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time) Frame.ADAPTER.asRepeated().encodeWithTag(writer, 2, value.frames) if (value.events != null) Events.ADAPTER.encodeWithTag(writer, 3, value.events) @@ -362,7 +371,7 @@ public class Point( writer.writeBytes(value.unknownFields) } - public override fun encode(writer: ReverseProtoWriter, `value`: Block): Unit { + override fun encode(writer: ReverseProtoWriter, `value`: Block) { writer.writeBytes(value.unknownFields) if (value.bin_size != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 5, value.bin_size) if (value.length != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 4, value.length) @@ -371,7 +380,7 @@ public class Point( if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time) } - public override fun decode(reader: ProtoReader): Block { + override fun decode(reader: ProtoReader): Block { var time: Long = 0L val frames = mutableListOf() var events: Events? = null @@ -397,7 +406,7 @@ public class Point( ) } - public override fun redact(`value`: Block): Block = value.copy( + override fun redact(`value`: Block): Block = value.copy( frames = value.frames.redactElements(Frame.ADAPTER), events = value.events?.let(Events.ADAPTER::redact), unknownFields = ByteString.EMPTY @@ -418,6 +427,7 @@ public class Point( tag = 1, adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.OMIT_IDENTITY, + schemaIndex = 0, ) public val time: Long = 0L, /** @@ -428,6 +438,7 @@ public class Point( adapter = "com.squareup.wire.ProtoAdapter#BYTES", label = WireField.Label.OMIT_IDENTITY, declaredName = "data", + schemaIndex = 1, ) public val data_: ByteString = ByteString.EMPTY, unknownFields: ByteString = ByteString.EMPTY, @@ -436,10 +447,10 @@ public class Point( message = "Shouldn't be used in Kotlin", level = DeprecationLevel.HIDDEN, ) - public override fun newBuilder(): Nothing = throw + override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin") - public override fun equals(other: Any?): Boolean { + override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is Frame) return false if (unknownFields != other.unknownFields) return false @@ -448,7 +459,7 @@ public class Point( return true } - public override fun hashCode(): Int { + override fun hashCode(): Int { var result = super.hashCode if (result == 0) { result = unknownFields.hashCode() @@ -459,7 +470,7 @@ public class Point( return result } - public override fun toString(): String { + override fun toString(): String { val result = mutableListOf() result += """time=$time""" result += """data_=$data_""" @@ -482,7 +493,7 @@ public class Point( null, "numass-proto.proto" ) { - public override fun encodedSize(`value`: Frame): Int { + override fun encodedSize(`value`: Frame): Int { var size = value.unknownFields.size if (value.time != 0L) size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.time) if (value.data_ != ByteString.EMPTY) size += ProtoAdapter.BYTES.encodedSizeWithTag(2, @@ -490,21 +501,21 @@ public class Point( return size } - public override fun encode(writer: ProtoWriter, `value`: Frame): Unit { + override fun encode(writer: ProtoWriter, `value`: Frame) { if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time) if (value.data_ != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 2, value.data_) writer.writeBytes(value.unknownFields) } - public override fun encode(writer: ReverseProtoWriter, `value`: Frame): Unit { + override fun encode(writer: ReverseProtoWriter, `value`: Frame) { writer.writeBytes(value.unknownFields) if (value.data_ != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 2, value.data_) if (value.time != 0L) ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.time) } - public override fun decode(reader: ProtoReader): Frame { + override fun decode(reader: ProtoReader): Frame { var time: Long = 0L var data_: ByteString = ByteString.EMPTY val unknownFields = reader.forEachTag { tag -> @@ -521,7 +532,7 @@ public class Point( ) } - public override fun redact(`value`: Frame): Frame = value.copy( + override fun redact(`value`: Frame): Frame = value.copy( unknownFields = ByteString.EMPTY ) } @@ -547,6 +558,7 @@ public class Point( tag = 1, adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.PACKED, + schemaIndex = 0, ) public val times: List = immutableCopyOf("times", times) @@ -557,6 +569,7 @@ public class Point( tag = 2, adapter = "com.squareup.wire.ProtoAdapter#UINT64", label = WireField.Label.PACKED, + schemaIndex = 1, ) public val amplitudes: List = immutableCopyOf("amplitudes", amplitudes) @@ -564,10 +577,10 @@ public class Point( message = "Shouldn't be used in Kotlin", level = DeprecationLevel.HIDDEN, ) - public override fun newBuilder(): Nothing = throw + override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin") - public override fun equals(other: Any?): Boolean { + override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is Events) return false if (unknownFields != other.unknownFields) return false @@ -576,7 +589,7 @@ public class Point( return true } - public override fun hashCode(): Int { + override fun hashCode(): Int { var result = super.hashCode if (result == 0) { result = unknownFields.hashCode() @@ -587,7 +600,7 @@ public class Point( return result } - public override fun toString(): String { + override fun toString(): String { val result = mutableListOf() if (times.isNotEmpty()) result += """times=$times""" if (amplitudes.isNotEmpty()) result += """amplitudes=$amplitudes""" @@ -610,43 +623,61 @@ public class Point( null, "numass-proto.proto" ) { - public override fun encodedSize(`value`: Events): Int { + override fun encodedSize(`value`: Events): Int { var size = value.unknownFields.size size += ProtoAdapter.UINT64.asPacked().encodedSizeWithTag(1, value.times) size += ProtoAdapter.UINT64.asPacked().encodedSizeWithTag(2, value.amplitudes) return size } - public override fun encode(writer: ProtoWriter, `value`: Events): Unit { + override fun encode(writer: ProtoWriter, `value`: Events) { ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 1, value.times) ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 2, value.amplitudes) writer.writeBytes(value.unknownFields) } - public override fun encode(writer: ReverseProtoWriter, `value`: Events): Unit { + override fun encode(writer: ReverseProtoWriter, `value`: Events) { writer.writeBytes(value.unknownFields) ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 2, value.amplitudes) ProtoAdapter.UINT64.asPacked().encodeWithTag(writer, 1, value.times) } - public override fun decode(reader: ProtoReader): Events { - val times = mutableListOf() - val amplitudes = mutableListOf() + override fun decode(reader: ProtoReader): Events { + var times: MutableList? = null + var amplitudes: MutableList? = null val unknownFields = reader.forEachTag { tag -> when (tag) { - 1 -> times.add(ProtoAdapter.UINT64.decode(reader)) - 2 -> amplitudes.add(ProtoAdapter.UINT64.decode(reader)) + 1 -> { + if (times == null) { + val minimumByteSize = 1 + val initialCapacity = (reader.nextFieldMinLengthInBytes() / minimumByteSize) + .coerceAtMost(Int.MAX_VALUE.toLong()) + .toInt() + times = ArrayList(initialCapacity) + } + times!!.add(ProtoAdapter.UINT64.decode(reader)) + } + 2 -> { + if (amplitudes == null) { + val minimumByteSize = 1 + val initialCapacity = (reader.nextFieldMinLengthInBytes() / minimumByteSize) + .coerceAtMost(Int.MAX_VALUE.toLong()) + .toInt() + amplitudes = ArrayList(initialCapacity) + } + amplitudes!!.add(ProtoAdapter.UINT64.decode(reader)) + } else -> reader.readUnknownField(tag) } } return Events( - times = times, - amplitudes = amplitudes, + times = times ?: listOf(), + amplitudes = amplitudes ?: listOf(), unknownFields = unknownFields ) } - public override fun redact(`value`: Events): Events = value.copy( + override fun redact(`value`: Events): Events = value.copy( unknownFields = ByteString.EMPTY ) } diff --git a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/NumassProtoPlugin.kt b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/NumassProtoPlugin.kt index 512c548..5e52222 100644 --- a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/NumassProtoPlugin.kt +++ b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/NumassProtoPlugin.kt @@ -20,7 +20,6 @@ import java.nio.file.Path import kotlin.io.path.exists import kotlin.io.path.isDirectory import kotlin.io.path.relativeTo -import kotlin.reflect.KClass public class NumassProtoPlugin : AbstractPlugin() { public val io: IOPlugin by require(IOPlugin) @@ -35,7 +34,6 @@ public class NumassProtoPlugin : AbstractPlugin() { public companion object : PluginFactory { override fun build(context: Context, meta: Meta): NumassProtoPlugin = NumassProtoPlugin() override val tag: PluginTag = PluginTag("numass-proto", group = "ru.inr.mass") - override val type: KClass = NumassProtoPlugin::class } } diff --git a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt index ef9b310..a640010 100644 --- a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt +++ b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt @@ -39,24 +39,8 @@ public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeForm writeRawString(END_SEQUENCE) } - override fun writeEnvelope( - output: Output, - envelope: Envelope, - metaFormatFactory: MetaFormatFactory, - formatMeta: Meta, - ) { + override fun writeObject(output: Output, obj: Envelope) { error("Don't write legacy formats") -// val metaFormat = metaFormatFactory.invoke(formatMeta, io.context) -// val metaBytes = metaFormat.toBinary(envelope.meta) -// val actualSize: ULong = (envelope.data?.size ?: 0).toULong() -// val tag = Tag(metaFormatFactory.key, metaBytes.size.toUInt() + 2u, actualSize) -// output.writeBinary(tag.toBinary()) -// output.writeBinary(metaBytes) -// output.writeRawString("\r\n") -// envelope.data?.let { -// output.writeBinary(it) -// } -// output.flush() } /** @@ -68,31 +52,30 @@ public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeForm override fun readObject(input: Input): Envelope { val tag = input.readTag() - val metaFormat = io.resolveMetaFormat(tag.metaFormatKey) - ?: error("Meta format with key ${tag.metaFormatKey} not found") + val metaFormat = io.resolveMetaFormat(tag.metaFormatKey) ?: JsonMetaFormat val meta: Meta = metaFormat.readObjectFrom(input.readBinary(tag.metaSize.toInt())) val data = input.readBinary(tag.dataSize.toInt()) - return SimpleEnvelope(meta, data) - } - - override fun readPartial(input: Input): PartialEnvelope { - val tag = input.readTag() - - val metaFormat = if (tag.metaFormatKey == 1.toShort()) { - JsonMetaFormat - } else { - io.resolveMetaFormat(tag.metaFormatKey) - ?: error("Meta format with key ${tag.metaFormatKey} not found") - } - - val meta: Meta = metaFormat.readObjectFrom(input.readBinary(tag.metaSize.toInt())) - - - return PartialEnvelope(meta, 30 + tag.metaSize.toInt(), tag.dataSize) + return Envelope(meta, data) } +// +// override fun readPartial(input: Input): PartialEnvelope { +// val tag = input.readTag() +// +// val metaFormat = if (tag.metaFormatKey == 1.toShort()) { +// JsonMetaFormat +// } else { +// io.resolveMetaFormat(tag.metaFormatKey) +// ?: error("Meta format with key ${tag.metaFormatKey} not found") +// } +// +// val meta: Meta = metaFormat.readObjectFrom(input.readBinary(tag.metaSize.toInt())) +// +// +// return PartialEnvelope(meta, 30 + tag.metaSize.toInt(), tag.dataSize) +// } private data class Tag( val metaFormatKey: Short, @@ -149,23 +132,11 @@ public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeForm private val default by lazy { invoke() } - override fun readPartial(input: Input): PartialEnvelope = - default.run { readPartial(input) } - - override fun writeEnvelope( - output: Output, - envelope: Envelope, - metaFormatFactory: MetaFormatFactory, - formatMeta: Meta, - ): Unit = default.run { - writeEnvelope( - output, - envelope, - metaFormatFactory, - formatMeta - ) + override fun writeObject(output: Output, obj: Envelope) { + error("Don't write legacy formats") } + override fun readObject(input: Input): Envelope = default.readObject(input) } } \ No newline at end of file diff --git a/numass-data-server/build.gradle.kts b/numass-data-server/build.gradle.kts index 9c05fde..84164db 100644 --- a/numass-data-server/build.gradle.kts +++ b/numass-data-server/build.gradle.kts @@ -8,62 +8,41 @@ val visionForgeVersion: String by rootProject.extra val production: Boolean by rootProject.extra(true) -kotlin { - js(IR) { - browser { - webpackTask { - this.outputFileName = "js/numass-web.js" - } - } - binaries.executable() - } - - sourceSets { - commonMain { - dependencies { - implementation(project(":numass-data-model")) - implementation("space.kscience:visionforge-core:$visionForgeVersion") - implementation("space.kscience:visionforge-plotly:$visionForgeVersion") - implementation(compose.runtime) - } - } - jvmMain { - dependencies { - implementation(project(":numass-data-proto")) - implementation("io.ktor:ktor-server-cio:2.1.3") - implementation("io.ktor:ktor-server-html-builder-jvm:2.1.3") - implementation("space.kscience:visionforge-plotly:$visionForgeVersion") - } - } - jsMain{ - dependencies{ - implementation(compose.web.core) - } - } - - } -} - -afterEvaluate { - val distributionTask = if (production) { - tasks.getByName("jsBrowserDistribution") - } else { - tasks.getByName("jsBrowserDevelopmentExecutableDistribution") - } - - tasks.getByName("jvmProcessResources") { - dependsOn(distributionTask) - from(distributionTask) - include("**/*.js") - if (production) { - include("**/*.map") - } - } -} kscience { + fullStack("js/numass-web.js") + useSerialization { json() } - withContextReceivers() + + useContextReceivers() + useKtor() + + commonMain { + dependencies { + implementation(project(":numass-data-model")) + implementation("space.kscience:visionforge-core:$visionForgeVersion") + implementation("space.kscience:visionforge-plotly:$visionForgeVersion") + } + } } + +kotlin{ + sourceSets{ + getByName("jvmMain"){ + dependencies{ + implementation(compose.runtime) + implementation(project(":numass-data-proto")) + implementation("io.ktor:ktor-server-cio") + implementation("io.ktor:ktor-server-html-builder") + implementation("space.kscience:visionforge-plotly:$visionForgeVersion") + } + } + getByName("jsMain"){ + dependencies{ + implementation(compose.html.core) + } + } + } +} \ No newline at end of file diff --git a/numass-data-server/src/commonMain/kotlin/ru/inr/mass/data/server/NumassCommonPlugin.kt b/numass-data-server/src/commonMain/kotlin/ru/inr/mass/data/server/NumassCommonPlugin.kt index 6813a39..7730d3e 100644 --- a/numass-data-server/src/commonMain/kotlin/ru/inr/mass/data/server/NumassCommonPlugin.kt +++ b/numass-data-server/src/commonMain/kotlin/ru/inr/mass/data/server/NumassCommonPlugin.kt @@ -9,7 +9,6 @@ import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionPlugin -import kotlin.reflect.KClass public class NumassCommonPlugin(meta: Meta = Meta.EMPTY) : VisionPlugin(meta) { override val tag: PluginTag get() = Companion.tag @@ -18,7 +17,6 @@ public class NumassCommonPlugin(meta: Meta = Meta.EMPTY) : VisionPlugin(meta) { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("numass.common", "ru.inr.mass") - override val type: KClass = NumassCommonPlugin::class override fun build(context: Context, meta: Meta): NumassCommonPlugin = NumassCommonPlugin() diff --git a/numass-data-server/src/jsMain/kotlin/ru/inr/mass/data/server/NumassJsPlugin.kt b/numass-data-server/src/jsMain/kotlin/ru/inr/mass/data/server/NumassJsPlugin.kt index c30acb6..586e356 100644 --- a/numass-data-server/src/jsMain/kotlin/ru/inr/mass/data/server/NumassJsPlugin.kt +++ b/numass-data-server/src/jsMain/kotlin/ru/inr/mass/data/server/NumassJsPlugin.kt @@ -18,7 +18,6 @@ import space.kscience.visionforge.ElementVisionRenderer import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionClient import space.kscience.visionforge.plotly.PlotlyPlugin -import kotlin.reflect.KClass public class NumassJsPlugin : AbstractPlugin(), ElementVisionRenderer { public val client: VisionClient by require(VisionClient) @@ -83,8 +82,6 @@ public class NumassJsPlugin : AbstractPlugin(), ElementVisionRenderer { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("numass.js", "ru.inr.mass") - override val type: KClass = NumassJsPlugin::class - override fun build(context: Context, meta: Meta): NumassJsPlugin = NumassJsPlugin() } diff --git a/numass-model/build.gradle.kts b/numass-model/build.gradle.kts index 721289d..13e3abb 100644 --- a/numass-model/build.gradle.kts +++ b/numass-model/build.gradle.kts @@ -7,7 +7,9 @@ plugins { val dataforgeVersion: String by rootProject.extra val kmathVersion: String by rootProject.extra -kotlin.sourceSets { +kscience{ + jvm() + js() commonMain { dependencies { api("space.kscience:dataforge-context:$dataforgeVersion") @@ -15,7 +17,10 @@ kotlin.sourceSets { api("space.kscience:kmath-functions:$kmathVersion") } } - jvmMain { +} + +kotlin.sourceSets{ + getByName("jvmMain"){ dependencies { api("space.kscience:kmath-commons:$kmathVersion") api("ch.qos.logback:logback-classic:1.2.3") diff --git a/numass-model/src/commonMain/kotlin/ru/inr/mass/models/FSS.kt b/numass-model/src/commonMain/kotlin/ru/inr/mass/models/FSS.kt index 3fbf7cb..2ddf349 100644 --- a/numass-model/src/commonMain/kotlin/ru/inr/mass/models/FSS.kt +++ b/numass-model/src/commonMain/kotlin/ru/inr/mass/models/FSS.kt @@ -15,10 +15,10 @@ */ package ru.inr.mass.models +import space.kscience.kmath.UnstableKMathAPI import space.kscience.kmath.data.ColumnarData import space.kscience.kmath.expressions.Symbol import space.kscience.kmath.expressions.symbol -import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.structures.Buffer diff --git a/numass-model/src/commonMain/kotlin/ru/inr/mass/models/NBkgSpectrum.kt b/numass-model/src/commonMain/kotlin/ru/inr/mass/models/NBkgSpectrum.kt index 08fcddb..2dc811f 100644 --- a/numass-model/src/commonMain/kotlin/ru/inr/mass/models/NBkgSpectrum.kt +++ b/numass-model/src/commonMain/kotlin/ru/inr/mass/models/NBkgSpectrum.kt @@ -33,7 +33,7 @@ public class NBkgSpectrum(public val source: Spectrum) : DifferentiableSpectrum symbols.isEmpty() -> this symbols.size == 1 -> when (symbols.first()) { norm -> Spectrum { x, arguments -> source(x, arguments) } - bkg -> Spectrum { x, _ -> 1.0 } + bkg -> Spectrum { _, _ -> 1.0 } else -> (source as? DifferentiableSpectrum)?.derivativeOrNull(symbols)?.let { NBkgSpectrum(it) } } else -> null diff --git a/numass-workspace/src/main/kotlin/ru/inr/mass/scripts/fit.kt b/numass-workspace/src/main/kotlin/ru/inr/mass/scripts/fit.kt index 45a9c4d..3042e32 100644 --- a/numass-workspace/src/main/kotlin/ru/inr/mass/scripts/fit.kt +++ b/numass-workspace/src/main/kotlin/ru/inr/mass/scripts/fit.kt @@ -4,14 +4,16 @@ import ru.inr.mass.models.* import ru.inr.mass.workspace.buffer import ru.inr.mass.workspace.fitWith import ru.inr.mass.workspace.generate +import space.kscience.kmath.UnstableKMathAPI import space.kscience.kmath.expressions.Symbol import space.kscience.kmath.expressions.derivative -import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.asSequence import space.kscience.kmath.optimization.* import space.kscience.kmath.real.step -import space.kscience.plotly.* +import space.kscience.plotly.Plotly +import space.kscience.plotly.makeFile import space.kscience.plotly.models.ScatterMode +import space.kscience.plotly.scatter import kotlin.math.pow diff --git a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassWorkspacePlugin.kt b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassWorkspacePlugin.kt index f7bc2b5..876d4c4 100644 --- a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassWorkspacePlugin.kt +++ b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/NumassWorkspacePlugin.kt @@ -18,7 +18,6 @@ import space.kscience.dataforge.workspace.WorkspacePlugin import space.kscience.dataforge.workspace.pipeFrom import space.kscience.dataforge.workspace.task import space.kscience.tables.Table -import kotlin.reflect.KClass class NumassWorkspacePlugin : WorkspacePlugin() { override val tag: PluginTag get() = Companion.tag @@ -128,7 +127,6 @@ class NumassWorkspacePlugin : WorkspacePlugin() { companion object : PluginFactory { override val tag: PluginTag = PluginTag("numass", "ru.mipt.npm") - override val type: KClass = NumassWorkspacePlugin::class override fun build(context: Context, meta: Meta): NumassWorkspacePlugin = NumassWorkspacePlugin() } } \ No newline at end of file diff --git a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/dataUtils.kt b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/dataUtils.kt index 1979389..e0bcffb 100644 --- a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/dataUtils.kt +++ b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/dataUtils.kt @@ -3,13 +3,13 @@ package ru.inr.mass.workspace import ru.inr.mass.models.Spectrum +import space.kscience.kmath.UnstableKMathAPI import space.kscience.kmath.data.XYColumnarData import space.kscience.kmath.data.XYErrorColumnarData import space.kscience.kmath.expressions.DifferentiableExpression import space.kscience.kmath.expressions.Symbol import space.kscience.kmath.misc.FeatureSet import space.kscience.kmath.misc.Loggable -import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.optimization.* import space.kscience.kmath.random.RandomGenerator import space.kscience.kmath.samplers.PoissonSampler diff --git a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/plots.kt b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/plots.kt index 797d00a..195bc1e 100644 --- a/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/plots.kt +++ b/numass-workspace/src/main/kotlin/ru/inr/mass/workspace/plots.kt @@ -12,9 +12,9 @@ import ru.inr.mass.data.proto.HVData import ru.inr.mass.data.proto.NumassDirectorySet import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.double +import space.kscience.kmath.UnstableKMathAPI import space.kscience.kmath.domains.center import space.kscience.kmath.histogram.Histogram1D -import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.asIterable import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.DoubleBuffer diff --git a/settings.gradle.kts b/settings.gradle.kts index 70e2d4b..04e6c6d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,6 @@ rootProject.name = "numass" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -enableFeaturePreview("VERSION_CATALOGS") pluginManagement {