Merge pull request #77 from SciProgCentre/dev

0.6.2
This commit is contained in:
SPC-code 2023-07-29 13:13:38 +03:00 committed by GitHub
commit 182f206b88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 339 additions and 131 deletions

View File

@ -1,28 +1,31 @@
name: Dokka publication name: Dokka publication
on: on:
push: workflow_dispatch:
branches: [ master ] release:
types: [ created ]
jobs: jobs:
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-latest
timeout-minutes: 40 timeout-minutes: 40
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3.0.0
- uses: DeLaGuardo/setup-graalvm@4.0 - uses: actions/setup-java@v3.0.0
with: with:
graalvm: 21.2.0 java-version: 11
java: java11 distribution: liberica
arch: amd64 - name: Cache konan
- uses: actions/cache@v2 uses: actions/cache@v3.0.1
with: with:
path: ~/.gradle/caches path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: | restore-keys: |
${{ runner.os }}-gradle- ${{ runner.os }}-gradle-
- run: ./gradlew dokkaHtmlMultiModule --build-cache --no-daemon --no-parallel --stacktrace - uses: gradle/gradle-build-action@v2.1.5
- uses: JamesIves/github-pages-deploy-action@4.1.0 with:
arguments: dokkaHtmlMultiModule --no-parallel
- uses: JamesIves/github-pages-deploy-action@v4.3.0
with: with:
branch: gh-pages branch: gh-pages
folder: build/dokka/htmlMultiModule folder: build/dokka/htmlMultiModule

View File

@ -9,32 +9,18 @@ jobs:
publish: publish:
environment: environment:
name: publish name: publish
env:
publishing.github: false
strategy: strategy:
matrix: matrix:
os: [ macOS-latest, windows-latest ] os: [ macOS-latest, windows-latest ]
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
steps: steps:
- name: Checkout the repo - uses: actions/checkout@v3.0.0
uses: actions/checkout@v2 - uses: actions/setup-java@v3.10.0
- name: Set up JDK 11
uses: DeLaGuardo/setup-graalvm@4.0
with: with:
graalvm: 21.2.0 java-version: 11
java: java11 distribution: liberica
arch: amd64
- name: Cache gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache konan - name: Cache konan
uses: actions/cache@v2 uses: actions/cache@v3.0.1
with: with:
path: ~/.konan path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
@ -42,14 +28,23 @@ jobs:
${{ runner.os }}-gradle- ${{ runner.os }}-gradle-
- name: Publish Windows Artifacts - name: Publish Windows Artifacts
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
shell: cmd uses: gradle/gradle-build-action@v2.4.0
run: > with:
./gradlew release --no-daemon --build-cache -Ppublishing.enabled=true arguments: |
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} publishAllPublicationsToSpaceRepository
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} -Ppublishing.targets=all
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}
- name: Publish Mac Artifacts - name: Publish Mac Artifacts
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
run: > uses: gradle/gradle-build-action@v2.4.0
./gradlew release --no-daemon --build-cache -Ppublishing.enabled=true with:
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} arguments: |
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} publishMacosX64PublicationToSpaceRepository
publishMacosArm64PublicationToSpaceRepository
publishIosX64PublicationToSpaceRepository
publishIosArm64PublicationToSpaceRepository
publishIosSimulatorArm64PublicationToSpaceRepository
-Ppublishing.targets=all
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}

View File

@ -14,6 +14,12 @@
### Security ### Security
## 0.6.2 - 2023-07-29
### Changed
- Meta to Json serializer now serializes a single item with index as an array. It is important for plotly integration.
- Meta to Json serializes Meta without children a value as literal or array instead of an object with `@value` field.
## 0.6.1 - 2023-03-31 ## 0.6.1 - 2023-03-31
### Added ### Added

View File

