Ben Chuanlong Du's Blog

It is never too late to learn.

Specify Dependencies in the Almond Scala Kernel in JupyterLab

Jar Dependency

The way to add Jar dependency in Almond is the same as in Ammonite.

In [ ]:
interp.load.cp(os.Path("/absolute/path/to/file.jar"))
In [ ]:
import $cp.`/absolute/path/to/file.jar`

Maven Dependency

  1. Notice that %% (in interp.load.ivy) and :: (in import $ivy...) automatically suffix the short version of the current Scala distribution (e.g., _2.12) to the artifact name. For example, if your current Scala distribution is 2.12, then the following 2 statements are equivalent.
    interp.load.ivy("org.apache.spark" % "spark-core_2.12" % "2.3.1")
     interp.load.ivy("org.apache.spark" %% "spark-core" % "2.3.1")
    
    This is specific to Scala. You almost never need to use %% or :: when you add a Java library dependency.
In [ ]:
import $ivy.`org.apache.spark:spark-sql_2.12:2.4.2` 
import $ivy.`org.apache.spark::spark-sql:2.4.2`
In [ ]:
interp.load.ivy("org.apache.spark" % "spark-core_2.12" % "2.4.2")
interp.load.ivy("org.apache.spark" %% "spark-sql" % "2.4.2")

Almond Jupyter/Lab API

https://almond.sh/docs/api-jupyter

In [ ]:

Comments