Code Monkey home page Code Monkey logo

kotlin-jupyter's Introduction

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

Kotlin Kernel for Jupyter notebooks

The Kotlin Kernel for Jupyter notebooks is a powerful tool that allows you to write and run Kotlin 1.9.23 code within the Jupyter Notebook environment. This Kernel essentially acts as a bridge between Jupyter Notebook and the Kotlin compiler.

Alt text for the GIF

The Kotlin Kernel for notebooks supports running code cells to immediately see outputs, basic code completion, error analysis, and other interactive coding features, enhancing the interactive experience provided by the Kotlin REPL.

With the Kotlin Kernel for notebooks, you gain access to a range of features like:

  • Accessing APIs within cells and using APIs for handling outputs.
  • Retrieving information from previously executed code snippets, allowing quick project exploration.
  • Importing various libraries with a single line of code or even integrating new libraries into your project.

You can leverage Kotlin Kernel's benefits in IntelliJ IDEA through the Kotlin Notebook plugin, in your Jupyter Notebook, or in Datalore.

Contents

Click here to expand the table of contents.

Get started

Start using the Kotlin Kernel for Jupyter notebooks:

Versions and support

Note: The Kotlin Kernel for Jupyter notebooks is in Beta.

Kotlin version support

The latest version of the Kotlin Kernel for notebooks uses the Kotlin compiler of version 1.9.23.

Jupyter environments

We tested the Kotlin Kernel for notebooks with the following clients:

Client Minimal supported version
JupyterLab 1.2.6
Jupyter Notebook 6.0.3
Jupyter Console 6.1.0

Operating systems

We tested the Kotlin Kernel for notebooks with all the mentioned clients on the following operating systems:

  • Windows
  • Ubuntu Linux
  • macOS

Install the Kotlin Kernel in various clients

You can create, open, and work with Kotlin notebooks on various clients:

Our Kotlin Kernel is fully integrated into Kotlin Notebook, which you can use directly within IntelliJ IDEA by installing the Kotlin Notebook plugin.

In Datalore, Kotlin is supported natively, with the Kotlin Kernel already bundled for an out-of-the-box experience.

For other Jupyter clients, you'll need to install the Kotlin Kernel separately using conda, pip, or sources.

Install the Kotlin Notebook plugin

If you use IntelliJ IDEA, you need to install the Kotlin Notebook plugin that contains the Kotlin Kernel for Jupyter notebooks.

Install the Kotlin Notebook plugin by downloading its latest version from the JetBrains Marketplace.

Alternatively, access the Kotlin Notebook plugin from Settings | Plugins | Marketplace within IntelliJ IDEA.

Note: For a quick introduction to Kotlin Notebook, see this blog post.

Install with Conda

If you use Jupyter Notebook and Conda, run this Conda command to install the stable version package of the Kotlin Kernel for Jupyter notebooks:

conda install -c jetbrains kotlin-jupyter-kernel

Alternatively, run this Conda command to install the package from the developers channel:

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

To uninstall the Kotlin Kernel for Jupyter notebooks, run this Conda command:

conda remove kotlin-jupyter-kernel

Install with Pip

If you use Jupyter Notebook and Pip, run this Pip command to install the stable version package of the Kotlin Kernel for Jupyter notebooks:

pip install kotlin-jupyter-kernel

Alternatively, run this Pip command to install the package from the developers channel:

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

To uninstall the Kotlin Kernel for Jupyter notebooks, run this Pip command:

pip uninstall kotlin-jupyter-kernel

Install from sources

If you use either IntelliJ IDEA or Jupyter Notebook, you can install the Kotlin Kernel for Jupyter notebooks from sources.

Clone this repository and run the following Gradle command in the root folder:

./gradlew install

The default installation path is ~/.ipython/kernels/kotlin/. You can also install the package in another location using the -PinstallPath= option. However, Jupyter only looks for the kernel specification files in predefined places. For more details, see Jupyter docs.

To uninstall the Kotlin Kernel for Jupyter notebooks from sources, run this Gradle command:

./gradlew uninstall

Troubleshoot your installation

