Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7424af2
Remove resource on note / paragraph removal
Leemoonsoo Mar 5, 2016
568ee54
ApplicationLoader
Leemoonsoo Mar 7, 2016
b891b98
HeliumRegistry
Leemoonsoo Mar 13, 2016
b239f1b
Helium application factory
Leemoonsoo Mar 19, 2016
9f5c493
Application output
Leemoonsoo Apr 1, 2016
4eaeea7
sync -> async api
Leemoonsoo Apr 2, 2016
7aeb64a
Unload app on paragraph / note removal as well as interpreter unbind
Leemoonsoo Apr 3, 2016
134bbe6
Change HeliumRegistry constructor argument type
Leemoonsoo Apr 6, 2016
94b490d
initial rest api impl
Leemoonsoo Apr 6, 2016
bd0f467
Style
Leemoonsoo Apr 9, 2016
6223cd4
App output display
Leemoonsoo Apr 12, 2016
16f6887
Angular object update for helium app
Leemoonsoo Apr 12, 2016
412480a
Fix style
Leemoonsoo Apr 12, 2016
be3a1fa
Add license header
Leemoonsoo Apr 12, 2016
5503f9c
Improved
Leemoonsoo Apr 12, 2016
b47ca74
Fix tests
Leemoonsoo Apr 12, 2016
98f3872
Managed interpreter process and Running interpreter process
Leemoonsoo Apr 13, 2016
024d7fc
Dev mode
Leemoonsoo Apr 13, 2016
71f814d
Better way to find resource dir for InterpreterOutput watcher
Leemoonsoo Apr 13, 2016
f2ab95d
Prevent unnecessary output update
Leemoonsoo Apr 13, 2016
b4ff52f
Put last value of scala repl into resource pool
Leemoonsoo Apr 14, 2016
ec2fdea
Match classname correctly
Leemoonsoo Apr 14, 2016
0e4d81c
Remove unnecessary log
Leemoonsoo Apr 14, 2016
fade3c1
Handle output update in angular mode
Leemoonsoo Apr 14, 2016
03be3a1
Pass required resource to run() method
Leemoonsoo Apr 14, 2016
c30f53c
null check
Leemoonsoo Apr 14, 2016
864bea1
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Apr 14, 2016
1f1a3b5
Fix test
Leemoonsoo Apr 17, 2016
01a1646
Add example
Leemoonsoo Apr 17, 2016
620f79f
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Apr 17, 2016
0730ece
Add license into package json
Leemoonsoo Apr 17, 2016
3b891de
Provide resource pool for testing
Leemoonsoo Apr 17, 2016
83eba98
UnloadApp on interpreter restart
Leemoonsoo Apr 18, 2016
51fc113
Include examples in CI build
Leemoonsoo Apr 18, 2016
ab1de03
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Apr 28, 2016
7451479
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Apr 30, 2016
f07ada1
Construct classpath correctly
Leemoonsoo May 7, 2016
8186daf
Update Application Status from RemoteInterpreterProcess event
Leemoonsoo May 8, 2016
b6e4141
helper for printing javascript and inject $z
Leemoonsoo May 12, 2016
b068065
Replace . to _
Leemoonsoo May 15, 2016
5225551
let instead of var
Leemoonsoo May 15, 2016
b974eb1
Add horizontal bar visualization example
Leemoonsoo May 15, 2016
f782fb0
clean pom.xml file
Leemoonsoo May 15, 2016
e89177e
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo May 19, 2016
99dd0b0
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo May 28, 2016
93fa766
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 6, 2016
e0a2046
Add annotation to api
Leemoonsoo Jun 8, 2016
e36d2fb
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 8, 2016
1dc4409
Remove incubating from example pom.xml
Leemoonsoo Jun 8, 2016
bfcdf34
Fix style
Leemoonsoo Jun 8, 2016
0671dfd
Fix compile error
Leemoonsoo Jun 8, 2016
7f174e3
Add more comments
Leemoonsoo Jun 8, 2016
e60cd8e
Add docs
Leemoonsoo Jun 8, 2016
bff2217
Fix SparkParagraphIT
Leemoonsoo Jun 8, 2016
76de11c
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 11, 2016
14efb6c
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 14, 2016
9110897
arrange buttons
Leemoonsoo Jun 14, 2016
b6811a6
set SPARK_HOME to find bin/interpreter.sh
Leemoonsoo Jun 14, 2016
3619afd
Exclude test data file from rat check
Leemoonsoo Jun 15, 2016
6c5019e
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 15, 2016
710487b
fix syntax error
Leemoonsoo Jun 15, 2016
4571781
double quote the keys in json
Leemoonsoo Jun 15, 2016
6f1343f
add license header
Leemoonsoo Jun 15, 2016
88dbc71
change style
Leemoonsoo Jun 15, 2016
e54d633
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 16, 2016
5bef173
Update NoteTest
Leemoonsoo Jun 16, 2016
6a5a19e
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 16, 2016
644add4
Takecare csv/tsv download button position after merge
Leemoonsoo Jun 16, 2016
ac963ff
Remove unnecessary stacktrace and provide more meaningful message
Leemoonsoo Jun 16, 2016
385dab3
Fix xpath in the SparkParagraphIt test
Leemoonsoo Jun 17, 2016
562f083
CLose interpreter after test
Leemoonsoo Jun 17, 2016
1bdea70
Print error message in the test
Leemoonsoo Jun 17, 2016
5b5f6c8
trigger ci
Leemoonsoo Jun 17, 2016
eaa68c6
print processes
Leemoonsoo Jun 17, 2016
f999f71
Update getParagraphXpath
Leemoonsoo Jun 17, 2016
d43ab57
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 21, 2016
0467077
update test
Leemoonsoo Jun 21, 2016
d558591
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 23, 2016
c714a19
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 29, 2016
4e98cfe
Update DependencyResolver
Leemoonsoo Jun 29, 2016
4030fff
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jun 30, 2016
3249ddb
Remove incubating
Leemoonsoo Jun 30, 2016
6785441
interpreter order changed
Leemoonsoo Jul 1, 2016
e1b0e79
Update unittest
Leemoonsoo Jul 1, 2016
83b529c
Update unittest
Leemoonsoo Jul 2, 2016
0665380
Merge branch 'master' into ZEPPELIN-732-up
Leemoonsoo Jul 2, 2016
3577777
Address Ahyoung's comment
Leemoonsoo Jul 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ matrix:
include:
# Test all modules
- jdk: "oraclejdk7"
env: SPARK_VER="1.6.1" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Pr -Phadoop-2.3 -Ppyspark -Psparkr -Pscalding" BUILD_FLAG="package -Pbuild-distr" TEST_FLAG="verify -Pusing-packaged-distr" TEST_PROJECTS=""
env: SPARK_VER="1.6.1" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Pr -Phadoop-2.3 -Ppyspark -Psparkr -Pscalding -Pexamples" BUILD_FLAG="package -Pbuild-distr" TEST_FLAG="verify -Pusing-packaged-distr" TEST_PROJECTS=""

