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

View File

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

View File

@ -3,47 +3,39 @@
![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
<hr/>
* ### [dataforge-data](dataforge-data)
### [dataforge-data](dataforge-data)
>
>
> **Maturity**: EXPERIMENTAL
<hr/>
* ### [dataforge-io](dataforge-io)
### [dataforge-io](dataforge-io)
>
>
> **Maturity**: PROTOTYPE
<hr/>
* ### [dataforge-meta](dataforge-meta)
### [dataforge-meta](dataforge-meta)
>
>
> **Maturity**: DEVELOPMENT
<hr/>
* ### [dataforge-scripting](dataforge-scripting)
### [dataforge-scripting](dataforge-scripting)
>
>
> **Maturity**: PROTOTYPE
<hr/>
* ### [dataforge-workspace](dataforge-workspace)
### [dataforge-workspace](dataforge-workspace)
>
>
> **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
>
> **Maturity**: PROTOTYPE
<hr/>

View File

@ -9,7 +9,7 @@ plugins {
allprojects {
group = "space.kscience"
version = "0.6.1"
version = "0.6.2"
}
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
*/
@DFExperimental
@Suppress("FunctionName")
public inline fun <reified T : Any, reified R : Any> Action.Companion.reduce(
noinline builder: ReduceGroupBuilder<T, R>.() -> Unit,
): 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
*/
@DFExperimental
@Suppress("FunctionName")
public inline fun <T : Any, reified R : Any> Action.Companion.split(
noinline builder: SplitBuilder<T, R>.() -> Unit,
): 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()
js()
native()
useSerialization("1.4.1")
useSerialization("1.4.1", sourceSet = space.kscience.gradle.DependencySourceSet.TEST) {
useSerialization()
useSerialization(sourceSet = space.kscience.gradle.DependencySourceSet.TEST) {
cbor()
}
dependencies {
@ -20,6 +20,6 @@ kscience {
}
}
readme{
readme {
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"
repositories {
mavenCentral()
}
kscience {
jvm()
js()
@ -20,10 +16,6 @@ kscience {
}
}
repositories{
maven("https://dl.bintray.com/mamoe/yamlkt")
}
readme{
maturity = space.kscience.gradle.Maturity.PROTOTYPE
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.Output
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.meta.Meta
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 {
override fun writeMeta(output: Output, meta: Meta, descriptor: MetaDescriptor?) {
val jsonObject = meta.toJson(descriptor)
output.writeUtf8String(json.encodeToString(JsonObject.serializer(), jsonObject))
val jsonElement = meta.toJson(descriptor)
output.writeUtf8String(json.encodeToString(JsonElement.serializer(), jsonElement))
}
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()
js()
native()
useSerialization("1.4.1"){
useSerialization{
json()
}
}

View File

@ -23,7 +23,6 @@ public fun Value.toJson(descriptor: MetaDescriptor? = null): JsonElement = when
}
//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 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)
if (list.size == 1) {
val (token, element) = list.first()
//do not add empty element
val child: JsonElement = element.toJsonWithIndex(childDescriptor, token.index)
body to child
//do not add an empty element
val child: JsonElement = element.toJsonWithIndex(childDescriptor, token.index)
if(token.index == null) {
body to child
} else {
body to JsonArray(listOf(child))
}
} else {
val elements: List<JsonElement> = list.sortedBy { it.key.index }.mapIndexed { index, entry ->
//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())
}
public fun Meta.toJson(descriptor: MetaDescriptor? = null): JsonObject {
val element = toJsonWithIndex(descriptor, null)
return if (element is JsonObject) {
element
} else {
buildJsonObject {
put("@value", element)
}
}
}
/**
* Convert Meta to [JsonElement]. Meta with children is converted to [JsonObject].
* Meta without children is converted to either [JsonPrimitive] or [JsonArray] depending on the value type.
* An empty Meta is converted to an empty JsonObject.
*/
public fun Meta.toJson(descriptor: MetaDescriptor? = null): JsonElement = toJsonWithIndex(descriptor, null)
/**
* Convert a Json primitive to a [Value]
*/
public fun JsonPrimitive.toValue(descriptor: MetaDescriptor?): Value {
return when (this) {
JsonNull -> Null
else -> {
if (isString) {
StringValue(content)
} else {
//consider using LazyParse
content.parseValue()
}
public fun JsonPrimitive.toValue(descriptor: MetaDescriptor?): Value = when (this) {
JsonNull -> Null
else -> {
if (isString) {
content.asValue()
} else {
//consider using LazyParse
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 {

View File

@ -1,15 +1,45 @@
package space.kscience.dataforge.meta
import kotlinx.serialization.json.Json
import space.kscience.dataforge.names.asName
import kotlin.test.Test
import kotlin.test.assertEquals
class MetaSerializationTest {
@Test
fun singleValueDeserialization(){
fun singleValueDeserialization() {
val string = "ddd"
val meta = Json.decodeFromString(MetaSerializer, 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)
$modules
${modules}

View File

@ -6,4 +6,4 @@ kotlin.mpp.stability.nowarn=true
kotlin.incremental.js.ir=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
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
zipStorePath=wrapper/dists