Skip to content

Commit 32e50c9

Browse files
author
Vincent Ye
committed
build Spark Monitor plugin into a separate jar
1 parent 96d161f commit 32e50c9

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,59 @@ This results in 2 packages.
8080

8181
NOTE: `make release` uses `docker`. Please refer to `docker` installation instructions for your system.
8282

83+
## Building Individual Components
84+
85+
### Main Toree Assembly
86+
To build just the main Toree assembly jar (without spark-monitor-plugin):
87+
```
88+
sbt assembly
89+
```
90+
This creates: `target/scala-2.12/toree-assembly-<VERSION>.jar`
91+
92+
### Spark Monitor Plugin
93+
To build the spark-monitor-plugin as a separate jar:
94+
```
95+
sbt sparkMonitorPlugin/assembly
96+
```
97+
This creates: `spark-monitor-plugin/target/scala-2.12/spark-monitor-plugin-<VERSION>.jar`
98+
99+
### Build All Components
100+
To compile all projects including both the main assembly and spark-monitor-plugin:
101+
```
102+
sbt compile
103+
```
104+
105+
**Note**: The spark-monitor-plugin is now built as a separate jar and is not included in the main Toree assembly.
106+
107+
## Using the Spark Monitor Plugin
108+
109+
To enable the Spark Monitor Plugin in your Toree application, you need to specify the path to the plugin JAR when starting Toree:
110+
111+
### Option 1: Command Line Parameter
112+
```bash
113+
# Start Toree with spark-monitor-plugin enabled
114+
java -jar target/scala-2.12/toree-assembly-<VERSION>.jar --magic-url file:///path/to/spark-monitor-plugin/target/scala-2.12/spark-monitor-plugin-<VERSION>.jar [other-options]
115+
```
116+
117+
### Option 2: Jupyter Kernel Installation
118+
When installing Toree as a Jupyter kernel, you can specify the plugin:
119+
```bash
120+
jupyter toree install --spark_home=<YOUR_SPARK_PATH> --kernel_name=toree_with_monitor --toree_opts="--magic-url file:///path/to/spark-monitor-plugin-<VERSION>.jar"
121+
```
122+
123+
### Option 3: Configuration File
124+
You can also specify the plugin in a configuration file and use the `--profile` option:
125+
```json
126+
{
127+
"magic_urls": ["file:///path/to/spark-monitor-plugin-<VERSION>.jar"]
128+
}
129+
```
130+
Then start with: `java -jar toree-assembly.jar --profile config.json`
131+
132+
**Important**:
133+
- Make sure to use the absolute path to the spark-monitor-plugin JAR file and ensure the JAR is accessible from the location where Toree is running.
134+
- The JAR file name does not contain "toree" prefix to avoid automatic loading as an internal plugin. This allows you to control when the SparkMonitorPlugin is enabled via the `--magic-url` parameter.
135+
83136
Run Examples
84137
============
85138
To play with the example notebooks, run

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ lazy val root = (project in file("."))
123123
macros,protocol,plugins,sparkMonitorPlugin,communication,kernelApi,client,scalaInterpreter,sqlInterpreter,kernel
124124
)
125125
.dependsOn(
126-
macros,protocol,communication,kernelApi,client,scalaInterpreter,sqlInterpreter,kernel,sparkMonitorPlugin
126+
macros,protocol,communication,kernelApi,client,scalaInterpreter,sqlInterpreter,kernel
127127
)
128128

129129
/**
@@ -146,7 +146,7 @@ lazy val protocol = (project in file("protocol"))
146146
*/
147147
lazy val plugins = (project in file("plugins"))
148148
.settings(name := "toree-plugins")
149-
.dependsOn(macros, protocol)
149+
.dependsOn(macros)
150150

151151
/**
152152
* Project representing the SparkMonitor plugin for Toree.

spark-monitor-plugin/build.sbt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,24 @@ libraryDependencies ++= Seq(
2525
)
2626

2727
// Test dependencies
28-
libraryDependencies += Dependencies.scalaCompiler.value % "test"
28+
libraryDependencies += Dependencies.scalaCompiler.value % "test"
29+
30+
// Assembly configuration for separate jar
31+
enablePlugins(AssemblyPlugin)
32+
33+
assembly / assemblyJarName := s"spark-monitor-plugin-${version.value}.jar"
34+
35+
assembly / assemblyMergeStrategy := {
36+
case "module-info.class" => MergeStrategy.discard
37+
case PathList("META-INF", "versions", "9", "module-info.class") => MergeStrategy.discard
38+
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
39+
case x =>
40+
val oldStrategy = (assembly / assemblyMergeStrategy).value
41+
oldStrategy(x)
42+
}
43+
44+
assembly / assemblyOption ~= {
45+
_.withIncludeScala(false)
46+
}
47+
48+
assembly / test := {}

0 commit comments

Comments
 (0)