Peter
05/01/2023, 8:44 PMConflicting import, imported name 'Instant' is ambiguous
In this particular case I want to import java.time.Instant
, but dataframe wants to import kotlinx.datetime.Instant
Is there a way I can manipulate/disable the import statements of the other library (dataframe) before they are executed (or another work around)?Ilya Muradyan
05/01/2023, 10:00 PMfun getDataframeIntegration(
lastCellClass: KClass<*>,
notebook: Notebook,
version: String
): LibraryDefinition {
val classLoader = lastCellClass.java.classLoader
val integrationClass = classLoader.loadClass("org.jetbrains.kotlinx.dataframe.jupyter.Integration")
val integrationConstructor = integrationClass.constructors.single()
val integrationProducer = integrationConstructor.newInstance(notebook, mapOf("v" to version)) as LibraryDefinitionProducer
val dataframeDefinition = integrationProducer.getDefinitions(notebook).first()
return dataframeDefinition
}
In the notebook context (considering dataframe dependencies were loaded) it should be called like this:
val dfIntegration = getDataframeIntegration(this::class, notebook, "0.11.0-dev-1608")
Then, obtained dataframe integration should be used to construct new integration:
val newIntegration = libraryDefinition {
it.afterCellExecution = dfIntegration.afterCellExecution
it.converters = dfIntegration.converters
// <do not copy "imports">...
}
And finally, this new integration should be loaded:
USE {
onLoaded {
scheduleExecution {
addLibrary(newIntegration)
}
}
}
So probably it doesn't worth to do. I hope we'll design better API laterIlya Muradyan
05/01/2023, 10:05 PMnotebook.libraryLoader
to load definitions without adding to the context. And also will add a data-class-like copy function for LibraryDefinitionPeter
05/02/2023, 4:53 AM