Giter Club home page Giter Club logo

kotlin-jupyter's Introduction

JetBrains official project Kotlin beta stability PyPI Anaconda Gradle plugin Maven Central GitHub Binder

Kotlin Kernel for IPython/Jupyter

Kotlin (1.9.23) kernel for Jupyter.

The kernel is a powerful engine designed to enhance your Kotlin REPL experience. It offers support for executing code cells, providing basic code completion, and analyzing errors. With the Kotlin kernel, you gain access to a range of features, including an API for handling outputs, retrieving information from previously executed code snippets, executing generic Kotlin code effortlessly, seamless integration with libraries, and more.

Screenshot in Jupyter

Beta version. Tested with Jupyter Notebook, Jupyter Lab, and Jupyter Console on Windows, Ubuntu Linux, and macOS. The minimal supported versions of clients are given in the table below:

Client Version
Jupyter Lab 1.2.6
Jupyter Notebook 6.0.3
Jupyter Console 6.1.0

To start using the Kotlin kernel for Jupyter, take a look at the introductory guide.

Example notebooks can be found in the samples folder.

Try samples online: Binder

Contents

Installation

There are several ways to use the kernel:

Kotlin Notebook plugin

Simply download and use the latest version of the Kotlin Notebook plugin from the Marketplace. The Kotlin kernel is embedded in it.

Check out the blog post for a quick introduction to Kotlin Notebook.

Conda

If you have conda installed, run the following command to install the stable package version:

conda install -c jetbrains kotlin-jupyter-kernel (package home)

To install the conda package from the dev channel:

conda install -c jetbrains-dev kotlin-jupyter-kernel (package home)

Uninstall: conda remove kotlin-jupyter-kernel

Pip

You can also install this package using pip:

Stable: pip install kotlin-jupyter-kernel (package home)

Dev: pip install -i https://test.pypi.org/simple/ kotlin-jupyter-kernel (package home)

Uninstall: pip uninstall kotlin-jupyter-kernel

From sources

To install the kernel from sources, clone the repository and run the following command in the root folder:

./gradlew install

Default installation path is ~/.ipython/kernels/kotlin/. To install to some other location use option -PinstallPath=, but note that Jupyter looks for the kernel specs files only in predefined places. For more detailed info see Jupyter docs.

Uninstall: ./gradlew uninstall

Troubleshooting

There could be a problem with kernel spec detection because of different python environments and installation modes. If you are using pip or conda to install the package, try running post-install fixup script:

python -m kotlin_kernel fix-kernelspec-location

This script replaces kernel specs to the "user" path where they are always detected. Don't forget to re-run this script on the kernel update.

Updating

To update the Kotlin kernel, follow the instructions below based on your installation method:

Kotlin Notebook

If you are using the Kotlin Notebook plugin, update it to the latest version within the IDE or manually download and install the latest plugin version from the Marketplace.

Datalore

To update the kernel in Datalore, simply add an environment.yml to the Notebook files containing:

datalore-env-format-version: "0.2"
datalore-package-manager: "pip"
datalore-base-env: "default"
dependencies:
- pip:
  - kotlin-jupyter-kernel=={VERSION}

where {VERSION} should be replaced by the latest PyPi version of the Kotlin Jupyter kernel, such as 0.11.0.198. Stop and restart the machine afterwards.

Conda

If you have conda installed, just run the following command to update the stable package version:

conda update -c jetbrains kotlin-jupyter-kernel

To update the conda package from the dev channel:

conda update -c jetbrains-dev kotlin-jupyter-kernel

If you want to change to a specific version of the kernel, take the install command from above and add ={VERSION} to kotlin-jupyter-kernel where {VERSION} should be replaced by the latest PyPi version of the Kotlin Jupyter kernel, such as 0.11.0.198.

For example, for the stable version:

conda install -c jetbrains kotlin-jupyter-kernel={VERSION}

Pip

To update the kernel using Pip, simply run:

Stable: pip install kotlin-jupyter-kernel --upgrade

Dev: pip install -i https://test.pypi.org/simple/ kotlin-jupyter-kernel --upgrade

If you want to change to a specific version of the kernel, take the install command from above and add =={VERSION} to kotlin-jupyter-kernel where {VERSION} should be replaced by the latest PyPi version of the Kotlin Jupyter kernel, such as 0.11.0.198.

For example, for the stable version:

pip install kotlin-jupyter-kernel=={VERSION} --ignore-installed

Usage

Kotlin Notebook

Within IDEA with installed Kotlin Notebook plugin, just open a notebook, and you're good to go.

Other clients

Run one of the following commands in console:

  • jupyter console --kernel=kotlin
  • jupyter notebook
  • jupyter lab

To start using kotlin kernel inside Jupyter Notebook or JupyterLab create a new notebook with kotlin kernel.

The default kernel will use the JDK pointed to by the environment variable KOTLIN_JUPYTER_JAVA_HOME, or JAVA_HOME if the first is not set.

JVM arguments will be set from the environment variable KOTLIN_JUPYTER_JAVA_OPTS or JAVA_OPTS if the first is not set. Additionally, arguments from KOTLIN_JUPYTER_JAVA_OPTS_EXTRA will be added. Arguments are parsed using shlex.split.

Creating Kernels

To create a kernel for a specific JDK, JVM arguments, and environment variables, you can use the add-kernel script:

python -m kotlin_kernel add-kernel [--name name] [--jdk jdk_home_dir] [--set-jvm-args] [--jvm-arg arg]* [--env KEY VALUE]* [--force]

The command uses argparse, so --help, @argfile (you will need to escape the @ in powershell), and --opt=value are all supported. --jvm-arg=arg in particular is needed when passing JVM arguments that start with -.