When installing the Kotlin Kernel for Jupyter notebooks, issues can occur while detecting the kernel specification file. These issues occur due to different Python environments and installation modes.

If you are using Pip or Conda to install the package, run this post-install fixup script:

python -m kotlin_kernel fix-kernelspec-location

This script replaces the kernel specification files with the detected user path.

Note: Don't forget to re-run this script when updating the Kotlin Kernel for notebooks.

Update the Kotlin Kernel for notebooks

See how to update the Kotlin Kernel for Jupyter notebooks using the Kotlin Notebook plugin, Conda, Pip, and Datalore.

Update the Kotlin Notebook plugin

If you use the Kotlin Notebook plugin, update it to the latest version in Settings | Plugins | Installed within IntelliJ IDEA.

Alternatively, you can download and install the latest plugin version from the JetBrains Marketplace.

Update with Conda

If you use Jupyter Notebook and Conda, run this Conda command to update the stable version package:

conda update -c jetbrains kotlin-jupyter-kernel

Alternatively, run this Conda command to update the package from the developers channel:

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

To change to a specific Kotlin Kernel version, add the ={VERSION} parameter to the kotlin-jupyter-kernel command. In this command, replace the {VERSION} parameter with the desired PyPi version of the Kotlin Jupyter Kernel (for example, 0.12.0-167).

You can specify the version in both commands the one from the stable package and the one from the developers channel package. For example, for the stable package:

conda install -c jetbrains kotlin-jupyter-kernel={0.12.0-167}

Update with Pip

If you use Jupyter Notebook and Pip, run this Pip command to update the stable version package:

pip install kotlin-jupyter-kernel --upgrade

Alternatively, run this Conda command to update the package from the developers channel:

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

To change to a specific Kotlin Kernel version, add the ={VERSION} parameter to the kotlin-jupyter-kernel command. In this command, replace the {VERSION} parameter with the desired PyPi version of the Kotlin Jupyter Kernel (for example, 0.12.0-167).

You can specify the version in both commands the one from the stable package and the one from the developers channel package. For example, for the stable package:

pip install kotlin-jupyter-kernel=={0.12.0-167} --ignore-installed

Update in Datalore

To update the Kotlin Kernel for notebooks in Datalore:

  1. Add an environment.yml file to the Notebook files containing the following snippet:

    datalore-env-format-version: "0.2"
    datalore-package-manager: "pip"
    datalore-base-env: "default"
    dependencies:
    - pip:
    - kotlin-jupyter-kernel=={VERSION}
  2. Replace the {VERSION} parameter for the latest PyPi version of the Kotlin Jupyter Kernel (for example, 0.12.0-167).

  3. Stop and restart the machine in Datalore.

Use the Kotlin Kernel for notebooks

See how to use the Kotlin Kernel for Jupyter notebooks with the Kotlin Notebook plugin, Jupyter clients, and Datalore.

Use the Kotlin Notebook

After installing the Kotlin Notebook plugin in IntelliJ IDEA, create a new notebook by selecting File | New | Kotlin Notebook, or right-click on a folder and select New | Kotlin Notebook.

Now you're good to go!

Use other Jupyter clients

You can use our Kotlin Kernel through JupyterLab, Jupyter Notebook, and Jupyter Console clients:

  1. Run one of the following commands in the console:
  • In JupyterLab:

    jupyter lab

  • In Jupyter Notebook:

    jupyter notebook

  • In Jupyter Console:

    jupyter console --kernel=kotlin

  1. Create a new notebook and set kotlin as kernel. This step applies to Jupyter Notebook or JupyterLab, and it's not required for Jupyter Console.

The default kernel uses the JDK that the environment points in the KOTLIN_JUPYTER_JAVA_HOME variable. In case the KOTLIN_JUPYTER_JAVA_HOME variable is not set, the kernel also uses the JDK from the JAVA_HOME variable.

The kernel uses the arguments that the environment points in the KOTLIN_JUPYTER_JAVA_OPTS variable. In case the KOTLIN_JUPYTER_JAVA_OPTS variable is not set, the kernel also uses the JVM arguments from the JAVA_OPTS variable.