# Test spark module for 1.5.2
- jdk: "oraclejdk7"
Expand All @@ -59,7 +59,7 @@ matrix:

# Test selenium with spark module for 1.6.1
- jdk: "oraclejdk7"
env: TEST_SELENIUM="true" SPARK_VER="1.6.1" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Phadoop-2.3 -Ppyspark" BUILD_FLAG="package -DskipTests" TEST_FLAG="verify" TEST_PROJECTS="-pl zeppelin-interpreter,zeppelin-zengine,zeppelin-server,zeppelin-display,spark-dependencies,spark -Dtest=org.apache.zeppelin.AbstractFunctionalSuite -DfailIfNoTests=false"
env: TEST_SELENIUM="true" SPARK_VER="1.6.1" HADOOP_VER="2.3" PROFILE="-Pspark-1.6 -Phadoop-2.3 -Ppyspark -Pexamples" BUILD_FLAG="package -DskipTests" TEST_FLAG="verify" TEST_PROJECTS="-pl zeppelin-interpreter,zeppelin-zengine,zeppelin-server,zeppelin-display,spark-dependencies,spark -Dtest=org.apache.zeppelin.AbstractFunctionalSuite -DfailIfNoTests=false"

before_install:
- "ls -la .spark-dist ${HOME}/.m2/repository/.cache/maven-download-plugin"
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ Available profiles are
-Pmapr51
```

#### -Pexamples (optional)

Bulid examples under zeppelin-examples directory





Here're some examples:

Expand Down Expand Up @@ -231,6 +238,7 @@ mvn clean package -Dignite.version=1.6.0 -DskipTests
mvn clean package -Pscalding -DskipTests
```