If jdk not specified, name is required. If name is not specified but jdk is the name will be JDK $vendor $version detected from the JDK. Regardless, the actual name of the kernel will be Kotlin ($name), and the directory will be kotlin_$name with the spaces in name replaced by underscores (so make sure it's compatible with your file system).

JVM arguments are joined with a ' ', so multiple JVM arguments in the same argument are supported. The arguments will be added to existing ones (see above section) unless --set-jvm-args is present, in which case they will be set to KOTLIN_JUPYTER_JAVA_OPTS. Note that both adding and setting work fine alongside KOTLIN_JUPYTER_JAVA_OPTS_EXTRA.

While jupyter kernel environment variable substitutions are supported in env, note that if the used environment variable doesn't exist, nothing will be replaced.

An example:

python -m kotlin_kernel add-kernel --name "JDK 15 Big 2 GPU" --jdk ~/.jdks/openjdk-15.0.2 --jvm-arg=-Xmx8G --env CUDA_VISIBLE_DEVICES 0,1

Supported functionality

REPL commands

The following REPL commands are supported:

  • :help - display help
  • :classpath - show current classpath
  • :vars - get visible variables values

Dependencies resolving

It is possible to add dynamic dependencies to the notebook using the following annotations:

  • @file:DependsOn(<coordinates>) - adds artifacts to classpath. Supports absolute and relative paths to class directories or jars, ivy and maven artifacts represented by the colon separated string
  • @file:Repository(<absolute-path>) - adds a directory for relative path resolution or ivy/maven repository. To specify Maven local, use @file:Repository("*mavenLocal").

Alternative way to do the same is using Gradle-like syntax:

USE {
    repositories {
        maven {
            url = "https://my.secret.repo/maven/"
            credentials {
                username = USER
                password = TOKEN
            }
        }
    }

    dependencies {
        val ktorVersion = "2.0.3"

        implementation("my.secret:artifact:1.0-beta")
        implementation("io.ktor:ktor-client-core:$ktorVersion")
        implementation("io.ktor:ktor-client-apache:$ktorVersion")
    }
}

The same syntax can be used in integrations creating.

Note that dependencies in remote repositories are resolved via Maven resolver. Caches are stored in ~/.m2/repository folder by default. Sometimes, due to network issues or running several artifacts resolutions in parallel, caches may get corrupted. If you have some troubles with artifacts resolution, please remove caches, restart kernel and try again.

Default repositories

The following maven repositories are included by default:

Line Magics

The following line magics are supported:

  • %use - injects code for supported libraries: artifact resolution, default imports, initialization code, type renderers. Usage example: %use klaxon(5.5), lets-plot
  • %trackClasspath - logs any changes of current classpath. Useful for debugging artifact resolution failures. Usage example: %trackClasspath [on|off]
  • %trackExecution - logs pieces of code that are going to be executed. Useful for debugging of libraries support. Usage example: %trackExecution [all|generated|off]
  • %useLatestDescriptors - use latest versions of library descriptors available. By default, bundled descriptors are used. Note that default behavior is preferred: latest descriptors versions might be not supported by current version of kernel. So if you care about stability of the notebook, avoid using this line magic. Usage example: %useLatestDescriptors [on|off]
  • %output - output capturing settings. Usage example: %output --max-cell-size=1000 --no-stdout --max-time=100 --max-buffer=400
  • %logLevel - set logging level. Usage example: %logLevel [off|error|warn|info|debug]

See detailed info about line magics here.

Supported Libraries

When a library is included with %use keyword, the following functionality is added to the notebook:

  • repositories to search for library artifacts
  • artifact dependencies
  • default imports
  • library initialization code
  • renderers for special types, e.g. charts and data frames

This behavior is defined by json library descriptor. Descriptors for all supported libraries can be found in libraries repository. A library descriptor may provide a set of properties with default values that can be overridden when library is included. The major use case for library properties is to specify a particular version of library. If descriptor has only one property, it can be defined without naming:

%use krangl(0.10)

If library descriptor defines more than one property, property names should be used:

%use spark(scala=2.11.10, spark=2.4.2)

Several libraries can be included in single %use statement, separated by ,:

%use lets-plot, krangl, mysql(8.0.15)

You can also specify the source of library descriptor. By default, it's taken from the libraries repository. If you want to try descriptor from another revision, use the following syntax:

// Specify some git tag from this repository
%use [email protected]
// Specify commit sha, with more verbose syntax
%use lets-plot@ref[24a040fe22335648885b106e2f4ddd63b4d49469]
// Specify git ref along with library arguments
%use krangl@dev(0.10)

Note that using descriptor from specific revision is better than using %useLatestDescriptors.

Other options are resolving library descriptor from a local file or from remote URL:

// Load library from file
%use mylib@file[/home/user/lib.json]
// Load library from file: kernel will guess it's a file actually
%use @/home/user/libs/lib.json
// Or use another approach: specify a directory and file name without 
// extension (it should be JSON in such case) before it
%use lib@/home/user/libs
// Load library descriptor from a remote URL
%use herlib@url[https://site.com/lib.json]
// If your URL responds with 200(OK), you may skip `url[]` part:
%use @https://site.com/lib.json
// You may omit library name for file and URL resolution:
%use @file[lib.json]

List of supported libraries:

  • 2p-kt - Kotlin Multi-Platform ecosystem for symbolic AI
  • biokotlin - BioKotlin aims to be a high-performance bioinformatics library that brings the power and speed of compiled programming languages to scripting and big data environments.
  • combinatoricskt - A combinatorics library for Kotlin
  • coroutines - Asynchronous programming and reactive streams support
  • dataframe - Kotlin framework for structured data processing
  • datetime - Kotlin date/time library
  • deeplearning4j - Deep learning library for the JVM
  • deeplearning4j-cuda - Deep learning library for the JVM (CUDA support)
  • default - Default imports: dataframe and Kandy libraries
  • develocity-api-kotlin - A library to use the Develocity API in Kotlin scripts or projects
  • exposed - Kotlin SQL framework
  • fuel - HTTP networking library
  • gradle-enterprise-api-kotlin - [Deprecated: use develocity-api-kotlin] A library to use the Gradle Enterprise API in Kotlin scripts or projects
  • gral - Java library for displaying plots
  • jdsp - Java library for signal processing
  • jupyter-js - Experimental %javascript/%typescript/%jsx line magic support
  • kalasim - Discrete event simulator
  • kaliningraph - Graph library with a DSL for constructing graphs and visualizing the behavior of graph algorithms
  • kandy - Kotlin plotting DSL for Lets-Plot
  • kandy-echarts - Kotlin plotting DSL for Apache ECharts
  • khttp - HTTP networking library
  • klaxon - JSON parser for Kotlin
  • kmath - Experimental Kotlin algebra-based mathematical library
  • kotlin-dl - KotlinDL library which provides Keras-like API for deep learning
  • kotlin-statistics - Idiomatic statistical operators for Kotlin
  • krangl - Kotlin DSL for data wrangling
  • kraphviz - Graphviz wrapper for JVM
  • kravis - Kotlin grammar for data visualization
  • kt-math - Kotlin multi-platform port of java.math.*
  • ktor-client - Asynchronous HTTP client
  • lets-plot - Kotlin API for Lets-Plot: multiplatform plotting library based on Grammar of Graphics
  • lets-plot-gt - Lets-Plot visualisation for GeoTools toolkit
  • lib-ext - Extended functionality for Jupyter kernel
  • londogard-nlp-toolkit - A Natural Language Processing (NLP) toolkit for Kotlin on the JVM
  • multik - Multidimensional array library for Kotlin
  • mysql - MySql JDBC Connector
  • openai - OpenAI API for Jupyter Notebooks
  • plotly - [beta] Plotly.kt jupyter integration for static plots.
  • plotly-server - [beta] Plotly.kt jupyter integration for dynamic plots.
  • rdkit - Open-Source Cheminformatics Software
  • reflection - Imports for Kotlin Reflection
  • roboquant - Algorithmic trading platform written in Kotlin
  • serialization - Deserialize JSON content using kotlinx.serialization and automatically generate classes for it
  • smile - Statistical Machine Intelligence and Learning Engine
  • spark - Kotlin API for Apache Spark: unified analytics engine for large-scale data processing
  • spark-streaming - Kotlin API for Apache Spark Streaming: scalable, high-throughput, fault-tolerant stream processing of live data streams
  • webtau - WebTau end-to-end testing across layers

Rich output

By default, the return values from REPL statements are displayed in the text form. To use richer representations, e.g. to display graphics or html, it is possible to send MIME-encoded result to the client using the MIME helper function:

fun MIME(vararg mimeToData: Pair<String, String>): MimeTypedResult 

E.g.:

MIME("text/html" to "<p>Some <em>HTML</em></p>", "text/plain" to "No HTML for text clients")

HTML outputs can also be rendered with HTML helper function:

fun HTML(text: String): MimeTypedResult

Rendering

Rendering is a procedure of transforming of the value to the form that is appropriate for displaying in Jupyter client. Kernel supports several features that allow you to render values.

Renderers

Renderers can transform a value into another value. Library can define one or several renderers. Rendering with renderers is controlled via RenderersProcessor. You can access it via notebook. Renderers are applied until at least one renderer can be applied.

DisplayResult and Renderable

If object implements DisplayResult or Renderable, it will be rendered to output JsonObject via its own corresponding method.

Text rendering

Text renderers render objects to strings. Library can define one or several text renderers. Rendering with text renderers is controlled via TextRenderersProcessor. You can access it via notebook. Text renderers are applied until at least one renderer returns non-null string for a passed argument. This kind of renderers can be easily composed with each other. I.e. text renderer for iterables can render its elements with text renderers processor recursively.

Throwables rendering

Throwable renderers do the same thing as renderers do, but only for results of the cells that were not successfully executed, and some exception was generated.

Common rendering semantics

Successfully evaluated value is firstly transformed with RenderersProcessor. Resulting value is checked. If it's Renderable or DisplayResult, it is transformed into output JSON using toJson() method. If it's Unit, the cell won't have result at all. Otherwise, value is passed to TextRenderersProcessor. It tries to render the value to string using defined text renderers having in mind their priority. If all the renderers returned null, value is transformed to string using toString(). Resulting string is wrapped to text/plain MIME JSON.

If the cell execution finished unsuccessfully and exception was generated, then the first applicable throwable renderer will be chosen for this exception, and exception will be passed to this renderer's render() method. Returned value will be displayed. If no applicable throwable renderer was found, exception message and stacktrace will be printed to stderr.

Autocompletion

Press TAB to get the list of suggested items for completion. In Jupyter Notebook, you don't need to press TAB, completion is requested automatically. Completion works for all globally defined symbols and for local symbols which were loaded into notebook during cells evaluation.

Error analysis

If you use Jupyter Notebook as Jupyter client, you will also see that compilation errors and warnings are underlined in red and in yellow correspondingly. This is achieved by kernel-level extension of Jupyter notebook which sends error-analysis requests to kernel and renders their results. If you hover the cursor over underlined text, you will get an error message which can help you to fix the error.

Debugging

  1. Run ./gradlew installDebug. Debugger port is selected automatically. Default port is 1044, consequent ports will be used if it's in use. If you want an exact port, specify -PdebugPort=<port> Gradle option.
  2. Run jupyter notebook, open the desired notebook.
  3. Attach a remote debugger to JVM with corresponding port (debug port number will be printed in terminal on kernel startup).

Adding new libraries

Read this article if you want to support new JVM library in the kernel.

Documentation

There is a site with rendered KDoc comments from the codebase. If you are a library author you may be interested in api module (see adding new libraries). There is also a lib module which contains entities available from the Notebook cells and shared-compiler module which may be used for Jupyter REPL integration into standalone application or IDEA plugin.

Contributing

We welcome contributions to further enhance our project! If you come across any issues or have feature requests, please don't hesitate to file an issue.

For issues specifically related to the Kotlin Notebook plugin, kindly utilize another tracker.

Pull requests are highly appreciated! When submitting a pull request, please ensure that it corresponds to an existing issue. If you are planning a substantial change, we recommend discussing it with a project maintainer. You can reach out to me through email, Kotlin Slack, or Telegram. We look forward to your contributions!

kotlin-jupyter's People

Contributors

alshan avatar altavir avatar andreyg avatar apatrida avatar ark-1 avatar biranyucel avatar breandan avatar carreau avatar devcrocod avatar drschlaubi avatar ermolenkodev avatar evgeniygubarev avatar fbrunacci avatar fmagin avatar haifengl avatar holgerbrandl avatar ileasile avatar jbaron avatar jolanrensen avatar koperagen avatar ligee avatar lundez avatar manics avatar mpcjanssen avatar nikitinas avatar nikolay-egorov avatar nilsga avatar rnett avatar strangepleasures avatar zhelenskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotlin-jupyter's Issues

Package level functions can not be used

Example (from a a file src/main/kotlin/de/mpicbg/scicomp/kip/Util.kt and pulled into the jupyter repl using @DependsOnMaven):

fun hello() = println("hello from in here")

It does not seem possible to do wildcard import for it, not to call it directly:
image

The kernel crashes after running println twice

When I am running this

println("hello")

then going back to the row, tun this again, the kernel just crashes with the following error:

[main] ERROR ikotlin - exception running kernel with args: "/Users/gyorgyorosz/Library/Jupyter/runtime/kernel-5687fb6d-e87f-46f6-968b-237817dbfa13.json, -cp=/Users/gyorgyorosz/.ipython/kernels/kotlin/lib/kotlin-stdlib-1.1.0-dev-1920.jar:/Users/gyorgyorosz/.ipython/kernels/kotlin/lib/jupyter-lib-0.2.0.jar:/Users/gyorgyorosz/.ipython/kernels/kotlin/lib/kotlin-runtime-1.1.0-dev-1920.jar"
java.lang.IllegalStateException: Rewrite at key Line1
        at org.jetbrains.kotlin.cli.jvm.repl.ReplClassLoader.addClass(ReplClassLoader.java:51)
        at org.jetbrains.kotlin.jupyter.ReplForJupyter.eval(repl.kt:169)
        at org.jetbrains.kotlin.jupyter.IkotlinKt.shellMessagesHandler(ikotlin.kt:141)
        at org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:87)
        at org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:43)