Additionally, the kernel uses arguments that the environment points in the KOTLIN_JUPYTER_JAVA_OPTS_EXTRA variable. The arguments are parsed using the Python shlex.split() function.

Use Datalore

To create a Kotlin notebook in Datalore, click on New notebook and select Kotlin as kernel.

Create custom kernels

You can create a custom Kotlin Kernel for Jupyter Notebook. This allows you to tailor the kernel's environment to your specific requirements, such as using a particular JDK, setting JVM arguments, or defining environment variables.

To create a custom Kotlin Kernel for Jupyter Notebook, use the add-kernel command from the installed kotlin_kernel python package:

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

In the add-kernel script, the name argument is required if the jdk argument is not specified. Alternatively, if the jdk argument is specified, but the name argument is not, then the name is taken from the JDK $vendor $version argument, which is detected from the JDK.

Regardless of how the name is determined, the format of the kernel name is Kotlin ($name), and the format of the directory name is kotlin_$name. The directory name includes spaces in name, replaced by underscores. Ensure this format is compatible with your file system.

JVM arguments are joined with a space (' '), supporting multiple arguments within the same entry. The new arguments are added to existing ones, unless the --set-jvm-args flag is used. In this case, JVM arguments are set to the KOTLIN_JUPYTER_JAVA_OPTS variable. Both adding and setting arguments work alongside the KOTLIN_JUPYTER_JAVA_OPTS_EXTRA variable.

While Jupyter Kernel environment variable substitutions are supported in the env argument, no replacement occurs if the used environment variable doesn't exist.

The add-kernel script utilizes the argparse Python library, supporting the --help, @argfile (you don't need the @ symbol in PowerShell), and --opt=value arguments. The --jvm-arg=arg argument is required when passing JVM arguments that start with the - symbol.

Here's an example of an add-kernel script to create a custom Kotlin Kernel for Jupyter Notebook:

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

Features

Explore the sections below to learn about the features of the Kotlin Kernel for Jupyter notebooks. You can leverage these features using Kotlin Notebook in IntelliJ IDEA, Datalore, or other Jupyter Notebook clients.

The features of the Kotlin Kernel for Jupyter notebooks include:

Click here to expand the features.

REPL commands

Our Kotlin Kernel for notebooks comes with a set of REPL commands that let you explore your notebook environment. The following REPL commands are supported:

Command Description
:help Displays help information with details of the notebook version, line magics, and supported libraries.
:classpath Displays the current classpath of your notebook environment, showing a list of locations where the notebook searches for libraries and resources.
:vars Displays information about the declared variables and their values.

Dependencies resolving

You can easily add dynamic dependencies to your notebook from a remote Maven repository or local ones (local JARs). You can add dependencies through annotations or Gradle-like syntax.

Annotations

You can add dynamic dependencies to the notebook using the following annotations:

  • @file:DependsOn(<coordinates>): In this annotation, you need to specify the coordinates of the dependency. This annotation adds artifacts (like JAR files) to the notebook's classpath. It supports absolute and relative paths to class directories or JARs, as well as Ivy and Maven artifacts:

    @file:DependsOn(“io.ktor:ktor-client-core-jvm:$ktorVersion“)
  • @file:Repository(<absolute-path>): In this annotation, you need to specify the absolute path of the dependency. This annotation adds a directory or an Ivy or Maven repository to the notebook environment. To specify a Maven local repository, use:

    @file:Repository("*mavenLocal")

Gradle-like syntax

You can load any library from the Maven repository using Gradle-like syntax in any cell, specifying repositories, locations, and so on:

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")
	}
}

Note: You can use the same Gradle-like syntax to integrate new libraries.

Handling dependencies

When adding dependencies, consider the following:

  • Dependencies in remote repositories are resolved via Maven resolver.
  • Caches are stored in the ~/.m2/repository folder by default. However, due to network issues or several artifact resolutions running in parallel, caches may become corrupted.
  • If you have issues with artifacts resolution, remove caches, restart kernel, and try again.
  • While you can utilize Gradle-like syntax, Gradle is not running under the hood, and Gradle metadata is not resolved. Therefore, advanced dependency configurations are not available. For example, top-level Multiplatform dependencies are not supported. In these cases, you need to use the -jvm variant manually.