### Configure
If you wish to configure Zeppelin option (like port number), configure the following files:

Expand Down
1 change: 1 addition & 0 deletions docs/_includes/themes/zeppelin/_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<li role="separator" class="divider"></li>
<li class="title"><span><b>Contibute</b><span></li>
<li><a href="{{BASE_PATH}}/development/writingzeppelininterpreter.html">Writing Zeppelin Interpreter</a></li>
<li><a href="{{BASE_PATH}}/development/writingzeppelinapplication.html">Writing Zeppelin Application</a></li>
<li><a href="{{BASE_PATH}}/development/howtocontribute.html">How to contribute (code)</a></li>
<li><a href="{{BASE_PATH}}/development/howtocontributewebsite.html">How to contribute (website)</a></li>
</ul>
Expand Down
185 changes: 185 additions & 0 deletions docs/development/writingzeppelinapplication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
layout: page
title: "Writing Zeppelin Application"
description: ""
group: development
---
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
{% include JB/setup %}

# What is Zeppelin Application (Experimental)

Apache Zeppelin Application is a package that runs on Interpreter process and displays it's output inside of the notebook. While application runs on Interpreter process, it's able to access resources provided by Interpreter through ResourcePool. Output is always rendered by AngularDisplaySystem. Therefore application provides all the possiblities of making interactive graphical application that uses data and processing power of any Interpreter.



## Writing your own Application

Writing Application means extending `org.apache.zeppelin.helium.Application`. You can use your favorite IDE and language while Java class files are packaged into jar. `Application` class looks like

```java

/**
* Constructor. Invoked when application is loaded
*/
public Application(ApplicationContext context);

/**
* Invoked when there're (possible) updates in required resource set.
* i.e. invoked after application load and after paragraph finishes.
*/
public abstract void run(ResourceSet args);

/**
* Invoked before application unload.
* Application is automatically unloaded with paragraph/notebook removal
*/
public abstract void unload();
```