Exception in thread "Thread-0" org.zeromq.ZMQException: Errno 156384765 : Context was terminated
        at org.zeromq.ZMQ$Socket.mayRaise(ZMQ.java:1456)
        at org.zeromq.ZMQ$Socket.recv(ZMQ.java:1365)
        at org.jetbrains.kotlin.jupyter.IkotlinKt$kernelServer$$inlined$use$lambda$1.invoke(ikotlin.kt:182)
        at org.jetbrains.kotlin.jupyter.IkotlinKt$kernelServer$$inlined$use$lambda$1.invoke(ikotlin.kt)
        at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:18)

Code inlining and jvm-target

I just encountered the following error:

Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8

Obviously, the kernel uses JVM 8 as a target and if the library targets 11, there will be problems with inlining. There are several ways to address the problem. There could be a switch in the configuration, or it could use current JDK target as default or both.

Unable to import krangl

Installed minicondo3, installed jupyter-notebook using conda install -c conda-forge jupyterlab, installed this kernel using conda install -c jetbrains kotlin-jupyter-kernel.

Trying to %use lets-plot and krangl:
image
This just throws error.

Trying to %use lets-plot, but import krangl with @file:DependsOn:
image
This throws error when actually referencing krangl.

I've also tried to install krangl using conda:
conda install krangl