@ -3,47 +3,39 @@
![Gradle build](https://github.com/mipt-npm/dataforge-core/workflows/Gradle%20build/badge.svg) ![Gradle build](https://github.com/mipt-npm/dataforge-core/workflows/Gradle%20build/badge.svg)
<hr/>
* ### [dataforge-context](dataforge-context) ### [dataforge-context](dataforge-context)
> >
> >
> **Maturity**: DEVELOPMENT > **Maturity**: DEVELOPMENT
<hr/>
* ### [dataforge-data](dataforge-data) ### [dataforge-data](dataforge-data)
> >
> >
> **Maturity**: EXPERIMENTAL > **Maturity**: EXPERIMENTAL
<hr/>
* ### [dataforge-io](dataforge-io) ### [dataforge-io](dataforge-io)
> >
> >
> **Maturity**: PROTOTYPE > **Maturity**: PROTOTYPE
<hr/>
* ### [dataforge-meta](dataforge-meta) ### [dataforge-meta](dataforge-meta)
> >
> >
> **Maturity**: DEVELOPMENT > **Maturity**: DEVELOPMENT
<hr/>
* ### [dataforge-scripting](dataforge-scripting) ### [dataforge-scripting](dataforge-scripting)
> >
> >
> **Maturity**: PROTOTYPE > **Maturity**: PROTOTYPE
<hr/>
* ### [dataforge-workspace](dataforge-workspace) ### [dataforge-workspace](dataforge-workspace)
> >
> >
> **Maturity**: EXPERIMENTAL > **Maturity**: EXPERIMENTAL
<hr/>
* ### [dataforge-io-yaml](dataforge-io/dataforge-io-yaml) ### [dataforge-io/dataforge-io-yaml](dataforge-io/dataforge-io-yaml)
> YAML meta converters and Front Matter envelope format > YAML meta converters and Front Matter envelope format
> >
> **Maturity**: PROTOTYPE > **Maturity**: PROTOTYPE
<hr/>

View File

@ -9,7 +9,7 @@ plugins {
allprojects { allprojects {
group = "space.kscience" group = "space.kscience"
version = "0.6.1" version = "0.6.2"
} }
subprojects { subprojects {

View File

@ -0,0 +1,32 @@
# Module dataforge-context
Context and provider definitions
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-context:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-context:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-context:0.6.2-dev-2")
}
```

32
dataforge-data/README.md Normal file
View File

@ -0,0 +1,32 @@
# Module dataforge-data
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-data:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-data:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-data:0.6.2-dev-2")
}
```

View File

@ -112,7 +112,6 @@ internal class ReduceAction<T : Any, R : Any>(
* A one-to-one mapping action * A one-to-one mapping action
*/ */
@DFExperimental @DFExperimental
@Suppress("FunctionName")
public inline fun <reified T : Any, reified R : Any> Action.Companion.reduce( public inline fun <reified T : Any, reified R : Any> Action.Companion.reduce(
noinline builder: ReduceGroupBuilder<T, R>.() -> Unit, noinline builder: ReduceGroupBuilder<T, R>.() -> Unit,
): Action<T, R> = ReduceAction(typeOf<R>(), builder) ): Action<T, R> = ReduceAction(typeOf<R>(), builder)

View File

@ -87,7 +87,6 @@ internal class SplitAction<T : Any, R : Any>(
* Action that splits each incoming element into a number of fragments defined in builder * Action that splits each incoming element into a number of fragments defined in builder
*/ */
@DFExperimental @DFExperimental
@Suppress("FunctionName")
public inline fun <T : Any, reified R : Any> Action.Companion.split( public inline fun <T : Any, reified R : Any> Action.Companion.split(
noinline builder: SplitBuilder<T, R>.() -> Unit, noinline builder: SplitBuilder<T, R>.() -> Unit,
): Action<T, R> = SplitAction(typeOf<R>(), builder) ): Action<T, R> = SplitAction(typeOf<R>(), builder)

32
dataforge-io/README.md Normal file
View File

@ -0,0 +1,32 @@
# Module dataforge-io
IO module
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-io:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-io:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-io:0.6.2-dev-2")
}
```

View File

@ -10,8 +10,8 @@ kscience {
jvm() jvm()
js() js()
native() native()
useSerialization("1.4.1") useSerialization()
useSerialization("1.4.1", sourceSet = space.kscience.gradle.DependencySourceSet.TEST) { useSerialization(sourceSet = space.kscience.gradle.DependencySourceSet.TEST) {
cbor() cbor()
} }
dependencies { dependencies {
@ -20,6 +20,6 @@ kscience {
} }
} }
readme{ readme {
maturity = space.kscience.gradle.Maturity.PROTOTYPE maturity = space.kscience.gradle.Maturity.PROTOTYPE
} }

View File

@ -0,0 +1,32 @@
# Module dataforge-io-yaml
YAML meta IO
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-io-yaml:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-io-yaml:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-io-yaml:0.6.2-dev-2")
}
```

View File

@ -4,10 +4,6 @@ plugins {
description = "YAML meta IO" description = "YAML meta IO"
repositories {
mavenCentral()
}
kscience { kscience {
jvm() jvm()
js() js()
@ -20,10 +16,6 @@ kscience {
} }
} }
repositories{
maven("https://dl.bintray.com/mamoe/yamlkt")
}
readme{ readme{
maturity = space.kscience.gradle.Maturity.PROTOTYPE maturity = space.kscience.gradle.Maturity.PROTOTYPE
description =""" description ="""

View File

@ -6,7 +6,7 @@ package space.kscience.dataforge.io
import io.ktor.utils.io.core.Input import io.ktor.utils.io.core.Input
import io.ktor.utils.io.core.Output import io.ktor.utils.io.core.Output
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonElement
import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.Context
import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.MetaDescriptor
@ -19,8 +19,8 @@ import space.kscience.dataforge.meta.toMeta
public class JsonMetaFormat(private val json: Json = DEFAULT_JSON) : MetaFormat { public class JsonMetaFormat(private val json: Json = DEFAULT_JSON) : MetaFormat {
override fun writeMeta(output: Output, meta: Meta, descriptor: MetaDescriptor?) { override fun writeMeta(output: Output, meta: Meta, descriptor: MetaDescriptor?) {
val jsonObject = meta.toJson(descriptor) val jsonElement = meta.toJson(descriptor)
output.writeUtf8String(json.encodeToString(JsonObject.serializer(), jsonObject)) output.writeUtf8String(json.encodeToString(JsonElement.serializer(), jsonElement))
} }
override fun readMeta(input: Input, descriptor: MetaDescriptor?): Meta { override fun readMeta(input: Input, descriptor: MetaDescriptor?): Meta {

32
dataforge-meta/README.md Normal file
View File

@ -0,0 +1,32 @@
# Module dataforge-meta
Meta definition and basic operations on meta
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-meta:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-meta:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-meta:0.6.2-dev-2")
}
```

View File

@ -6,7 +6,7 @@ kscience {
jvm() jvm()
js() js()
native() native()
useSerialization("1.4.1"){ useSerialization{
json() json()
} }
} }

View File

@ -23,7 +23,6 @@ public fun Value.toJson(descriptor: MetaDescriptor? = null): JsonElement = when
} }
//Use these methods to customize JSON key mapping //Use these methods to customize JSON key mapping
@Suppress("NULLABLE_EXTENSION_OPERATOR_WITH_SAFE_CALL_RECEIVER")
private fun String.toJsonKey(descriptor: MetaDescriptor?) = descriptor?.attributes?.get("jsonName").string ?: toString() private fun String.toJsonKey(descriptor: MetaDescriptor?) = descriptor?.attributes?.get("jsonName").string ?: toString()
private fun Meta.toJsonWithIndex(descriptor: MetaDescriptor?, index: String?): JsonElement = if (items.isEmpty()) { private fun Meta.toJsonWithIndex(descriptor: MetaDescriptor?, index: String?): JsonElement = if (items.isEmpty()) {
@ -35,9 +34,13 @@ private fun Meta.toJsonWithIndex(descriptor: MetaDescriptor?, index: String?): J
val childDescriptor = descriptor?.children?.get(body) val childDescriptor = descriptor?.children?.get(body)
if (list.size == 1) { if (list.size == 1) {
val (token, element) = list.first() val (token, element) = list.first()
//do not add empty element //do not add an empty element
val child: JsonElement = element.toJsonWithIndex(childDescriptor, token.index) val child: JsonElement = element.toJsonWithIndex(childDescriptor, token.index)
body to child if(token.index == null) {
body to child
} else {
body to JsonArray(listOf(child))
}
} else { } else {
val elements: List<JsonElement> = list.sortedBy { it.key.index }.mapIndexed { index, entry -> val elements: List<JsonElement> = list.sortedBy { it.key.index }.mapIndexed { index, entry ->
//Use index if it is not equal to the item order //Use index if it is not equal to the item order
@ -61,30 +64,24 @@ private fun Meta.toJsonWithIndex(descriptor: MetaDescriptor?, index: String?): J
JsonObject(pairs.toMap()) JsonObject(pairs.toMap())
} }
public fun Meta.toJson(descriptor: MetaDescriptor? = null): JsonObject { /**
val element = toJsonWithIndex(descriptor, null) * Convert Meta to [JsonElement]. Meta with children is converted to [JsonObject].
return if (element is JsonObject) { * Meta without children is converted to either [JsonPrimitive] or [JsonArray] depending on the value type.
element * An empty Meta is converted to an empty JsonObject.
} else { */
buildJsonObject { public fun Meta.toJson(descriptor: MetaDescriptor? = null): JsonElement = toJsonWithIndex(descriptor, null)
put("@value", element)
}
}
}
/** /**
* Convert a Json primitive to a [Value] * Convert a Json primitive to a [Value]
*/ */
public fun JsonPrimitive.toValue(descriptor: MetaDescriptor?): Value { public fun JsonPrimitive.toValue(descriptor: MetaDescriptor?): Value = when (this) {
return when (this) { JsonNull -> Null
JsonNull -> Null else -> {
else -> { if (isString) {
if (isString) { content.asValue()
StringValue(content) } else {
} else { //consider using LazyParse
//consider using LazyParse content.parseValue()
content.parseValue()
}
} }
} }
} }

View File

@ -226,7 +226,7 @@ public fun <E : Enum<E>> E.asValue(): Value = EnumValue(this)
/** /**
* Create Value from String using closest match conversion * Create Value from String using the closest match conversion
*/ */
public fun String.parseValue(): Value { public fun String.parseValue(): Value {

View File

@ -1,15 +1,45 @@
package space.kscience.dataforge.meta package space.kscience.dataforge.meta
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import space.kscience.dataforge.names.asName
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
class MetaSerializationTest { class MetaSerializationTest {
@Test @Test
fun singleValueDeserialization(){ fun singleValueDeserialization() {
val string = "ddd" val string = "ddd"
val meta = Json.decodeFromString(MetaSerializer, string) val meta = Json.decodeFromString(MetaSerializer, string)
assertEquals(string, meta.value?.string) assertEquals(string, meta.value?.string)
} }
@Test
fun complexMeta() {
val meta = Meta {
"a" put 28.3
"b" put doubleArrayOf(1.0, 2.0, 3.2)
"child" put Meta {
"a" put "aString"
"sns[0]" put Meta {
"d" put 0
}
"sns[1]" put Meta {
"d" put 1
}
setIndexed(
"sns2".asName(),
listOf(
Meta { "d" put "first" },
Meta("53")
)
)
}
}
val string = Json.encodeToString(MetaSerializer, meta)
println(string)
val reconstructed = Json.decodeFromString(MetaSerializer, string)
assertEquals(meta, reconstructed)
}
} }

View File

@ -0,0 +1,32 @@
# Module dataforge-scripting
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-scripting:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-scripting:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-scripting:0.6.2-dev-2")
}
```

View File

@ -0,0 +1,32 @@
# Module dataforge-workspace
## Usage
## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-workspace:0.6.2-dev-2`.
**Gradle Groovy:**
```groovy
repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}
dependencies {
implementation 'space.kscience:dataforge-workspace:0.6.2-dev-2'
}
```
**Gradle Kotlin DSL:**
```kotlin
repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}
dependencies {
implementation("space.kscience:dataforge-workspace:0.6.2-dev-2")
}
```

View File

@ -1,29 +0,0 @@
> #### Artifact:
>
> This module artifact: `${group}:${name}:${version}`.
>
>
> [![Maven Central](https://img.shields.io/maven-central/v/space.kscience/${name}.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience%22%20AND%20a:%22${name}%22)
>
> **Gradle:**
>
> ```gradle
> repositories {
> maven { url 'https://repo.kotlin.link' }
> }
>
> dependencies {
> implementation '${group}:${name}:${version}'
> }
> ```
> **Gradle Kotlin DSL:**
>
> ```kotlin
> repositories {
> maven("https://https://repo.kotlin.link")
> }
>
> dependencies {
> implementation("${group}:${name}:${version}")
> }
> ```

View File

@ -3,4 +3,4 @@
![Gradle build](https://github.com/mipt-npm/dataforge-core/workflows/Gradle%20build/badge.svg) ![Gradle build](https://github.com/mipt-npm/dataforge-core/workflows/Gradle%20build/badge.svg)
$modules ${modules}

View File

@ -6,4 +6,4 @@ kotlin.mpp.stability.nowarn=true
kotlin.incremental.js.ir=true kotlin.incremental.js.ir=true
kotlin.native.ignoreDisabledTargets=true kotlin.native.ignoreDisabledTargets=true
toolsVersion=0.14.5-kotlin-1.8.20-RC toolsVersion=0.14.9-kotlin-1.8.20

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists