Skip to content

Commit 9572313

Browse files
Merge pull request #1361 from Kotlin/fix_jupyter_logger
Fix jupyter logger
2 parents 086fa75 + f86b01a commit 9572313

File tree

8 files changed

+81
-14
lines changed

8 files changed

+81
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
.kotlin
99
build
1010
.ipynb_checkpoints
11+
local.properties

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ kotlin {
155155
val modulesUsingJava11 = with(projects) {
156156
setOf(
157157
dataframeJupyter,
158-
dataframeGeo,
158+
dataframeGeoJupyter,
159159
examples.ideaExamples.titanic,
160160
tests,
161161
plugins.dataframeGradlePlugin,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
with(libs.plugins) {
5+
alias(kotlin.jvm)
6+
alias(publisher)
7+
alias(jupyter.api)
8+
alias(ktlint)
9+
alias(dataframe)
10+
alias(ksp)
11+
}
12+
}
13+
14+
group = "org.jetbrains.kotlinx"
15+
16+
repositories {
17+
// geo repository should come before Maven Central
18+
maven("https://repo.osgeo.org/repository/release")
19+
mavenCentral()
20+
mavenLocal()
21+
}
22+
23+
// https://stackoverflow.com/questions/26993105/i-get-an-error-downloading-javax-media-jai-core1-1-3-from-maven-central
24+
// jai core dependency should be excluded from geotools dependencies and added separately
25+
fun ExternalModuleDependency.excludeJaiCore() = exclude("javax.media", "jai_core")
26+
27+
dependencies {
28+
implementation(projects.dataframeGeo)
29+
implementation(projects.dataframeJupyter)
30+
31+
implementation(libs.geotools.referencing) { excludeJaiCore() }
32+
33+
// logger, need it for geotools
34+
implementation(libs.log4j.core)
35+
implementation(libs.log4j.api)
36+
37+
testImplementation(kotlin("test"))
38+
}
39+
40+
tasks.withType<KotlinCompile>().configureEach {
41+
friendPaths.from(project(projects.core.path).projectDir)
42+
}
43+
44+
kotlinPublications {
45+
publication {
46+
publicationName = "dataframeGeoJupyter"
47+
artifactId = project.name
48+
description = "GeoDataFrame API"
49+
packageName = artifactId
50+
}
51+
}
52+
53+
tasks.processJupyterApiResources {
54+
libraryProducers = listOf("org.jetbrains.kotlinx.dataframe.jupyter.IntegrationGeo")
55+
}
56+
57+
tasks.test {
58+
useJUnitPlatform()
59+
}

dataframe-geo/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt renamed to dataframe-geo-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ internal class IntegrationGeo : JupyterIntegration() {
5454
useSchema<WithMultiLineStringGeometry>()
5555
}
5656

57+
render<GeoDataFrame<*>> {
58+
println("GeoDataFrame with ${it.crs?.name?.code} CRS and inner dataframe:")
59+
it.df
60+
}
61+
5762
val replCodeGeneratorImpl = ReplCodeGeneratorImpl()
5863
replCodeGeneratorImpl.process(WithGeometry::class)
5964
replCodeGeneratorImpl.process(WithPolygonGeometry::class)
@@ -67,7 +72,7 @@ internal class IntegrationGeo : JupyterIntegration() {
6772
val generatedDf = execute(
6873
codeWithTypeCastGenerator = replCodeGeneratorImpl.process(geo.df, kProperty),
6974
expression = "(${kProperty.name}.df as DataFrame<*>)",
70-
)
75+
).let { "`$it`" }
7176
val name = execute("GeoDataFrame($generatedDf, ${kProperty.name}.crs)").name
7277
name
7378
}

dataframe-geo/build.gradle.kts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
with(libs.plugins) {
55
alias(kotlin.jvm)
66
alias(publisher)
7-
alias(jupyter.api)
87
alias(ktlint)
98
alias(dataframe)
109
alias(ksp)
@@ -14,7 +13,7 @@ plugins {
1413
group = "org.jetbrains.kotlinx"
1514

1615
repositories {
17-
// geo repository should come before Maven Central
16+
// osgeo repository should come before Maven Central
1817
maven("https://repo.osgeo.org/repository/release")
1918
mavenCentral()
2019
mavenLocal()
@@ -26,19 +25,22 @@ fun ExternalModuleDependency.excludeJaiCore() = exclude("javax.media", "jai_core
2625

2726
dependencies {
2827
api(projects.core)
29-
implementation(projects.dataframeJupyter)
3028

29+
// Geotools
3130
implementation(libs.geotools.main) { excludeJaiCore() }
3231
implementation(libs.geotools.shapefile) { excludeJaiCore() }
3332
implementation(libs.geotools.geojson) { excludeJaiCore() }
3433
implementation(libs.geotools.referencing) { excludeJaiCore() }
3534
implementation(libs.geotools.epsg.hsql) { excludeJaiCore() }
3635

36+
// JAI
3737
implementation(libs.jai.core)
3838

39+
// JTS
3940
implementation(libs.jts.core)
4041
implementation(libs.jts.io.common)
4142

43+
// Ktor
4244
implementation(libs.ktor.client.core)
4345
implementation(libs.ktor.client.cio)
4446
implementation(libs.ktor.client.content.negotiation)
@@ -54,16 +56,12 @@ tasks.withType<KotlinCompile>().configureEach {
5456
kotlinPublications {
5557
publication {
5658
publicationName = "dataframeGeo"
57-
artifactId = "dataframe-geo"
59+
artifactId = project.name
5860
description = "GeoDataFrame API"
5961
packageName = artifactId
6062
}
6163
}
6264

63-
tasks.processJupyterApiResources {
64-
libraryProducers = listOf("org.jetbrains.kotlinx.dataframe.jupyter.IntegrationGeo")
65-
}
66-
6765
tasks.test {
6866
useJUnitPlatform()
6967
}

dataframe-jupyter/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ repositories {
2020
dependencies {
2121
api(projects.dataframe)
2222

23+
// logger, need it for apache poi
24+
implementation(libs.log4j.core)
25+
implementation(libs.log4j.api)
26+
2327
testImplementation(libs.junit)
2428
testImplementation(libs.serialization.json)
29+
2530
// experimental
2631
testImplementation(projects.dataframeOpenapiGenerator)
2732
testImplementation(projects.dataframeOpenapi)

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ internal class Integration(private val notebook: Notebook, private val options:
6868
// TODO temporary settings while these experimental modules are being developed
6969

7070
private val enableExperimentalCsv = options["enableExperimentalCsv"]
71-
private val enableExperimentalGeo = options["enableExperimentalGeo"]
7271
private val enableExperimentalOpenApi = options["enableExperimentalOpenApi"]
72+
private val enableExperimentalGeo = options["enableExperimentalGeo"]
7373

7474
private fun KotlinKernelHost.updateImportDataSchemaVariable(
7575
importDataSchema: ImportDataSchema,
@@ -170,9 +170,7 @@ internal class Integration(private val notebook: Notebook, private val options:
170170
println("CSV module is already enabled by default now.")
171171
}
172172
if (enableExperimentalGeo?.toBoolean() == true) {
173-
println("Enabling experimental Geo module: dataframe-geo")
174-
repositories("https://repo.osgeo.org/repository/release")
175-
dependencies("org.jetbrains.kotlinx:dataframe-geo:$version")
173+
println("dataframe-geo module was extracted into separate descriptor: %use dataframe-geo")
176174
}
177175
if (enableExperimentalOpenApi?.toBoolean() == true) {
178176
println("Enabling experimental OpenAPI 3.0.0 module: dataframe-openapi")

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ include("dataframe-jdbc")
2121
include("dataframe-csv")
2222
include("dataframe-jupyter")
2323
include("dataframe-geo")
24+
include("dataframe-geo-jupyter")
2425
include("dataframe-openapi-generator")
2526
include("core")
2627
include("dataframe-compiler-plugin-core")

0 commit comments

Comments
 (0)