but it threw:

PackagesNotFoundError: The following packages are not available from current channels:

  - krangl

Current channels:

  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch

Searching for krangl on anaconda.com didn't turn up any results.

Either it's just broken, or there is some specific strange way to install/import/use krangl which I'm not aware of and which isn't described anywhere in krangl or korlin-jupyter docs.

Syntax error but no clue

I'm using kotlin-jupyter-kernel 0.7.40.145 and a cell with the following code (and syntactic error) produces no output:

data class Person(val name: String, val age: Int)
val example = Person("Testperson"; age = 4)
println(example)

As evident in this screen shot:
person

Whenever I make a different kind of error, such as leaving out a parameter (as in Person("foo")), I get a helpful message in red below the cell. There should be a similar error message when mistaking ; for ,.

Documentation popup

Add a hover or Shift+Tab documentation popup on functions, classes and properties like it is done in Python.

Failed to load maven-central dependency with @DependsOn

@file:DependsOn("org.apache.commons:commons-math3:3.6.1")

Failed to resolve org.apache.commons:commons-math3:3.6.1:
File 'org.apache.commons:commons-math3:3.6.1' not found
unresolved dependency: org.apache.commons#commons-math3;3.6.1: configuration not found in org.apache.commons#commons-math3;3.6.1: 'master'. It was required from org.apache.commons#commons-math3-caller;working default

Not sure it is a general problem, or just that precise installation. Leaving it here just in case.

Pass args on JVM startup

Hi !

I'm hitting the 8G memory limit and wanted to pass the -Xmx startup flag but couldn't find how to it. I believe it's useful to be able to customize how the JVM starts up.
I'm not familiar with Jupyter's internals, but is this where the args should be passed ?

