https://kotlinlang.org logo
#datascience
Title
# datascience
p

Peter

07/22/2022, 6:29 AM
Recently decided to upgrade my project to Kotlin Jupyter 0.11.0-125 and although all the runtime code is still fine, the test module that I’m using in my unit tests (kotlin-jupyter-test-kit) changed a lot. Are there examples or documentation how to use it, especially how to create in instance of
ReplForJupyterImpl
with its many parameters (like
MutableNotebook
,
RuntimeKernelProperties
) ?
i

Ilya Muradyan

07/22/2022, 9:46 AM
Hi, Peter! Sorry for that. Just use
org.jetbrains.kotlinx.jupyter.repl.creating.createRepl
instead
p

Peter

07/22/2022, 10:20 AM
Thanks, just tried it and one step closer. Remains the mandatory properties. Right now I take a very simple approach:
Copy code
runtimeProperties = RuntimeKernelProperties(emptyMap()),
But then I get exceptions like:
Copy code
java.lang.RuntimeException: Current branch is not specified!

	at org.jetbrains.kotlinx.jupyter.RuntimeKernelProperties.getCurrentBranch(config.kt:73)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.getCurrentBranch(repl.kt:193)
	at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.<init>(repl.kt:199)
	at org.jetbrains.kotlinx.jupyter.repl.creating.ReplFactory.createRepl(ReplFactory.kt:18)
i

Ilya Muradyan

07/22/2022, 11:46 AM
You may pass nothing there, the default properties will be used then. and it's enough. Or you need some special properties?
If you need to access runtime properties of created REPL, use
runtimeProperties
property
p

Peter

07/22/2022, 11:55 AM
I thought using the following statement would create empty properties:
Copy code
runtimeProperties = RuntimeKernelProperties(emptyMap())
What would the correct way to create an empty instance of ReplRuntimeProperties that I can use as a parameter to the createRepl (it is defined as non-null)?
i

Ilya Muradyan

07/22/2022, 12:22 PM
You need to specify at least three properties - all the properties that throw exceptions if they're empty: https://github.com/Kotlin/kotlin-jupyter/blob/7146f1fdcd4bc5dacaab635c302b0a5497bcd1d1/src/main/kotlin/org/jetbrains/kotlinx/jupyter/config.kt#L52 These properties are taken from resource file that is stored inside kernel JAR, that's why you most likely wish to reuse them. In this case, just use
org.jetbrains.kotlinx.jupyter.defaultRuntimeProperties
Alternatively, implement
ReplRuntimeProperties
interface and use this implementation
🙌 1
p

Peter

07/22/2022, 1:08 PM
Thanks, that indeed solved the second challenge and my notebook regression tests are running fine again 🙂
👍 1
4 Views