Default repositories

The following Maven repositories are included by default:

You can directly use libraries and dependencies from these repositories within your Kotlin code running in the Jupyter Notebook environment.

Line magics

Line magics are special commands, starting with the % character, that interact with the notebook on a per-line basis. Line magics allow you to import libraries, configure output settings, and perform more operations.

You can use the following line magics in your notebooks using the Kotlin Kernel:

Magic Description Usage example
%use Imports supported libraries and injects code from these libraries(artifact resolution, default imports, initialization code, and type renderers). %use klaxon(5.5), lets-plot
%trackClasspath Logs any changes of the current classpath. This command is useful for debugging artifact resolution failures. %trackClasspath [on/off]
%trackExecution Logs pieces of code to be executed. This command is useful for debugging libraries support. %trackExecution [all/generated/off]
%useLatestDescriptors Sets the latest versions of available library descriptors instead of bundled descriptors (used by default). Note that bundled descriptors are preferred because the current kernel version might not support the latest descriptors. For better notebook stability, use bundled descriptors. %useLatestDescriptors [on/off]
%output Configures the output capturing settings. %output --max-cell-size=1000 --no-stdout --max-time=100 --max-buffer=400
%logLevel Sets logging level. %logLevel [off/error/warn/info/debug]

Note: For more information, see Line magics.

Supported libraries

Kotlin Kernel for Jupyter notebooks comes with a set of integrated libraries, which you can import into your notebook by running the %use line magic before the library's name within a cell.

When you import a library using the %use line magic, 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. For example, charts and data frames

This behavior is defined by the JSON library descriptor, which provides a set of properties with default values that can be overridden when the library is imported.

To check the descriptors of all supported libraries, see the libraries repository.

The major use case for library properties is to specify a particular library version. If the descriptor has only one property, the library version can be defined without naming:

%use dataframe(0.10)

If the descriptor has more than one property, you need to use the property name:

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

You can include several libraries in a single %use statement, separated by commas (,):

%use kandy, dataframe, mysql(8.0.15)

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

// Uses a specific version from the default repository
%use [email protected]

// Uses a specific commit of the library
%use lets-plot@ref[24a040fe22335648885b106e2f4ddd63b4d49469]

// Uses a specific version of the library from a custom repository along with library arguments
%use dataframe@dev(0.10)

Note: Using a fixed version of a library is preferred over using the %useLatestDescriptors line magic.

Additionally, you can try resolving the library descriptor from a local file or a remote URL:

// Loads the library from a file
%use mylib@file[/home/user/lib.json]

// Loads the library from a file, and the Kernel detects it's a file
%use @/home/user/libs/lib.json

// Specifies a directory and a file name without extension (the extension file should be JSON) 
%use lib@/home/user/libs