subprocess.call(['java', '-jar'] + debug_list +

Or should we pass them somewhere else ?

Cheers !

PS : If you have any tips on how to change the memory limit, I'm still interested :)

Add optional version tag to use directive

Currently, use uses current version of the module descriptor from the distribution or the web. As it is, it solve significant portion of the problem with notebook reproducability, but sooner or later we will move to newer versions of artifacts mentioned in use and old notebooks could stop working.

I propose to add a version/variant qualifier to the module name like [email protected] (any other symbol could be used instead of @. Different version of the module descriptor could be stored in the same file and if no qualifier is provided, resolver should default empty one. Also it is possible to introduce nested qualifiers in case we will need something more complicated: kmath@[email protected] (default dev version is provided for kmath@dev). Nested descriptors are quite easy to do with json.

Installation issue on MacOs Mojave

Hi,
After cloning and running the install i get an error, informing about java version, i have java and it works properly, not sure whats going on here

โžœ kotlin-jupyter git:(master) ./gradlew install
Downloading https://services.gradle.org/distributions/gradle-2.12-all.zip
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /Users/raveenbeemsingh/.gradle/wrapper/dists/gradle-2.12-all/8ywkdai6puj5z81fume4e7njw/gradle-2.12-all.zip to /Users/raveenbeemsingh/.gradle/wrapper/dists/gradle-2.12-all/8ywkdai6puj5z81fume4e7njw
Set executable permissions for: /Users/raveenbeemsingh/.gradle/wrapper/dists/gradle-2.12-all/8ywkdai6puj5z81fume4e7njw/gradle-2.12/bin/gradle

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine java version from '10.0.2'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


โžœ kotlin-jupyter git:(master) java --version
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

State of the project?

Hi ligee, thanx for this project! To me there is nothing like a notebook for learning and documenting my forays in a new programming language!

I was wondering, what is the status of this project? I just got the kernel running on Jupyter on Solus Linux without any problems but I noticed autocompletion is not working for example. Do you consider this project well maintained? Is it safe for me to try out this kernel without running into bugs that I might consider Kotlins' but are in fact this notebook kernels' bugs?

Error when importing a dependency

I need to import in the notebook some libraries I've published. Now, maadb-project-sql-analytics-core-jvm depends on maadb-project-sql-jvm which depends on maadb-project-core-jvm.

They all have been published using the same plugin and they are visible in my repository.
But, in the notebook, the only artifact found in my repository is maadb-project-sql-analytics-core-jvm, the others throws not found error.

Here's the Maven repository, as you can see they are al present.

Where am I wrong?

@file:Repository("https://dl.bintray.com/lamba92/com.github.lamba92")
@file:Repository("https://dl.bintray.com/kotlin/kotlin-eap")
@file:DependsOn("com.github.lamba92:maadb-project-core-jvm:1.0.0")
@file:DependsOn("com.github.lamba92:maadb-project-sql-jvm:1.0.0")
@file:DependsOn("com.github.lamba92:maadb-project-sql-analytics-core-jvm:1.0.0")

Kernel references leaked into script classpath

%use klaxon(2.1.8)
class Person (val name: String, var age: Int = 23)
val klaxon = Klaxon()
klaxon.parse<Person>("""
    {
      "name": "John Smith"
    }
    """)

Fails with runtime error, because script is compiled with kernel's klaxon 5.2, but is evaluated with imported klaxon 2.1.8.

Logging options

Logging in Kernel is not configurable now. It would be great to do something (or all) of the folllowing:

  1. Let the user specify default debug level via configuration file
  2. Let the user change log level via magic
  3. Swith off the logging when user works in console mode
  4. Let the user specify the file to redirect logs

The kernel dies when using variables with different registers.

The kernel dies when the following code is executed:

fun stack(vararg tup: Int): Int = tup.sum()
val X = 1
val x = stack(1, X)

In this case, the code is executed if you use other names for X or x.

The error itself is as follows:

java.lang.IllegalStateException: Aggregated history sizes mismatch: 3 != 2
	at org.jetbrains.kotlin.cli.common.repl.AggregatedReplStateHistory.assertSameSize(AggregatedReplState.kt:75)
	at org.jetbrains.kotlin.cli.common.repl.AggregatedReplStateHistory.get(AggregatedReplState.kt:41)
	at org.jetbrains.kotlin.cli.common.repl.AggregatedReplStateHistory.get(AggregatedReplState.kt:23)
	at kotlin.collections.AbstractList$IteratorImpl.next(AbstractList.kt:78)
	at org.jetbrains.kotlin.jupyter.repl.reflect.ContextUpdater.getLines(ContextUpdater.kt:131)
	at org.jetbrains.kotlin.jupyter.repl.reflect.ContextUpdater.update(ContextUpdater.kt:30)
	at org.jetbrains.kotlin.jupyter.ReplForJupyter.doEval(repl.kt:269)
	at org.jetbrains.kotlin.jupyter.ReplForJupyter.eval(repl.kt:201)
	at org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:87)
	at org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt)
	at org.jetbrains.kotlin.jupyter.ProtocolKt.evalWithIO(protocol.kt:279)
	at org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:86)
	at org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:104)
	at org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:59)
Exception in thread "Thread-3" org.zeromq.ZMQException: Errno 156384765 : Context was terminated
	at org.zeromq.ZMQ$Socket.mayRaise(ZMQ.java:1456)
	at org.zeromq.ZMQ$Socket.recv(ZMQ.java:1365)
	at org.jetbrains.kotlin.jupyter.IkotlinKt$kernelServer$$inlined$use$lambda$1.invoke(ikotlin.kt:123)
	at org.jetbrains.kotlin.jupyter.IkotlinKt$kernelServer$$inlined$use$lambda$1.invoke(ikotlin.kt)
	at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

I got this error using latest kernel versions - 0.7.40.145 and 0.7.41.190. There was no such error on the old version. As far as I remember it was version 0.7.12.

Detect transitive dependencies for supported libraries

I wonder if there is a way to import transitive dependencies by default for supported libraries imported with the %use keyword in the same way as the @file:DependsOn(<coordinates>)/@file:Repository(<absolute-path>) syntax does. Why is it necessary to re-declare all the transitive dependencies for supported libraries in the json library descriptor like so?

Exclude kernel magics from error analysis

Now, you get errors in cells with magics. We should properly exclude magics from code snippets for error-analysis requests and then get back right location for found errors.
image

resultOf is missing

Commit df1e7e3 deleted resultOf.

