Skip to content

Commit b6cefbb

Browse files
authored
Merge pull request #1115 from Kotlin/openapi-experimental
OpenAPI -> experimental
2 parents be58c94 + 2f5c64b commit b6cefbb

File tree

28 files changed

+1264
-300
lines changed

28 files changed

+1264
-300
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,21 @@ Check it out on [**Datalore**](https://datalore.jetbrains.com/view/notebook/vq5j
219219

220220
Explore [**more examples here**](examples).
221221

222-
## Kotlin, Kotlin Jupyter, OpenAPI, Arrow and JDK versions
222+
## Kotlin, Kotlin Jupyter, Arrow, and JDK versions
223223

224224
This table shows the mapping between main library component versions and minimum supported Java versions.
225225

226-
| Kotlin DataFrame Version | Minimum Java Version | Kotlin Version | Kotlin Jupyter Version | OpenAPI version | Apache Arrow version |
227-
|--------------------------|----------------------|----------------|------------------------|-----------------|----------------------|
228-
| 0.10.0 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
229-
| 0.10.1 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
230-
| 0.11.0 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
231-
| 0.11.1 | 8 | 1.8.20 | 0.11.0-358 | 3.0.0 | 11.0.0 |
232-
| 0.12.0 | 8 | 1.9.0 | 0.11.0-358 | 3.0.0 | 11.0.0 |
233-
| 0.12.1 | 8 | 1.9.0 | 0.11.0-358 | 3.0.0 | 11.0.0 |
234-
| 0.13.1 | 8 | 1.9.22 | 0.12.0-139 | 3.0.0 | 15.0.0 |
235-
| 0.14.1 | 8 | 2.0.20 | 0.12.0-139 | 3.0.0 | 17.0.0 |
236-
| 0.15.0 | 8 | 2.0.20 | 0.12.0-139 | 3.0.0 | 18.1.0 |
226+
| Kotlin DataFrame Version | Minimum Java Version | Kotlin Version | Kotlin Jupyter Version | Apache Arrow version |
227+
|--------------------------|----------------------|----------------|------------------------|----------------------|
228+
| 0.10.0 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
229+
| 0.10.1 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
230+
| 0.11.0 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
231+
| 0.11.1 | 8 | 1.8.20 | 0.11.0-358 | 11.0.0 |
232+
| 0.12.0 | 8 | 1.9.0 | 0.11.0-358 | 11.0.0 |
233+
| 0.12.1 | 8 | 1.9.0 | 0.11.0-358 | 11.0.0 |
234+
| 0.13.1 | 8 | 1.9.22 | 0.12.0-139 | 15.0.0 |
235+
| 0.14.1 | 8 | 2.0.20 | 0.12.0-139 | 17.0.0 |
236+
| 0.15.0 | 8 | 2.0.20 | 0.12.0-139 | 18.1.0 |
237237

238238
## Code of Conduct
239239

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ dependencies {
5252
api(projects.core)
5353
api(projects.dataframeArrow)
5454
api(projects.dataframeExcel)
55-
api(projects.dataframeOpenapi)
5655
api(projects.dataframeJdbc)
5756
api(projects.dataframeCsv)
5857

58+
// experimental, so not included by default:
59+
// api(projects.dataframeOpenapi)
60+
5961
kover(projects.core)
6062
kover(projects.dataframeArrow)
6163
kover(projects.dataframeExcel)

core/api/core.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ public abstract interface annotation class org/jetbrains/kotlinx/dataframe/annot
240240

241241
public abstract interface annotation class org/jetbrains/kotlinx/dataframe/annotations/ImportDataSchema : java/lang/annotation/Annotation {
242242
public abstract fun csvOptions ()Lorg/jetbrains/kotlinx/dataframe/annotations/CsvOptions;
243+
public abstract fun enableExperimentalOpenApi ()Z
243244
public abstract fun jdbcOptions ()Lorg/jetbrains/kotlinx/dataframe/annotations/JdbcOptions;
244245
public abstract fun jsonOptions ()Lorg/jetbrains/kotlinx/dataframe/annotations/JsonOptions;
245246
public abstract fun name ()Ljava/lang/String;
@@ -5941,7 +5942,10 @@ public final class org/jetbrains/kotlinx/dataframe/jupyter/ImportDataSchemaKt {
59415942

59425943
public final class org/jetbrains/kotlinx/dataframe/jupyter/JupyterConfiguration {
59435944
public fun <init> ()V
5945+
public fun <init> (Z)V
5946+
public synthetic fun <init> (ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
59445947
public final fun getDisplay ()Lorg/jetbrains/kotlinx/dataframe/io/DisplayConfiguration;
5948+
public final fun getEnableExperimentalOpenApi ()Z
59455949
public final fun getVersion ()Ljava/lang/String;
59465950
public final fun invoke (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlinx/dataframe/jupyter/JupyterConfiguration;
59475951
}

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/annotations/ImportDataSchema.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.jetbrains.kotlinx.dataframe.io.JSON
2727
* @param csvOptions options to parse CSV data. Not used when data is not Csv
2828
* @param jsonOptions options to parse JSON data. Not used when data is not Json
2929
* @param jdbcOptions options to parse data from a database via JDBC. Not used when data is not stored in the database
30+
* @param enableExperimentalOpenApi Can be set to `true` to enable experimental OpenAPI 3.0.0 types support
3031
*/
3132
@Retention(AnnotationRetention.SOURCE)
3233
@Target(AnnotationTarget.FILE)
@@ -40,6 +41,7 @@ public annotation class ImportDataSchema(
4041
val csvOptions: CsvOptions = CsvOptions(','),
4142
val jsonOptions: JsonOptions = JsonOptions(),
4243
val jdbcOptions: JdbcOptions = JdbcOptions(),
44+
val enableExperimentalOpenApi: Boolean = false,
4345
)
4446

4547
public enum class DataSchemaVisibility {

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/JupyterConfiguration.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package org.jetbrains.kotlinx.dataframe.jupyter
33
import org.jetbrains.kotlinx.dataframe.BuildConfig
44
import org.jetbrains.kotlinx.dataframe.io.DisplayConfiguration
55

6-
public class JupyterConfiguration {
6+
public class JupyterConfiguration(
7+
/** If true, experimental OpenAPI 3.0.0 types support via importDataSchema() is enabled. Can be set via `%use dataframe(..., enableExperimentalOpenApi=true)` */
8+
public val enableExperimentalOpenApi: Boolean = false,
9+
) {
710
public val display: DisplayConfiguration = DisplayConfiguration()
811

912
/** Version of the library. */

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/importDataSchema.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ internal val importDataSchema =
2020
"""
2121
/** Import the type-only data schema from [url]. */
2222
fun importDataSchema(url: URL, name: String) {
23-
val formats = listOf(
24-
OpenApi(),
23+
val formats = listOfNotNull(
24+
if (dataFrameConfig.enableExperimentalOpenApi) OpenApi() else null,
2525
)
26+
27+
require(formats.isNotEmpty()) {
28+
"importDataSchema() did not find any supported type-only data schema generation providers (`SupportedCodeGenerationFormat`). If you were looking for OpenAPI 3.0.0 types, set `%use dataframe(..., enableExperimentalOpenApi=true)`."
29+
}
30+
2631
val codeGenResult = org.jetbrains.dataframe.impl.codeGen.CodeGenerator.urlCodeGenReader(url, formats)
2732
when (codeGenResult) {
2833
is org.jetbrains.kotlinx.dataframe.impl.codeGen.CodeGenerationReadResult.Success -> {

dataframe-geo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
This module, published as `dataframe-geo`, contains all logic and tests for DataFrame to be able to work
44
with geographical data.
55

6-
Experimental.
6+
**Experimental**.
77

88
This module targets java 11 because of the restriction from `org.jetbrains.kotlin.jupyter`.

dataframe-jupyter/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.jetbrains.kotlin.gradle.tasks.BaseKotlinCompile
21
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
32

43
plugins {
@@ -27,6 +26,10 @@ dependencies {
2726
testImplementation(projects.dataframeCsv)
2827
testImplementation(projects.dataframeExcel)
2928
testImplementation(projects.dataframeJdbc)
29+
// experimental
30+
testImplementation(projects.dataframeOpenapiGenerator)
31+
testImplementation(projects.dataframeOpenapi)
32+
3033
testImplementation(libs.kotestAssertions) {
3134
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
3235
}

dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ internal class Integration(private val notebook: Notebook, private val options:
6767
val version = options["v"]
6868

6969
// TODO temporary settings while these experimental modules are being developed
70+
7071
private val enableExperimentalCsv = options["enableExperimentalCsv"]
7172
private val enableExperimentalGeo = options["enableExperimentalGeo"]
73+
private val enableExperimentalOpenApi = options["enableExperimentalOpenApi"]
7274

7375
private fun KotlinKernelHost.updateImportDataSchemaVariable(
7476
importDataSchema: ImportDataSchema,
@@ -161,14 +163,19 @@ internal class Integration(private val notebook: Notebook, private val options:
161163
repositories("https://repo.osgeo.org/repository/release")
162164
dependencies("org.jetbrains.kotlinx:dataframe-geo:$version")
163165
}
166+
if (enableExperimentalOpenApi?.toBoolean() == true) {
167+
println("Enabling experimental OpenAPI 3.0.0 module: dataframe-openapi")
168+
dependencies(
169+
"org.jetbrains.kotlinx:dataframe-openapi:$version",
170+
"org.jetbrains.kotlinx:dataframe-openapi-generator:$version",
171+
)
172+
}
164173
dependencies(
165174
"org.jetbrains.kotlinx:dataframe-core:$version",
166175
"org.jetbrains.kotlinx:dataframe-csv:$version",
167176
"org.jetbrains.kotlinx:dataframe-excel:$version",
168177
"org.jetbrains.kotlinx:dataframe-jdbc:$version",
169178
"org.jetbrains.kotlinx:dataframe-arrow:$version",
170-
"org.jetbrains.kotlinx:dataframe-openapi:$version",
171-
"org.jetbrains.kotlinx:dataframe-openapi-generator:$version",
172179
)
173180
}
174181

@@ -181,7 +188,7 @@ internal class Integration(private val notebook: Notebook, private val options:
181188
)
182189
}
183190
val codeGen = ReplCodeGenerator.create()
184-
val config = JupyterConfiguration()
191+
val config = JupyterConfiguration(enableExperimentalOpenApi = enableExperimentalOpenApi?.toBoolean() == true)
185192

186193
if (notebook.jupyterClientType == JupyterClientType.KOTLIN_NOTEBOOK) {
187194
config.display.isolatedOutputs = true

dataframe-jupyter/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/SampleNotebooksTests.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ class SampleNotebooksTests : DataFrameJupyterTest() {
100100
),
101101
)
102102

103+
@Test
104+
fun json() =
105+
exampleTest(
106+
dir = "json",
107+
notebookName = "KeyValueAndOpenApi",
108+
cellClause = CellClause {
109+
// skip OOM cells
110+
it.metadata.tags?.contains("skiptest") != true
111+
},
112+
replacer = CodeReplacer.byMap(
113+
testFile("json", "api_guru_list.json"),
114+
testFile("json", "apiGuruMetrics.json"),
115+
testFile("json", "ApiGuruOpenApi.yaml"),
116+
),
117+
)
118+
103119
private fun doTest(
104120
notebookPath: String,
105121
replacer: CodeReplacer,

0 commit comments

Comments
 (0)