Skip to content

Fix jupyter logger #1361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
.kotlin
build
.ipynb_checkpoints
local.properties
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ kotlin {
val modulesUsingJava11 = with(projects) {
setOf(
dataframeJupyter,
dataframeGeo,
dataframeGeoJupyter,
examples.ideaExamples.titanic,
tests,
plugins.dataframeGradlePlugin,
Expand Down
59 changes: 59 additions & 0 deletions dataframe-geo-jupyter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
with(libs.plugins) {
alias(kotlin.jvm)
alias(publisher)
alias(jupyter.api)
alias(ktlint)
alias(dataframe)
alias(ksp)
}
}

group = "org.jetbrains.kotlinx"

repositories {
// geo repository should come before Maven Central
maven("https://repo.osgeo.org/repository/release")
mavenCentral()
mavenLocal()
}

// https://stackoverflow.com/questions/26993105/i-get-an-error-downloading-javax-media-jai-core1-1-3-from-maven-central
// jai core dependency should be excluded from geotools dependencies and added separately
fun ExternalModuleDependency.excludeJaiCore() = exclude("javax.media", "jai_core")

dependencies {
implementation(projects.dataframeGeo)
implementation(projects.dataframeJupyter)

implementation(libs.geotools.referencing) { excludeJaiCore() }

// logger, need it for geotools
implementation(libs.log4j.core)
implementation(libs.log4j.api)

testImplementation(kotlin("test"))
}

tasks.withType<KotlinCompile>().configureEach {
friendPaths.from(project(projects.core.path).projectDir)
}

kotlinPublications {
publication {
publicationName = "dataframeGeoJupyter"
artifactId = project.name
description = "GeoDataFrame API"
packageName = artifactId
}
}

tasks.processJupyterApiResources {
libraryProducers = listOf("org.jetbrains.kotlinx.dataframe.jupyter.IntegrationGeo")
}

tasks.test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ internal class IntegrationGeo : JupyterIntegration() {
useSchema<WithMultiLineStringGeometry>()
}

render<GeoDataFrame<*>> {
println("GeoDataFrame with ${it.crs?.name?.code} CRS and inner dataframe:")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ideal, better use notebook.display("text") for such things. Reason: we can't guarantee standard stream sync in multithreading envs.

it.df
}

val replCodeGeneratorImpl = ReplCodeGeneratorImpl()
replCodeGeneratorImpl.process(WithGeometry::class)
replCodeGeneratorImpl.process(WithPolygonGeometry::class)
Expand All @@ -67,7 +72,7 @@ internal class IntegrationGeo : JupyterIntegration() {
val generatedDf = execute(
codeWithTypeCastGenerator = replCodeGeneratorImpl.process(geo.df, kProperty),
expression = "(${kProperty.name}.df as DataFrame<*>)",
)
).let { "`$it`" }
val name = execute("GeoDataFrame($generatedDf, ${kProperty.name}.crs)").name
name
}
Expand Down
14 changes: 6 additions & 8 deletions dataframe-geo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
with(libs.plugins) {
alias(kotlin.jvm)
alias(publisher)
alias(jupyter.api)
alias(ktlint)
alias(dataframe)
alias(ksp)
Expand All @@ -14,7 +13,7 @@ plugins {
group = "org.jetbrains.kotlinx"

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

dependencies {
api(projects.core)
implementation(projects.dataframeJupyter)

// Geotools
implementation(libs.geotools.main) { excludeJaiCore() }
implementation(libs.geotools.shapefile) { excludeJaiCore() }
implementation(libs.geotools.geojson) { excludeJaiCore() }
implementation(libs.geotools.referencing) { excludeJaiCore() }
implementation(libs.geotools.epsg.hsql) { excludeJaiCore() }

// JAI
implementation(libs.jai.core)

// JTS
implementation(libs.jts.core)
implementation(libs.jts.io.common)

// Ktor
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.client.content.negotiation)
Expand All @@ -54,16 +56,12 @@ tasks.withType<KotlinCompile>().configureEach {
kotlinPublications {
publication {
publicationName = "dataframeGeo"
artifactId = "dataframe-geo"
artifactId = project.name
description = "GeoDataFrame API"
packageName = artifactId
}
}

tasks.processJupyterApiResources {
libraryProducers = listOf("org.jetbrains.kotlinx.dataframe.jupyter.IntegrationGeo")
}

tasks.test {
useJUnitPlatform()
}
5 changes: 5 additions & 0 deletions dataframe-jupyter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ repositories {
dependencies {
api(projects.dataframe)

// logger, need it for apache poi
implementation(libs.log4j.core)
implementation(libs.log4j.api)

testImplementation(libs.junit)
testImplementation(libs.serialization.json)

// experimental
testImplementation(projects.dataframeOpenapiGenerator)
testImplementation(projects.dataframeOpenapi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ internal class Integration(private val notebook: Notebook, private val options:
// TODO temporary settings while these experimental modules are being developed

private val enableExperimentalCsv = options["enableExperimentalCsv"]
private val enableExperimentalGeo = options["enableExperimentalGeo"]
private val enableExperimentalOpenApi = options["enableExperimentalOpenApi"]
private val enableExperimentalGeo = options["enableExperimentalGeo"]

private fun KotlinKernelHost.updateImportDataSchemaVariable(
importDataSchema: ImportDataSchema,
Expand Down Expand Up @@ -170,9 +170,7 @@ internal class Integration(private val notebook: Notebook, private val options:
println("CSV module is already enabled by default now.")
}
if (enableExperimentalGeo?.toBoolean() == true) {
println("Enabling experimental Geo module: dataframe-geo")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of completely removing it, please provide a helpful message of what to do instead :)

We mentioned the enableExperimentalGeo in some release, so if it suddenly does nothing anymore, people will be confused

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

repositories("https://repo.osgeo.org/repository/release")
dependencies("org.jetbrains.kotlinx:dataframe-geo:$version")
println("dataframe-geo module was extracted into separate descriptor: %use dataframe-geo")
}
if (enableExperimentalOpenApi?.toBoolean() == true) {
println("Enabling experimental OpenAPI 3.0.0 module: dataframe-openapi")
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include("dataframe-jdbc")
include("dataframe-csv")
include("dataframe-jupyter")
include("dataframe-geo")
include("dataframe-geo-jupyter")
include("dataframe-openapi-generator")
include("core")
include("dataframe-compiler-plugin-core")
Expand Down