The sample is now broken.

error: unresolved reference: resultOf resultOf(convolutionExample().toSvg(1000.0, 500.0))

Complete file names only inside some specific function calls

Now completion completes file names in all string literals. It is not a good idea.
Do the following:

  1. Add new library parameter "completeFilenamesFunctions" and join all these lists over all used libraries.
  2. Pass this list as a completion option to REPL
  3. Implement logic in REPL to do filename completion only in string literals inside function calls from the list.

Kernel spec produced for Windows is invalid

System requirements

  • Windows (Mine is Windows 10, this problem must be there for any Windows version)

Steps to reproduce

  • Clone the repository and run gradlew install
  • After that from suitable command prompt such as the 'Anaconda prompt' run jupyter kernelspec list

Error

(base) D:\jupyter-kernels\kotlin-jupyter>jupyter kernelspec list
[ListKernelSpecs] WARNING | Error loading kernelspec 'kotlin'
Traceback (most recent call last):
  File "D:\Anaconda3\lib\site-packages\jupyter_client\kernelspec.py", line 258, in get_all_specs
    spec = self._get_kernel_spec_by_name(kname, resource_dir)
  File "D:\Anaconda3\lib\site-packages\jupyter_client\kernelspec.py", line 201, in _get_kernel_spec_by_name
    return self.kernel_spec_class.from_resource_dir(resource_dir)
  File "D:\Anaconda3\lib\site-packages\jupyter_client\kernelspec.py", line 47, in from_resource_dir
    kernel_dict = json.load(f)
  File "D:\Anaconda3\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "D:\Anaconda3\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "D:\Anaconda3\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 2 column 32 (char 33)
Available kernels:
  kotlin        C:\Users\jjkav\.ipython\kernels\kotlin
  javascript    C:\Users\jjkav\AppData\Roaming\jupyter\kernels\javascript
  python3       D:\Anaconda3\share\jupyter\kernels\python3

As can be seen there is an issue with the kernel.json installed by kotlin-jupyter:

json.decoder.JSONDecodeError: Invalid \escape: line 2 column 32 (char 33)

Unable to use kernel because of error in parserLibraryDescriptors

I am using Jupyter lab and notebook on mac.

Conda env created from file

name: kotlin
channels:
  - conda-forge
  - jetbrains
  - defaults
dependencies:
  - python=3.8
  - jupyterlab
  - kotlin-jupyter-kernel

jdk installed by jabba

jabba current
[email protected]

I am getting error while running kernel in jypyter notebook or jupyter lab.
logs.txt

Changing versions of jupyterlab (2.0, 1.2) does not solve the problem

protocol issue with 5.x protocol of Jupyter

After seeing this does not work with Jupyter labs newest version, because of:

Ah, the issue is that we are expecting an idle status after every iopub message per the 5.0 spec: "Changed in version 5.0: Busy and idle messages should be sent before/after handling every request, not just execution." The classic notebook is more lenient because it also supports older protocol versions.

http://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-status

Cannot use RELEASE version in @file:DependsOn

It seems the @file:DependsOn resolution doesn't support the RELEASE version. For example:

@file:DependsOn("org.junit.jupiter:junit-jupiter-api:RELEASE") fails with the error:

:: problems summary ::
:::: WARNINGS
module not found: org.junit.jupiter#junit-jupiter-api;RELEASE

==== jcenter.bintray.com: tried

https://jcenter.bintray.com/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.pom

-- artifact org.junit.jupiter#junit-jupiter-api;RELEASE!junit-jupiter-api.jar:

https://jcenter.bintray.com/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.jar

==== repo.maven.apache.org: tried

https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.pom

-- artifact org.junit.jupiter#junit-jupiter-api;RELEASE!junit-jupiter-api.jar:

https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.jar

==== jitpack.io: tried

https://jitpack.io/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.pom

-- artifact org.junit.jupiter#junit-jupiter-api;RELEASE!junit-jupiter-api.jar:

https://jitpack.io/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.jar

==== central: tried

https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.pom

-- artifact org.junit.jupiter#junit-jupiter-api;RELEASE!junit-jupiter-api.jar:

https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/RELEASE/junit-jupiter-api-RELEASE.jar

This issue arose when I was trying to use one of my own JARs installed in a local repository.

readLine causing java.lang.ArrayIndexOutOfBoundsException

When trying to use readLine in Jupyter Notebook it raises an exception

val name = readLine()

java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 6
org.jetbrains.kotlin.jupyter.JupyterConnection$StdinInputStream.read(connection.kt:91)
kotlin.io.LineReader.readLine(Console.kt:173)
kotlin.io.ConsoleKt.readLine(Console.kt:148)
Line_19_jupyter.(Line_19.jupyter.kts:5)
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:96)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:41)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)
kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:51)
org.jetbrains.kotlin.jupyter.ReplForJupyterImpl$doEval$resultWithDiagnostics$1.invokeSuspend(repl.kt:486)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
org.jetbrains.kotlin.jupyter.ReplForJupyterImpl.doEval(repl.kt:486)
org.jetbrains.kotlin.jupyter.ReplForJupyterImpl.eval(repl.kt:342)
org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:143)
org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt)
org.jetbrains.kotlin.jupyter.ProtocolKt.evalWithIO(protocol.kt:356)
org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:142)
org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:104)
org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:59)

Support for custom type handlers