// Loads the library descriptor from a remote URL
%use herlib@url[https://site.com/lib.json]

// Loads the library descriptor from a remote URL. The `url[]` part can be omitted if the URL responds with 200(OK)
%use @https://site.com/lib.json

// Loads the library dependencies from a specified JSON file. The library name and URL resolution can be omitted
%use @file[lib.json]

List of supported libraries

Here you can find all the supported libraries you can use in you Kotlin notebooks through the %use line magic.

Click to see the 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
  • intellij-sdk - IntelliJ SDK that could be used in embedded mode of Kotlin Notebook
  • 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
  • kraphviz - Graphviz wrapper for JVM
  • kravis - Kotlin grammar for data visualization
  • ksl - KSL - Kotlin Simulation Library for Monte Carlo and Discrete-Event Simulation
  • 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, our Kotlin Kernel for Jupyter notebooks displays return values in text form. However, you can enrich the output by rendering graphics, HTML, or other MIME-encoded data format.

One approach is to send MIME-encoded results to the client using the MIME helper function:

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

For example:

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

Another approach is to use the HTML helper function, which provides a simpler way to display HTML content directly:

fun HTML(text: String): MimeTypedResult

For example:

HTML("<p>This is an example of <strong>HTML</strong> content rendered using the HTML helper function.</p>")

Rendering

Rendering is the procedure of transforming a value to a form that is appropriate for displaying it in the Jupyter client. The Kotlin Kernel for Jupyter notebook supports various features and mechanisms for rendering values:

  • Renderers: Transform values into other representations. Renderers are controlled via the RenderersProcessor method, and you can access it with the notebook API entry point. The Kotlin kernel iterates through a list of available renderers, trying to find one that can handle the given data. A library can define one or more renderers.

  • DisplayResult and Renderable: Objects implementing DisplayResult and Renderable interfaces are rendered to output JSON.

  • Text rendering: Render objects to strings using text renderers. Text renderers are controlled via the TextRenderersProcessor method, and you can access the method with the notebook API entry point. A library can define one or more renderers. The Kotlin Kernel iterates until at least one renderer returns a non-null string for a passed argument. This kind of renderer can be easily composed with each other. For example, a text renderer for iterables can render its elements with a text renderer processor recursively.

  • Throwables rendering: Throwable renderers behave as regular renderers but handle exceptions and errors generated during cell execution.

Common rendering semantics

Successful value evaluation triggers a rendering process. Initially, the RenderersProcessor attempts to convert the value into a Renderable or DisplayResult object. If successful, the result is transformed into JSON output using the toJson() method. For Unit values, no output is generated.

If the value cannot be rendered as Renderable or DisplayResult, the TextRenderersProcessor takes over. It iterates to render the value to a string using the defined text renderers, seeking a non-null string representation. If no suitable renderer is found, the value is transformed into a string using the toString() method. The resulting string is wrapped in a text/plain MIME JSON.

Upon execution failure, an exception is generated. The first applicable throwable renderer is chosen for this exception, and the exception is passed to this renderer's render() method so the returned value is displayed. If no applicable throwable renderer is found, the exception's message and stack trace are printed to standard error.

Autocompletion

When working with the Kotlin notebooks, 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 both globally defined symbols and local symbols, which were loaded into the notebook during cell evaluation.

Error analysis

If you use Jupyter Notebook, you'll notice that compilation errors and warnings are underlined in red and yellow, correspondingly. If you hover the cursor over underlined text, you'll get an error message that can help you to fix the error.

This error analysis is achieved by the kernel-level extension of Jupyter Notebook. The extension sends error-analysis requests to the kernel and renders their results.

Debug your Kotlin notebook client

  1. Run the ./gradlew installDebug Gradle command. The debugger port is selected automatically. The default port is 1044, and if it's unavailable, the consequent ports are used. If you want an exact port, specify the -PdebugPort=<port> Gradle option.
  2. Run the corresponding command to open the desired notebook client.
  3. Attach a remote debugger to the JVM with the corresponding port (the debug port number is printed in the terminal when the kernel starts).

Integrate new libraries

Read this article if you want to integrate new JVM libraries in the Kotlin Kernel for Jupyter notebooks.

Documentation

To learn more, explore the available documentation:

  • Docs site with rendered KDoc comments from the codebase.
  • Docs about integrating new libraries. If you are a library author, you may be interested in the api module in our project. There is also a lib module that contains entities available from the Notebook cells, and a shared-compiler module for Jupyter REPL integration into a standalone application or IDEA plugin.
  • Explore the Kotlin Notebook docs to learn about features, use cases, and tutorials.

Contribute

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, utilize this tracker.

Pull requests are highly appreciated! When submitting a pull request, ensure 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

alejandrapedroza avatar alshan avatar altavir avatar andreyg avatar apatrida avatar ark-1 avatar biranyucel avatar breandan avatar carreau avatar cmelchior avatar devcrocod avatar drschlaubi avatar ermolenkodev avatar evgeniygubarev avatar fbrunacci avatar fmagin avatar holgerbrandl avatar ileasile avatar jbaron avatar jolanrensen avatar koperagen avatar ligee 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

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

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).

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

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?

resultOf is missing

Commit df1e7e3 deleted resultOf.

The sample is now broken.

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

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

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.

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.

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")

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)

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.

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)

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.

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.

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.

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?

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 :)

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

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)

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)

Documentation popup

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

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.

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 ,.

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.

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.

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.

Add mavenLocal resolver

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

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

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.

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

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.