CoCalc Shared FilesInstall-Almond-Scala-Jupyter-kernel-in-CoCalc-2020.mdOpen in CoCalc with one click!
Author: Samuel Lelièvre
Views : 22
License: Other -- explicitly state in your code
Description: Install Almond Scala Jupyter kernel in CoCalc

Install Almond on CoCalc

Author: Samuel Lelièvre

Date: 2019-12-31

License: CC0

What

Almond is a Scala kernel for Jupyter.

Issue for installing on CoCalc:

This is a follow-up to my previous attempt from January 2019.

Install Almond in a CoCalc project

We follow the quick start installation guide:

Check Scala version available on CoCalc:

~$ date -u +"%Y-%m-%dT%H%M%SZ"
2019-12-31T023625Z

~$ scala
Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/home/user/tmp/ -Xms64m
Welcome to Scala 2.11.12 (OpenJDK 64-Bit Server VM, Java 11.0.4).
Type in expressions for evaluation. Or try :help.
scala> :quit

Given the possible combinations listed at:

we will set SCALA_VERSION=2.11.12 ALMOND_VERSION=0.6.0.

Follow the guide:

~$ SCALA_VERSION=2.11.12 ALMOND_VERSION=0.6.0
~$ curl -Lo coursier https://git.io/coursier-cli
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   135  100   135    0     0    415      0 --:--:-- --:--:-- --:--:--   415
100 24825  100 24825    0     0  58002      0 --:--:-- --:--:-- --:--:-- 58002
~$ chmod +x coursier
~$ ./coursier bootstrap \>     -r jitpack \
>     -i user -I user:sh.almond:scala-kernel-api_$SCALA_VERSION:$ALMOND_VERSION \
>     sh.almond:scala-kernel_$SCALA_VERSION:$ALMOND_VERSION \
>     -o almond
Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/home/user/tmp/ -Xms64m
https://repo1.maven.org/maven2/sh/almond/scala-kernel_2.11.12/0.6.0/scala-kernel_2.11.12-0.6.0.pom
  100.0% [##########] 2.1 KiB (7.0 KiB / s)
...
https://repo1.maven.org/maven2/org/scalameta/trees_2.11/4.1.4/trees_2.11-4.1.4.jar
  100.0% [##########] 3.3 MiB (6.8 MiB / s)
Wrote /home/user/almond

Last step:

~$ ./almond --install
Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/home/user/tmp/ -Xms64m
Installed scala kernel under /home/user/.local/share/jupyter/kernels/scala

Check what got installed:

~$ ls -halF ~/.local/share/jupyter/kernels/scala
total 31K
drwxr-xr-x 2 user user    5 Dec 31 02:22 ./
drwxr-xr-x 3 user user    3 Jan 10  2019 ../
-rw-r--r-- 1 user user  211 Dec 31 02:22 kernel.json
-rwxr-xr-x 1 user user  26K Dec 31 02:22 launcher.jar*
-rw-r--r-- 1 user user 2.0K Dec 31 02:22 logo-64x64.png
~$ cat /.local/share/jupyter/kernels/scala/kernel.json
{
  "language" : "scala",
  "display_name" : "Scala",
  "argv" : [
    "java",
    "-jar",
    "/home/user/.local/share/jupyter/kernels/scala/launcher.jar",
    "--connection-file",
    "{connection_file}"
  ]
}
~/.local/share/jupyter/kernels/scala$ 

Try it

Download the official example notebooks:

~$ git clone https://github.com/almond-sh/examples
Cloning into 'examples'...
remote: Enumerating objects: 64, done.
remote: Counting objects: 100% (64/64), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 498 (delta 21), reused 21 (delta 7), pack-reused 434
Receiving objects: 100% (498/498), 2.09 MiB | 11.97 MiB/s, done.
Resolving deltas: 100% (299/299), done.

And open them in CoCalc.

  • We need to set the kernel to "Trusted".

When we execute cells, it seems to think for a while, but neither execution number nor output appear.

Would be nice to inspect the logs to check what is going on.

Sadly I don't know where to look.