E.g. in the sci-java kernel they have implemented type converters (such as https://github.com/scijava/scijava-jupyter-kernel/blob/master/src/main/java/ij/notebook/converter/ImagePlusToPNGNotebookConverter.java).

I wonder if it would be possible to register those from within juptyer, to enable application domain handlers as needed. Something like
registerTypeHandler(java.awt.image.BufferedImage.class, MyHandler())

later just do
BufferedImage(20, 10, BufferedImage.TYPE_INT_ARGB)
to render the object in the notebook.

So when starting a notebook users could pull in handlers as needed to visualizes domain specific class-instances (like images, tables, whatever).

Cannot start jupyther notebook

After download and install kernel with ./gradlew install , start new notebook got error

Starting server: KernelConfig(ports=[64057, 64053, 64056, 64055, 64054], transport=tcp, signatureScheme=hmac-sha256, signatureKey=9f641ffe-cea077832b193c4d7a1d72e4, pollingIntervalMillis=100, classpath=[/Users/eggcaker/.ipython/kernels/kotlin/kotlin-stdlib-1.2.21.jar, /Users/eggcaker/.ipython/kernels/kotlin/jupyter-lib-0.6.0.jar, /Users/eggcaker/.ipython/kernels/kotlin/annotations-13.0.jar])
[main] INFO ikotlin - start listening
Exception in thread "main" java.lang.NoClassDefFoundError: org/jetbrains/kotlin/com/intellij/openapi/diagnostic/Logger
	at uy.kohesive.keplin.kotlin.script.resolver.AnnotationTriggeredScriptDefinition.<clinit>(AnnotationTriggeredScriptDefinition.kt:70)
	at org.jetbrains.kotlin.jupyter.ReplForJupyter.<init>(repl.kt:22)
	at org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:62)
	at org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:41)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.com.intellij.openapi.diagnostic.Logger
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 4 more

Load static resources via module descriptions

Some visualization features (like d3) require static or CDN resources like js, CSS, or images to be loaded into the current page. I think that the module descriptor JSON is the best place to describe such resources. I propose to add a resource (or static) block with a list of filenames or CDN paths to load when '%use' directive is invoked.

Exception in starting Kernel

OS:
Linux Mint 19
JVM "1.8.0_201"

Error when starting jupyter cosole --kernel=kotlin

$ jupyter console --kernel=kotlin
[main] INFO ikotlin - Kernel args: -classpath=/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/jupyter-lib-0.7.40.145.jar:/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-1.3.70-dev-2104.jar:/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-common-1.3.70-dev-2104.jar:/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/annotations-13.0.jar, /home/blackmo/.local/share/jupyter/runtime/kernel-14107.json, -home=/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel
[main] INFO ikotlin - Starting server with config: KernelConfig(ports=[60895, 53195, 48119, 34655, 33753], transport=tcp, signatureScheme=hmac-sha256, signatureKey=d3912a08-c308643b6708e79d580871d7, pollingIntervalMillis=100, scriptClasspath=[/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/jupyter-lib-0.7.40.145.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-1.3.70-dev-2104.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-common-1.3.70-dev-2104.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/annotations-13.0.jar], resolverConfig=ResolverConfig(repositories=[kotlin.script.experimental.dependencies.RepositoryCoordinates@2aae9190, kotlin.script.experimental.dependencies.RepositoryCoordinates@2f333739, kotlin.script.experimental.dependencies.RepositoryCoordinates@77468bd9], libraries=DeferredCoroutine{Active}@71bc1ae4))
[DefaultDispatcher-worker-1] INFO ikotlin - Reading commit info for which library descriptors were cached: '/home/blackmo/.jupyter_kotlin/cache/libsCommit'
[DefaultDispatcher-worker-1] INFO ikotlin - Local libraries are cached for commit 'aebe1332e8a838318ffba9a7a06a2c565219f1d7' at '2020-01-05T19:18:11Z'
[DefaultDispatcher-worker-1] INFO ikotlin - Checking for new commits to library descriptors at https://api.github.com/repos/kotlin/kotlin-jupyter/commits?path=libraries&sha=master&since=2020-01-05T19:18:11Z
[main] DEBUG ikotlin - [hb] listen: tcp://*:60895
[main] DEBUG ikotlin - [shell] listen: tcp://*:53195
[main] DEBUG ikotlin - [control] listen: tcp://*:48119
[main] DEBUG ikotlin - [stdin] listen: tcp://*:34655
[main] DEBUG ikotlin - [iopub] listen: tcp://*:33753
[main] INFO ikotlin - Current classpath: /usr/lib/jvm/java-8-oracle/jre/lib/ext/sunec.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/sunpkcs11.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/dnsns.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/localedata.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/jaccess.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/zipfs.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/cldrdata.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/sunjce_provider.jar, /usr/lib/jvm/java-8-oracle/jre/lib/ext/nashorn.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-jupyter-kernel-0.7.40.145.jar
[main] INFO ikotlin - Begin listening for events
[main] INFO ikotlin - Classpath for compiler options: none
[DefaultDispatcher-worker-1] INFO ikotlin - No new commits to library descriptors were detected
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'spark' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/spark.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'numpy' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/numpy.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'lets-plot' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/lets-plot.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'mysql' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/mysql.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'fuel' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/fuel.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'krangl' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/krangl.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'kravis' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/kravis.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'gral' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/gral.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'kmath' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/kmath.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'klaxon' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/klaxon.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'exposed' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/exposed.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'kotlin-statistics' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/kotlin-statistics.json'
[DefaultDispatcher-worker-1] INFO ikotlin - Loading 'koma' descriptor from '/home/blackmo/.jupyter_kotlin/cache/libraries/koma.json'
[main] INFO ikotlin - Starting kotlin REPL engine. Compiler version: 1.3.70-dev-2104
[main] INFO ikotlin - Classpath used in script: [/home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/jupyter-lib-0.7.40.145.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-1.3.70-dev-2104.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-common-1.3.70-dev-2104.jar, /home/blackmo/.local/lib/python3.6/site-packages/run_kotlin_kernel/jars/annotations-13.0.jar]
[main] DEBUG ikotlin - [shell] >rcv: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"version":"5.3","date":"2020-03-31T00:19:51.584990Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_0"} parentHeader = {} metadata = {} content = {}
[main] DEBUG ikotlin - [iopub] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"status","msg_id":"1123adb0-9692-4920-aa7b-efa2b0904b55","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:51.584990Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_0"} metadata = {} content = {"execution_state":"busy"}
[main] DEBUG ikotlin - [shell] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"kernel_info_reply","msg_id":"c966a767-f0f9-4e8f-a1d6-48abc519ac88","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:51.584990Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_0"} metadata = {} content = {"protocol_version":"5.3","language_info":{"name":"kotlin","codemirror_mode":"text/x-kotlin","file_extension":"kt"},"implementation":"Kotlin","banner":"Kotlin language, version 1.3.70-dev-2104","language":"Kotlin","language_version":"1.3.70-dev-2104","implementation_version":"1.3.70-dev-2104","status":"ok"}
[main] DEBUG ikotlin - [iopub] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"status","msg_id":"3eb15d39-ee9f-4b5e-b6d1-309aed0b074a","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:51.584990Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_0"} metadata = {} content = {"execution_state":"idle"}
[main] DEBUG ikotlin - [shell] >rcv: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"version":"5.3","date":"2020-03-31T00:19:51.591735Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_1"} parentHeader = {} metadata = {} content = {}
[main] DEBUG ikotlin - [iopub] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"status","msg_id":"20287cf5-cf12-4708-a1d7-1ee80e1c97b2","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:51.591735Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_1"} metadata = {} content = {"execution_state":"busy"}
[main] DEBUG ikotlin - [shell] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"kernel_info_reply","msg_id":"6abcb258-a093-4c11-b174-c233fa7e2d06","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:51.591735Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_1"} metadata = {} content = {"protocol_version":"5.3","language_info":{"name":"kotlin","codemirror_mode":"text/x-kotlin","file_extension":"kt"},"implementation":"Kotlin","banner":"Kotlin language, version 1.3.70-dev-2104","language":"Kotlin","language_version":"1.3.70-dev-2104","implementation_version":"1.3.70-dev-2104","status":"ok"}
[main] DEBUG ikotlin - [iopub] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"status","msg_id":"e9b4fa91-5eb1-4df8-8ac4-9999cad15be7","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:51.591735Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"kernel_info_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_1"} metadata = {} content = {"execution_state":"idle"}
[main] DEBUG ikotlin - [shell] >rcv: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"version":"5.3","date":"2020-03-31T00:19:54.596428Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"history_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_2"} parentHeader = {} metadata = {} content = {"raw":true,"output":false,"hist_access_type":"tail","n":1000}
[main] DEBUG ikotlin - [iopub] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"status","msg_id":"e5f2f54a-2c67-4a62-b0f1-195d11393c48","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:54.596428Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"history_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_2"} metadata = {} content = {"execution_state":"busy"}
[main] DEBUG ikotlin - [shell] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"history_reply","msg_id":"ba6a1f52-a3d5-4b32-b456-8f0bc1b41a81","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:54.596428Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"history_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_2"} metadata = {} content = {"history":[]}
[main] DEBUG ikotlin - [iopub] snd>: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"date":"2020-03-31T08:19+0800","msg_type":"status","msg_id":"10add227-dc18-468e-88c8-5104bd652e1c","version":"5.3","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo"} parentHeader = {"version":"5.3","date":"2020-03-31T00:19:54.596428Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"history_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_2"} metadata = {} content = {"execution_state":"idle"}
Jupyter console 6.1.0

Kotlin language, version 1.3.70-dev-2104
In [1]: val hello = "hello"[main] DEBUG ikotlin - [shell] >rcv: msg[f0255f1a-e6f2ef75974643e9ac98f284] header = {"version":"5.3","date":"2020-03-31T00:20:03.574618Z","session":"f0255f1a-e6f2ef75974643e9ac98f284","username":"blackmo","msg_type":"is_complete_request","msg_id":"f0255f1a-e6f2ef75974643e9ac98f284_3"} parentHeader = {} metadata = {} content = {"code":"val hello = \"hello\""}
Exception in thread "main" java.lang.NoSuchMethodError: org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.getProject()Lorg/jetbrains/kotlin/mainKts/relocatedDeps/com/intellij/openapi/project/Project;
	at kotlin.script.experimental.jvmhost.repl.JvmReplCompiler.check(legacyReplCompilation.kt:39)
	at org.jetbrains.kotlin.jupyter.ReplForJupyter.checkComplete(repl.kt:164)
	at org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:152)
	at org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:104)
	at org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:59)