You can check example applications under [./zeppelin-examples](https://github.com/apache/incubator-zeppelin/tree/master/zeppelin-examples) directory.


## Development mode

In the development mode, you can run your Application in your IDE as a normal java application and see the result inside of Zeppelin notebook.

org.apache.zeppelin.interpreter.dev.ZeppelinApplicationDevServer can run Zeppelin Application in development mode.

```java

// entry point for development mode
public static void main(String[] args) throws Exception {

// add resources for development mode
LocalResourcePool pool = new LocalResourcePool("dev");
pool.put("date", new Date());

// run application in devlopment mode with give resource
// in this case, Clock.class.getName() will be the application class name
ZeppelinApplicationDevServer devServer = new ZeppelinApplicationDevServer(
Clock.class.getName(),
pool.getAll());

// start development mode
devServer.start();
devServer.join();
}
```


In the Zeppelin notebook, run `%dev run` will connect to application running in development mode.




## Package file

Package file is a json file that provides information about the application.
Json file contains following informations

```
{
name : "[organization].[name]",
description : "Description",
artifact : "groupId:artifactId:version",
className : "your.package.name.YourApplicationClass",
resources : [
["resource.name", ":resource.class.name"],
["alternative.resource.name", ":alternative.class.name"]
],
icon : "<i class="icon"></i>"
}

```

#### name

Name is a string in '[group].[name]' format.
[group] and [name] allows only [A-Za-z0-9_].
Group is normally organization name who creates this application.

#### description

Short description. about application

#### artifact

Location of the jar artifact.
"groupId:artifactId:version" will make load artifact from maven repository.
If jar is in local filesystem, absolute/relative can be used.

e.g.

When artifact exists in Maven repository

`artifact: "org.apache.zeppelin:zeppelin-examples:0.6.0"`

When artifact exists in local filesystem

`artifact: "zeppelin-example/target/zeppelin-example-0.6.0.jar"`


#### className

Entry point. Class that extends `org.apache.zeppelin.helium.Application`


#### resources

Two dimensional array that defines required resources by name or by className. Helium Application launcher will compare resources in the ResourcePool with informations in this field and suggest application only when all required resources are available in the ResourcePool.

Resouce name is a string which will be compared with name of objects in the ResourcePool. className is a string with ":" prepended, which will be compared with className of the objects in the ResourcePool.

Application may require two or more resources. Required resource can be listed inside of json array. For example, if application requires object "name1", "name2" and "className1" type of object to run, resources field can be

```
resources: [
[ "name1", "name2", ":className1", ...]
]
```

If Application can handle alternative combination of required resource, alternative set can be listed as below.

```
resources: [
[ "name", ":className"],
[ "altName", ":altClassName1"],
...
]
```

Easier way of understanding this scheme is

```
resources: [
[ 'resource' AND 'resource' AND ... ] OR
[ 'resource' AND 'resource' AND ... ] OR
...
]
```


#### icon

Icon to be used on the application button. String in this field will be rendered as a html.

e.g.

```
icon: "<i class='fa fa-clock-o'></i>"
```

7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,13 @@
</modules>
</profile>

<profile>
<id>examples</id>
<modules>
<module>zeppelin-examples</module>
</modules>
</profile>

<profile>
<id>build-distr</id>
<activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.InterpreterUtils;
import org.apache.zeppelin.interpreter.WrappedInterpreter;
import org.apache.zeppelin.resource.ResourcePool;
import org.apache.zeppelin.resource.WellKnownResourceName;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
Expand Down Expand Up @@ -533,7 +535,9 @@ public void open() {
binder.put("sc", sc);
binder.put("sqlc", sqlc);
binder.put("z", z);

binder.put("intp", intp);
intp.interpret("@transient val intp = _binder.get(\"intp\").asInstanceOf[org.apache.spark" +
".repl.SparkIMain]");
intp.interpret("@transient val z = "
+ "_binder.get(\"z\").asInstanceOf[org.apache.zeppelin.spark.ZeppelinContext]");
intp.interpret("@transient val sc = "
Expand Down Expand Up @@ -759,13 +763,10 @@ public InterpreterResult interpret(String[] lines, InterpreterContext context) {
public InterpreterResult interpretInput(String[] lines, InterpreterContext context) {
SparkEnv.set(env);

// add print("") to make sure not finishing with comment
// see https://github.com/NFLabs/zeppelin/issues/151
String[] linesToRun = new String[lines.length + 1];
String[] linesToRun = new String[lines.length];
for (int i = 0; i < lines.length; i++) {
linesToRun[i] = lines[i];
}
linesToRun[lines.length] = "print(\"\")";

Console.setOut(context.out);
out.setInterpreterOutput(context.out);
Expand Down Expand Up @@ -828,17 +829,39 @@ public InterpreterResult interpretInput(String[] lines, InterpreterContext conte
}
}

// make sure code does not finish with comment
if (r == Code.INCOMPLETE) {
scala.tools.nsc.interpreter.Results.Result res;
res = intp.interpret(incomplete + "\nprint(\"\")");
r = getResultCode(res);
}

if (r == Code.INCOMPLETE) {
sc.clearJobGroup();
out.setInterpreterOutput(null);
return new InterpreterResult(r, "Incomplete expression");
} else {
sc.clearJobGroup();
putLatestVarInResourcePool(context);
out.setInterpreterOutput(null);
return new InterpreterResult(Code.SUCCESS);
}
}

private void putLatestVarInResourcePool(InterpreterContext context) {
String varName = intp.mostRecentVar();
if (varName == null || varName.isEmpty()) {
return;
}

Object lastObj = getValue(varName);
if (lastObj != null) {
ResourcePool resourcePool = context.getResourcePool();
resourcePool.put(context.getNoteId(), context.getParagraphId(),
WellKnownResourceName.ZeppelinReplResult.toString(), lastObj);
}
};


@Override
public void cancel(InterpreterContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.spark.SparkConf;
import org.apache.spark.SparkContext;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.resource.LocalResourcePool;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.apache.zeppelin.display.GUI;
import org.apache.zeppelin.interpreter.*;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void setUp() throws Exception {
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
null,
new LocalResourcePool("id"),
new LinkedList<InterpreterContextRunner>(),
new InterpreterOutput(new InterpreterOutputListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Properties;

import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.resource.LocalResourcePool;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.apache.zeppelin.display.GUI;
import org.apache.zeppelin.interpreter.*;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void setUp() throws Exception {
context = new InterpreterContext("note", "id", "title", "text", new AuthenticationInfo(),
new HashMap<String, Object>(), new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
null,
new LocalResourcePool("id"),
new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(new InterpreterOutputListener() {
@Override
public void onAppend(InterpreterOutput out, byte[] line) {
Expand Down
Loading