Exception in thread "Thread-3" org.zeromq.ZMQException: Errno 156384765 : Context was terminated
	at org.zeromq.ZMQ$Socket.mayRaise(ZMQ.java:1456)
	at org.zeromq.ZMQ$Socket.recv(ZMQ.java:1365)
	at org.jetbrains.kotlin.jupyter.IkotlinKt$kernelServer$$inlined$use$lambda$1.invoke(ikotlin.kt:123)
	at org.jetbrains.kotlin.jupyter.IkotlinKt$kernelServer$$inlined$use$lambda$1.invoke(ikotlin.kt)
	at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
In [1]: val hello = "hello"                                                                                                                                                                                                                   
/home/blackmo/.local/lib/python3.6/site-packages/jupyter_console/ptshell.py:656: UserWarning: The kernel did not respond to an is_complete_request. Setting `use_kernel_is_complete` to False.
  warn('The kernel did not respond to an is_complete_request.

Internal error for if expression

When executing the following code:

fun test() {
    if() {    }
}

error:

Back-end (JVM) Internal error: Failed to generate expression: KtIfExpression
File being compiled: (2,5) in Line_1.jupyter.kts
The root cause java.lang.IllegalArgumentException was thrown at: org.jetbrains.kotlin.codegen.ExpressionCodegen.$$$reportNull$$$0(ExpressionCodegen.java)

I expect compilation error in readable form.

Config editor / network based configuration

Compile-time configuration repository seems to be rather limited. We probably will want to add configuration locally (Jupyter lab has special configuration pages for extensions) and in future, there should be central repository for packages ready for notebook so people could update them without installing new version.

Low priority.

Add mavenLocal resolver

Add possibility or documentation about adding mavenLocal as a repository. It is required to test development builds without deploying them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.