mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-4419]. Align functions in ZeppelinContext of Scala/Python/R
This commit is contained in:
parent
83006c2fd6
commit
7d5cdc8538
16 changed files with 749 additions and 209 deletions
14
.travis.yml
14
.travis.yml
|
|
@ -106,43 +106,43 @@ matrix:
|
|||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.11" PROFILE="-Pspark-2.4 -Pspark-scala-2.11 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,jdbc,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest24,SparkIntegrationTest24,JdbcIntegrationTest,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.11" PROFILE="-Pspark-2.4 -Pspark-scala-2.11 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,jdbc,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest24,SparkIntegrationTest24,JdbcIntegrationTest,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
|
||||
# ZeppelinSparkClusterTest24, SparkIntegrationTest24, JdbcIntegrationTest, Unit test of Spark 2.4 (Scala-2.12)
|
||||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.12" PROFILE="-Pspark-2.4 -Pspark-scala-2.12 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,jdbc,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest24,SparkIntegrationTest24,JdbcIntegrationTest,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.12" PROFILE="-Pspark-2.4 -Pspark-scala-2.12 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,jdbc,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest24,SparkIntegrationTest24,JdbcIntegrationTest,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
|
||||
# ZeppelinSparkClusterTest23, SparkIntegrationTest23, Unit test of Spark 2.3 (Scala-2.11) and Unit test PythonInterpreter under python2
|
||||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.11" PROFILE="-Pspark-2.3 -Pspark-scala-2.11 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest23,SparkIntegrationTest23,org.apache.zeppelin.spark.*,apache.zeppelin.python.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.11" PROFILE="-Pspark-2.3 -Pspark-scala-2.11 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest23,SparkIntegrationTest23,org.apache.zeppelin.spark.*,apache.zeppelin.python.* -DfailIfNoTests=false"
|
||||
|
||||
# ZeppelinSparkClusterTest22, SparkIntegrationTest22, Unit test of Spark 2.2 (Scala-2.10) and Unit test PythonInterpreter under python3
|
||||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.10" PROFILE="-Pspark-2.2 -Pspark-scala-2.10 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest22,SparkIntegrationTest22,org.apache.zeppelin.spark.*,apache.zeppelin.python.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.10" PROFILE="-Pspark-2.2 -Pspark-scala-2.10 -Phadoop2 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest22,SparkIntegrationTest22,org.apache.zeppelin.spark.*,apache.zeppelin.python.* -DfailIfNoTests=false"
|
||||
|
||||
# ZeppelinSparkClusterTest21, SparkIntegrationTest21, Unit test of Spark 2.1 (Scala-2.10)
|
||||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.10" PROFILE="-Pspark-2.1 -Phadoop2 -Pspark-scala-2.10 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest21,SparkIntegrationTest21,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="3" SCALA_VER="2.10" PROFILE="-Pspark-2.1 -Phadoop2 -Pspark-scala-2.10 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest21,SparkIntegrationTest21,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
|
||||
# ZeppelinSparkClusterTest20, SparkIntegrationTest20, Unit test of Spark 2.0 (Scala-2.10), Use python 3.5 because spark 2.0 doesn't support python 3.6 +
|
||||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="2" SCALA_VER="2.10" PROFILE="-Pspark-2.0 -Phadoop2 -Pspark-scala-2.10 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest20,SparkIntegrationTest20,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="2" SCALA_VER="2.10" PROFILE="-Pspark-2.0 -Phadoop2 -Pspark-scala-2.10 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest20,SparkIntegrationTest20,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
|
||||
# ZeppelinSparkClusterTest16, SparkIntegrationTest16, Unit test of Spark 1.6 (Scala-2.10)
|
||||
- sudo: required
|
||||
jdk: "openjdk8"
|
||||
dist: xenial
|
||||
env: BUILD_PLUGINS="true" PYTHON="2" SCALA_VER="2.10" PROFILE="-Pspark-1.6 -Phadoop2 -Pspark-scala-2.10 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest16,SparkIntegrationTest16,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
env: BUILD_PLUGINS="true" PYTHON="2" SCALA_VER="2.10" PROFILE="-Pspark-1.6 -Phadoop2 -Pspark-scala-2.10 -Pintegration" SPARKR="true" BUILD_FLAG="install -DskipTests -DskipRat -am" TEST_FLAG="test -DskipRat -am" MODULES="-pl zeppelin-interpreter-integration,zeppelin-web,spark/spark-dependencies,markdown" TEST_PROJECTS="-Dtest=ZeppelinSparkClusterTest16,SparkIntegrationTest16,org.apache.zeppelin.spark.* -DfailIfNoTests=false"
|
||||
|
||||
# Test python/pyspark with python 2, livy 0.5
|
||||
- sudo: required
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ class InterpreterLogic(val session: Session) {
|
|||
case None => {
|
||||
val listChoices:List[String] = choices.trim.split(CHOICES_SEPARATOR).toList
|
||||
val paramOptions= listChoices.map(choice => new ParamOption(choice, choice))
|
||||
val selected = context.getGui.select(variable, listChoices.head, paramOptions.toArray)
|
||||
val selected = context.getGui.select(variable, paramOptions.toArray, listChoices.head)
|
||||
statement.replaceAll(escapedExp,selected.toString)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ public class InterpreterLogicTest {
|
|||
//Given
|
||||
AngularObjectRegistry angularObjectRegistry = new AngularObjectRegistry("cassandra", null);
|
||||
when(intrContext.getAngularObjectRegistry()).thenReturn(angularObjectRegistry);
|
||||
when(intrContext.getGui().select(eq("name"), eq("'Paul'"), optionsCaptor.capture()))
|
||||
when(intrContext.getGui().select(eq("name"), optionsCaptor.capture(), eq("'Paul'")))
|
||||
.thenReturn("'Jack'");
|
||||
|
||||
//When
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@ class PyZeppelinContext(object):
|
|||
def __contains__(self, item):
|
||||
return self.z.containsKey(item)
|
||||
|
||||
def add(self, key, value):
|
||||
self.__setitem__(key, value)
|
||||
|
||||
def put(self, key, value):
|
||||
self.__setitem__(key, value)
|
||||
|
||||
|
|
@ -72,8 +69,14 @@ class PyZeppelinContext(object):
|
|||
def angular(self, key, noteId = None, paragraphId = None):
|
||||
return self.z.angular(key, noteId, paragraphId)
|
||||
|
||||
def angularBind(self, key, value, noteId = None, paragraphId = None):
|
||||
return self.z.angularBind(key, value, noteId, paragraphId)
|
||||
def remove(self, key):
|
||||
self.z.remove(key)
|
||||
|
||||
def contains(self, key):
|
||||
return self.contains(key)
|
||||
|
||||
def add(self, key, value):
|
||||
self.__setitem__(key, value)
|
||||
|
||||
def getInterpreterContext(self):
|
||||
return self.z.getInterpreterContext()
|
||||
|
|
@ -84,23 +87,56 @@ class PyZeppelinContext(object):
|
|||
def textbox(self, name, defaultValue=""):
|
||||
return self.z.textbox(name, defaultValue)
|
||||
|
||||
def password(self, name):
|
||||
return self.z.password(name)
|
||||
|
||||
def noteTextbox(self, name, defaultValue=""):
|
||||
return self.z.noteTextbox(name, defaultValue)
|
||||
|
||||
def password(self, name):
|
||||
return self.z.password(name)
|
||||
|
||||
def notePassword(self, name):
|
||||
return self.z.notePassword(name)
|
||||
|
||||
def select(self, name, options, defaultValue=""):
|
||||
return self.z.select(name, defaultValue, self.getParamOptions(options))
|
||||
return self.z.select(name, self.getParamOptions(options), defaultValue)
|
||||
|
||||
def noteSelect(self, name, options, defaultValue=""):
|
||||
return self.z.noteSelect(name, defaultValue, self.getParamOptions(options))
|
||||
return self.z.noteSelect(name, self.getParamOptions(options), defaultValue)
|
||||
|
||||
def checkbox(self, name, options, defaultChecked=[]):
|
||||
return self.z.checkbox(name, self.getDefaultChecked(defaultChecked), self.getParamOptions(options))
|
||||
return self.z.checkbox(name, self.getParamOptions(options), self.getDefaultChecked(defaultChecked))
|
||||
|
||||
def noteCheckbox(self, name, options, defaultChecked=[]):
|
||||
return self.z.noteCheckbox(name, self.getDefaultChecked(defaultChecked), self.getParamOptions(options))
|
||||
return self.z.noteCheckbox(name, self.getParamOptions(options), self.getDefaultChecked(defaultChecked))
|
||||
|
||||
def run(self, paragraphId):
|
||||
return self.z.run(paragraphId)
|
||||
|
||||
def run(self, noteId, paragraphId):
|
||||
return self .z.run(noteId, paragraphId)
|
||||
|
||||
def runNote(self, noteId):
|
||||
return self.z.runNote(noteId)
|
||||
|
||||
def runAll(self):
|
||||
return self.z.runAll()
|
||||
|
||||
def angular(self, key, noteId = None, paragraphId = None):
|
||||
if noteId == None:
|
||||
return self.z.angular(key, self.z.getInterpreterContext().getNoteId(), paragraphId)
|
||||
else:
|
||||
return self.z.angular(key, noteId, paragraphId)
|
||||
|
||||
def angularBind(self, name, value, noteId = None, paragraphId = None):
|
||||
if noteId == None:
|
||||
return self.z.angularBind(name, value, noteId, paragraphId)
|
||||
else:
|
||||
return self.z.angularBind(name, value, self.z.getInterpreterContext().getNoteId(), paragraphId)
|
||||
|
||||
def angularUnbind(self, name, noteId = None):
|
||||
if noteId == None:
|
||||
self.z.angularUnbind(name, self.z.getInterpreterContext().getNoteId())
|
||||
else:
|
||||
self.z.angularUnbind(name, noteId)
|
||||
|
||||
def registerHook(self, event, cmd, replName=None):
|
||||
if replName is None:
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ public class SparkRInterpreter extends AbstractInterpreter {
|
|||
|
||||
@Override
|
||||
public FormType getFormType() {
|
||||
return FormType.NONE;
|
||||
return FormType.NATIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ assign(".zeppelinContext", SparkR:::callJStatic("org.apache.zeppelin.spark.Zeppe
|
|||
z.put <- function(name, object) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "put", name, object)
|
||||
}
|
||||
|
||||
z.get <- function(name) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "get", name)
|
||||
}
|
||||
|
|
@ -80,8 +81,44 @@ z.angularBind <- function(name, value, noteId=NULL, paragraphId=NULL) {
|
|||
SparkR:::callJMethod(.zeppelinContext, "angularBind", name, value, noteId, paragraphId)
|
||||
}
|
||||
|
||||
z.input <- function(name, value) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "input", name, value)
|
||||
z.textbox <- function(name, value) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "textbox", name, value)
|
||||
}
|
||||
|
||||
z.noteTextbox <- function(name, value) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "noteTextbox", name, value)
|
||||
}
|
||||
|
||||
z.password <- function(name) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "password", name)
|
||||
}
|
||||
|
||||
z.notePassword <- function(name) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "notePassword", name)
|
||||
}
|
||||
|
||||
z.run <- function(paragraphId) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "run", paragraphId)
|
||||
}
|
||||
|
||||
z.runNote <- function(noteId) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "runNote", noteId)
|
||||
}
|
||||
|
||||
z.runAll <- function() {
|
||||
SparkR:::callJMethod(.zeppelinContext, "runAll")
|
||||
}
|
||||
|
||||
z.angular <- function(name) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "angular", name)
|
||||
}
|
||||
|
||||
z.angularBind <- function(name, value) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "angularBind", name, value)
|
||||
}
|
||||
|
||||
z.angularUnbind <- function(name, value) {
|
||||
SparkR:::callJMethod(.zeppelinContext, "angularUnbind", name)
|
||||
}
|
||||
|
||||
# notify script is initialized
|
||||
|
|
|
|||
|
|
@ -217,27 +217,27 @@ public class IPySparkInterpreterTest extends IPythonInterpreterTest {
|
|||
assertTrue(completions.size() > 0);
|
||||
completions.contains(new InterpreterCompletion("sc", "sc", ""));
|
||||
|
||||
// pyspark streaming
|
||||
// pyspark streaming TODO(zjffdu) disable pyspark streaming test temporary
|
||||
context = createInterpreterContext(mockIntpEventClient);
|
||||
result = interpreter.interpret(
|
||||
"from pyspark.streaming import StreamingContext\n" +
|
||||
"import time\n" +
|
||||
"ssc = StreamingContext(sc, 1)\n" +
|
||||
"rddQueue = []\n" +
|
||||
"for i in range(5):\n" +
|
||||
" rddQueue += [ssc.sparkContext.parallelize([j for j in range(1, 1001)], 10)]\n" +
|
||||
"inputStream = ssc.queueStream(rddQueue)\n" +
|
||||
"mappedStream = inputStream.map(lambda x: (x % 10, 1))\n" +
|
||||
"reducedStream = mappedStream.reduceByKey(lambda a, b: a + b)\n" +
|
||||
"reducedStream.pprint()\n" +
|
||||
"ssc.start()\n" +
|
||||
"time.sleep(6)\n" +
|
||||
"ssc.stop(stopSparkContext=False, stopGraceFully=True)", context);
|
||||
Thread.sleep(1000);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
interpreterResultMessages = context.out.toInterpreterResultMessage();
|
||||
assertEquals(1, interpreterResultMessages.size());
|
||||
assertTrue(interpreterResultMessages.get(0).getData().contains("(0, 100)"));
|
||||
// result = interpreter.interpret(
|
||||
// "from pyspark.streaming import StreamingContext\n" +
|
||||
// "import time\n" +
|
||||
// "ssc = StreamingContext(sc, 1)\n" +
|
||||
// "rddQueue = []\n" +
|
||||
// "for i in range(5):\n" +
|
||||
// " rddQueue += [ssc.sparkContext.parallelize([j for j in range(1, 1001)], 10)]\n" +
|
||||
// "inputStream = ssc.queueStream(rddQueue)\n" +
|
||||
// "mappedStream = inputStream.map(lambda x: (x % 10, 1))\n" +
|
||||
// "reducedStream = mappedStream.reduceByKey(lambda a, b: a + b)\n" +
|
||||
// "reducedStream.pprint()\n" +
|
||||
// "ssc.start()\n" +
|
||||
// "time.sleep(6)\n" +
|
||||
// "ssc.stop(stopSparkContext=False, stopGraceFully=True)", context);
|
||||
// Thread.sleep(1000);
|
||||
// assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
// interpreterResultMessages = context.out.toInterpreterResultMessage();
|
||||
// assertEquals(1, interpreterResultMessages.size());
|
||||
// assertTrue(interpreterResultMessages.get(0).getData().contains("(0, 100)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
public class SparkInterpreterTest {
|
||||
|
|
@ -263,7 +262,7 @@ public class SparkInterpreterTest {
|
|||
assertEquals("pwd", pwd.getName());
|
||||
|
||||
context = getInterpreterContext();
|
||||
result = interpreter.interpret("z.checkbox(\"checkbox_1\", Seq(\"value_2\"), Seq((\"value_1\", \"name_1\"), (\"value_2\", \"name_2\")))", context);
|
||||
result = interpreter.interpret("z.checkbox(\"checkbox_1\", Seq((\"value_1\", \"name_1\"), (\"value_2\", \"name_2\")), Seq(\"value_2\"))", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(1, context.getGui().getForms().size());
|
||||
assertTrue(context.getGui().getForms().get("checkbox_1") instanceof CheckBox);
|
||||
|
|
@ -278,7 +277,7 @@ public class SparkInterpreterTest {
|
|||
assertEquals("name_2", checkBox.getOptions()[1].getDisplayName());
|
||||
|
||||
context = getInterpreterContext();
|
||||
result = interpreter.interpret("z.select(\"select_1\", Seq(\"value_2\"), Seq((\"value_1\", \"name_1\"), (\"value_2\", \"name_2\")))", context);
|
||||
result = interpreter.interpret("z.select(\"select_1\", Seq((\"value_1\", \"name_1\"), (\"value_2\", \"name_2\")), Seq(\"value_2\"))", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(1, context.getGui().getForms().size());
|
||||
assertTrue(context.getGui().getForms().get("select_1") instanceof Select);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import org.apache.zeppelin.display.AngularObjectWatcher
|
|||
import org.apache.zeppelin.display.ui.OptionInput.ParamOption
|
||||
import org.apache.zeppelin.interpreter.{BaseZeppelinContext, InterpreterContext, InterpreterHookRegistry}
|
||||
|
||||
import scala.collection.{JavaConversions, Seq}
|
||||
import scala.collection.Seq
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -47,85 +48,173 @@ class SparkZeppelinContext(val sc: SparkContext,
|
|||
|
||||
private val supportedClasses = scala.collection.mutable.ArrayBuffer[Class[_]]()
|
||||
|
||||
try
|
||||
try {
|
||||
supportedClasses += Class.forName("org.apache.spark.sql.Dataset")
|
||||
catch {
|
||||
} catch {
|
||||
case e: ClassNotFoundException =>
|
||||
}
|
||||
|
||||
try
|
||||
try {
|
||||
supportedClasses += Class.forName("org.apache.spark.sql.DataFrame")
|
||||
catch {
|
||||
} catch {
|
||||
case e: ClassNotFoundException =>
|
||||
|
||||
}
|
||||
if (supportedClasses.isEmpty) throw new RuntimeException("Can not load Dataset/DataFrame class")
|
||||
|
||||
override def getSupportedClasses: util.List[Class[_]] =
|
||||
JavaConversions.mutableSeqAsJavaList(supportedClasses)
|
||||
override def getSupportedClasses: util.List[Class[_]] = supportedClasses.asJava
|
||||
|
||||
override def getInterpreterClassMap: util.Map[String, String] =
|
||||
JavaConversions.mapAsJavaMap(interpreterClassMap)
|
||||
override def getInterpreterClassMap: util.Map[String, String] = interpreterClassMap.asJava
|
||||
|
||||
override def showData(obj: Any, maxResult: Int): String = sparkShims.showDataFrame(obj, maxResult)
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with no item selected.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def select(name: String, options: Seq[(Any, String)]): Any = select(name, null, options)
|
||||
def select(name: String, options: Seq[(Any, String)]): Any = select(name, options, null: Any)
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with default selected item.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @param options
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
def select(name: String, defaultValue: Any, options: Seq[(Any, String)]): Any =
|
||||
select(name, defaultValue, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
select(name, options.map(e => new ParamOption(e._1, e._2)).toArray, defaultValue)
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with default selected item.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @param defaultValue
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def checkbox(name: String, options: Seq[(AnyRef, String)]): Seq[Any] = {
|
||||
val javaResult = checkbox(name, JavaConversions.seqAsJavaList(options.map(e => e._1)),
|
||||
options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
JavaConversions.asScalaBuffer(javaResult)
|
||||
def select(name: String, options: Seq[(Any, String)], defaultValue: Any): Any =
|
||||
select(name, options.map(e => new ParamOption(e._1, e._2)).toArray, defaultValue)
|
||||
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of Select with no item selected.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def noteSelect(name: String, options: Seq[(Any, String)]): Any =
|
||||
noteSelect(name, null, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of Select with default selected item.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @param defaultValue
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def noteSelect(name: String, options: Seq[(Any, String)], defaultValue: Any): Any =
|
||||
noteSelect(name, options.map(e => new ParamOption(e._1, e._2)).toArray, defaultValue)
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of Select with default selected item.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @param options
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
def noteSelect(name: String, defaultValue: Any, options: Seq[(Any, String)]): Any =
|
||||
noteSelect(name, options.map(e => new ParamOption(e._1, e._2)).toArray, defaultValue)
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of checkbox with no item checked.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def checkbox(name: String, options: Seq[(Any, String)]): Seq[Any] = {
|
||||
val javaResult = checkbox(name, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
javaResult.asScala
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of checkbox with default checked items.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @param defaultChecked
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def checkbox(name: String, options: Seq[(Any, String)], defaultChecked: Seq[Any]): Seq[Any] = {
|
||||
val defaultCheckedList = defaultChecked.asJava
|
||||
val optionsArray = options.map(e => new ParamOption(e._1, e._2)).toArray
|
||||
val javaResult = checkbox(name, optionsArray, defaultCheckedList)
|
||||
javaResult.asScala
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of checkbox with no item checked.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def noteCheckbox(name: String, options: Seq[(Any, String)]): Seq[Any] = {
|
||||
val javaResult = noteCheckbox(name, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
javaResult.asScala
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of checkbox with default checked items.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @param defaultChecked
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
def noteCheckbox(name: String, options: Seq[(Any, String)], defaultChecked: Seq[Any]): Seq[Any] = {
|
||||
val javaResult = noteCheckbox(name,
|
||||
options.map(e => new ParamOption(e._1, e._2)).toArray, defaultChecked.asJava)
|
||||
javaResult.asScala
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
def checkbox(name: String, defaultChecked: Seq[AnyRef], options: Seq[(Any, String)]): Seq[Any] = {
|
||||
val defaultCheckedList = JavaConversions.seqAsJavaList(defaultChecked)
|
||||
val javaResult = checkbox(name, defaultCheckedList, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
JavaConversions.asScalaBuffer(javaResult)
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
def noteSelect(name: String, options: Seq[(Any, String)]): Any = noteSelect(name, "", options)
|
||||
|
||||
@ZeppelinApi
|
||||
def noteSelect(name: String, defaultValue: Any, options: Seq[(Any, String)]): AnyRef =
|
||||
noteSelect(name, defaultValue, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
|
||||
@ZeppelinApi
|
||||
def noteCheckbox(name: String, options: Seq[(AnyRef, String)]): Seq[AnyRef] = {
|
||||
val javaResulst =noteCheckbox(name, JavaConversions.seqAsJavaList(options.map(e => e._1)),
|
||||
options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
JavaConversions.asScalaBuffer(javaResulst)
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
def noteCheckbox(name: String, defaultChecked: Seq[AnyRef], options: Seq[(AnyRef, String)]): Seq[AnyRef] = {
|
||||
val defaultCheckedList = JavaConversions.seqAsJavaList(defaultChecked)
|
||||
val javaResult = noteCheckbox(name, defaultCheckedList, options.map(e => new ParamOption(e._1, e._2)).toArray)
|
||||
JavaConversions.asScalaBuffer(javaResult)
|
||||
}
|
||||
|
||||
@ZeppelinApi def angularWatch(name: String, func: (AnyRef, AnyRef) => Unit): Unit = {
|
||||
def angularWatch(name: String, func: (AnyRef, AnyRef) => Unit): Unit = {
|
||||
angularWatch(name, interpreterContext.getNoteId, func)
|
||||
}
|
||||
|
||||
@deprecated def angularWatchGlobal(name: String, func: (AnyRef, AnyRef) => Unit): Unit = {
|
||||
@deprecated
|
||||
def angularWatchGlobal(name: String, func: (AnyRef, AnyRef) => Unit): Unit = {
|
||||
angularWatch(name, null, func)
|
||||
}
|
||||
|
||||
@ZeppelinApi def angularWatch(name: String,
|
||||
func: (AnyRef, AnyRef, InterpreterContext) => Unit): Unit = {
|
||||
@ZeppelinApi
|
||||
def angularWatch(name: String, func: (AnyRef, AnyRef, InterpreterContext) => Unit): Unit = {
|
||||
angularWatch(name, interpreterContext.getNoteId, func)
|
||||
}
|
||||
|
||||
@deprecated def angularWatchGlobal(name: String,
|
||||
func: (AnyRef, AnyRef, InterpreterContext) => Unit): Unit = {
|
||||
@deprecated
|
||||
def angularWatchGlobal(name: String,
|
||||
func: (AnyRef, AnyRef, InterpreterContext) => Unit): Unit = {
|
||||
angularWatch(name, null, func)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ public class SubmarineInterpreter extends Interpreter {
|
|||
commandOptions[1] = new ParamOption(COMMAND_JOB_SHOW, COMMAND_JOB_SHOW);
|
||||
commandOptions[2] = new ParamOption(COMMAND_USAGE, COMMAND_USAGE);
|
||||
String command = (String) context.getGui().
|
||||
select("Submarine Command", "", commandOptions);
|
||||
select("Submarine Command", commandOptions, "");
|
||||
|
||||
String distributed = this.properties.getProperty(MACHINELEARNING_DISTRIBUTED_ENABLE, "false");
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,14 @@
|
|||
*/
|
||||
package org.apache.zeppelin.integration;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.display.AngularObject;
|
||||
import org.apache.zeppelin.display.Input;
|
||||
import org.apache.zeppelin.display.ui.CheckBox;
|
||||
import org.apache.zeppelin.display.ui.Select;
|
||||
import org.apache.zeppelin.display.ui.TextBox;
|
||||
import org.apache.zeppelin.interpreter.InterpreterException;
|
||||
import org.apache.zeppelin.interpreter.InterpreterNotFoundException;
|
||||
import org.apache.zeppelin.interpreter.InterpreterProperty;
|
||||
|
|
@ -575,14 +580,18 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
Paragraph p3 = note.addNewParagraph(anonymous);
|
||||
p3.setText("%spark.pyspark print(z.get(\"var_1\"))");
|
||||
|
||||
// resources across interpreter processes (via DistributedResourcePool)
|
||||
Paragraph p4 = note.addNewParagraph(anonymous);
|
||||
p4.setText("%python print(z.get('var_1'))");
|
||||
p4.setText("%spark.r z.get(\"var_1\")");
|
||||
|
||||
// resources across interpreter processes (via DistributedResourcePool)
|
||||
Paragraph p5 = note.addNewParagraph(anonymous);
|
||||
p5.setText("%python print(z.get('var_1'))");
|
||||
|
||||
note.run(p1.getId(), true);
|
||||
note.run(p2.getId(), true);
|
||||
note.run(p3.getId(), true);
|
||||
note.run(p4.getId(), true);
|
||||
note.run(p5.getId(), true);
|
||||
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
|
|
@ -590,7 +599,10 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
assertEquals(Status.FINISHED, p3.getStatus());
|
||||
assertEquals("hello world\n", p3.getReturn().message().get(0).getData());
|
||||
assertEquals(Status.FINISHED, p4.getStatus());
|
||||
assertEquals("hello world\n", p4.getReturn().message().get(0).getData());
|
||||
assertTrue(p4.getReturn().toString(),
|
||||
p4.getReturn().message().get(0).getData().contains("hello world"));
|
||||
assertEquals(Status.FINISHED, p5.getStatus());
|
||||
assertEquals("hello world\n", p5.getReturn().message().get(0).getData());
|
||||
} finally {
|
||||
if (null != note) {
|
||||
TestUtils.getInstance(Notebook.class).removeNote(note.getId(), anonymous);
|
||||
|
|
@ -679,12 +691,12 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
try {
|
||||
note = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
|
||||
Paragraph p = note.addNewParagraph(anonymous);
|
||||
String code = "%spark.spark println(z.textbox(\"my_input\", \"default_name\"))\n" +
|
||||
String code = "%spark println(z.textbox(\"my_input\", \"default_name\"))\n" +
|
||||
"println(z.password(\"my_pwd\"))\n" +
|
||||
"println(z.select(\"my_select\", \"1\"," +
|
||||
"Seq((\"1\", \"select_1\"), (\"2\", \"select_2\"))))\n" +
|
||||
"val items=z.checkbox(\"my_checkbox\", Seq(\"2\"), " +
|
||||
"Seq((\"1\", \"check_1\"), (\"2\", \"check_2\")))\n" +
|
||||
"val items=z.checkbox(\"my_checkbox\", " +
|
||||
"Seq((\"1\", \"check_1\"), (\"2\", \"check_2\")), Seq(\"2\"))\n" +
|
||||
"println(items(0))";
|
||||
p.setText(code);
|
||||
note.run(p.getId());
|
||||
|
|
@ -801,6 +813,164 @@ public abstract class ZeppelinSparkClusterTest extends AbstractTestRestApi {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScalaNoteDynamicForms() throws IOException {
|
||||
Note note = null;
|
||||
try {
|
||||
note = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
|
||||
Paragraph p1 = note.addNewParagraph(anonymous);
|
||||
|
||||
// create TextBox
|
||||
p1.setText("%spark z.noteTextbox(\"name\", \"world\")");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
Input input = p1.getNote().getNoteForms().get("name");
|
||||
assertTrue(input instanceof TextBox);
|
||||
TextBox inputTextBox = (TextBox) input;
|
||||
assertEquals("name", inputTextBox.getDisplayName());
|
||||
assertEquals("world", inputTextBox.getDefaultValue());
|
||||
assertEquals("world", p1.getNote().getNoteParams().get("name"));
|
||||
|
||||
Paragraph p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${name}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello world"));
|
||||
|
||||
// create Select
|
||||
p1.setText("%spark z.noteSelect(\"language\", Seq((\"java\" -> \"JAVA\"), (\"scala\" -> \"SCALA\")), \"java\")");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
input = p1.getNote().getNoteForms().get("language");
|
||||
assertTrue(input instanceof Select);
|
||||
Select select = (Select) input;
|
||||
assertEquals("language", select.getDisplayName());
|
||||
assertEquals("java", select.getDefaultValue());
|
||||
assertEquals("java", p1.getNote().getNoteParams().get("language"));
|
||||
|
||||
p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${language}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello java"));
|
||||
|
||||
// create Checkbox
|
||||
p1.setText("%spark z.noteCheckbox(\"languages\", Seq((\"java\" -> \"JAVA\"), (\"scala\" -> \"SCALA\")), Seq(\"java\", \"scala\"))");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
input = p1.getNote().getNoteForms().get("languages");
|
||||
assertTrue(input instanceof CheckBox);
|
||||
CheckBox checkbox = (CheckBox) input;
|
||||
assertEquals("languages", checkbox.getDisplayName());
|
||||
assertEquals(new Object[]{"java", "scala"}, checkbox.getDefaultValue());
|
||||
assertEquals(Lists.newArrayList("java", "scala"), p1.getNote().getNoteParams().get("languages"));
|
||||
|
||||
p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${checkbox:languages}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello java,scala"));
|
||||
} finally {
|
||||
if (null != note) {
|
||||
TestUtils.getInstance(Notebook.class).removeNote(note.getId(), anonymous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPythonNoteDynamicForms() throws IOException {
|
||||
Note note = null;
|
||||
try {
|
||||
note = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
|
||||
Paragraph p1 = note.addNewParagraph(anonymous);
|
||||
|
||||
// create TextBox
|
||||
p1.setText("%spark.pyspark z.noteTextbox(\"name\", \"world\")");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
Input input = p1.getNote().getNoteForms().get("name");
|
||||
assertTrue(input instanceof TextBox);
|
||||
TextBox inputTextBox = (TextBox) input;
|
||||
assertEquals("name", inputTextBox.getDisplayName());
|
||||
assertEquals("world", inputTextBox.getDefaultValue());
|
||||
assertEquals("world", p1.getNote().getNoteParams().get("name"));
|
||||
|
||||
Paragraph p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${name}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello world"));
|
||||
|
||||
// create Select
|
||||
p1.setText("%spark.pyspark z.noteSelect('language', [('java', 'JAVA'), ('scala', 'SCALA')], 'java')");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
input = p1.getNote().getNoteForms().get("language");
|
||||
assertTrue(input instanceof Select);
|
||||
Select select = (Select) input;
|
||||
assertEquals("language", select.getDisplayName());
|
||||
assertEquals("java", select.getDefaultValue());
|
||||
assertEquals("java", p1.getNote().getNoteParams().get("language"));
|
||||
|
||||
p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${language}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello java"));
|
||||
|
||||
// create Checkbox
|
||||
p1.setText("%spark.pyspark z.noteCheckbox('languages', [('java', 'JAVA'), ('scala', 'SCALA')], ['java', 'scala'])");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
input = p1.getNote().getNoteForms().get("languages");
|
||||
assertTrue(input instanceof CheckBox);
|
||||
CheckBox checkbox = (CheckBox) input;
|
||||
assertEquals("languages", checkbox.getDisplayName());
|
||||
assertEquals(new Object[]{"java", "scala"}, checkbox.getDefaultValue());
|
||||
assertEquals(Lists.newArrayList("java", "scala"), p1.getNote().getNoteParams().get("languages"));
|
||||
|
||||
p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${checkbox:languages}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello java,scala"));
|
||||
} finally {
|
||||
if (null != note) {
|
||||
TestUtils.getInstance(Notebook.class).removeNote(note.getId(), anonymous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRNoteDynamicForms() throws IOException {
|
||||
Note note = null;
|
||||
try {
|
||||
note = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
|
||||
Paragraph p1 = note.addNewParagraph(anonymous);
|
||||
|
||||
// create TextBox
|
||||
p1.setText("%spark.r z.noteTextbox(\"name\", \"world\")");
|
||||
note.run(p1.getId(), true);
|
||||
assertEquals(Status.FINISHED, p1.getStatus());
|
||||
Input input = p1.getNote().getNoteForms().get("name");
|
||||
assertTrue(input instanceof TextBox);
|
||||
TextBox inputTextBox = (TextBox) input;
|
||||
assertEquals("name", inputTextBox.getDisplayName());
|
||||
assertEquals("world", inputTextBox.getDefaultValue());
|
||||
assertEquals("world", p1.getNote().getNoteParams().get("name"));
|
||||
|
||||
Paragraph p2 = note.addNewParagraph(anonymous);
|
||||
p2.setText("%md hello $${name}");
|
||||
note.run(p2.getId(), true);
|
||||
assertEquals(Status.FINISHED, p2.getStatus());
|
||||
assertTrue(p2.getReturn().toString(), p2.getReturn().toString().contains("hello world"));
|
||||
} finally {
|
||||
if (null != note) {
|
||||
TestUtils.getInstance(Notebook.class).removeNote(note.getId(), anonymous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfInterpreter() throws IOException {
|
||||
Note note = null;
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ public class GUI implements Serializable {
|
|||
if (value == null) {
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
forms.put(id, new TextBox(id, defaultValue));
|
||||
params.put(id, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ public class GUI implements Serializable {
|
|||
return params.get(id);
|
||||
}
|
||||
|
||||
public Object select(String id, Object defaultValue, ParamOption[] options) {
|
||||
public Object select(String id, ParamOption[] options, Object defaultValue) {
|
||||
if (defaultValue == null && options != null && options.length > 0) {
|
||||
defaultValue = options[0].getValue();
|
||||
}
|
||||
|
|
@ -104,13 +104,14 @@ public class GUI implements Serializable {
|
|||
Object value = params.get(id);
|
||||
if (value == null) {
|
||||
value = defaultValue;
|
||||
params.put(id, value);
|
||||
}
|
||||
params.put(id, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public List<Object> checkbox(String id, Collection<Object> defaultChecked,
|
||||
ParamOption[] options) {
|
||||
public List<Object> checkbox(String id,
|
||||
ParamOption[] options,
|
||||
Collection<Object> defaultChecked) {
|
||||
Collection<Object> checked = (Collection<Object>) params.get(id);
|
||||
if (checked == null) {
|
||||
checked = defaultChecked;
|
||||
|
|
@ -122,6 +123,7 @@ public class GUI implements Serializable {
|
|||
filtered.add(o);
|
||||
}
|
||||
}
|
||||
params.put(id, filtered);
|
||||
return filtered;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ public class Input<T> implements Serializable {
|
|||
String displayName = null;
|
||||
String type = null;
|
||||
String arg = null;
|
||||
Object defaultValue = "";
|
||||
Object defaultValue = null;
|
||||
ParamOption[] paramOptions = null;
|
||||
|
||||
// get var name type
|
||||
|
|
@ -350,17 +350,25 @@ public class Input<T> implements Serializable {
|
|||
Collection<Object> checked = value instanceof Collection ? (Collection<Object>) value
|
||||
: Arrays.asList((Object[]) value);
|
||||
List<Object> validChecked = new LinkedList<>();
|
||||
for (Object o : checked) { // filter out obsolete checked values
|
||||
for (ParamOption option : optionInput.getOptions()) {
|
||||
if (option.getValue().equals(o)) {
|
||||
validChecked.add(o);
|
||||
break;
|
||||
for (Object o : checked) {
|
||||
// filter out obsolete checked values
|
||||
if (optionInput.getOptions() != null) {
|
||||
for (ParamOption option : optionInput.getOptions()) {
|
||||
if (option.getValue().equals(o)) {
|
||||
validChecked.add(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
params.put(input.name, validChecked);
|
||||
expanded = StringUtils.join(validChecked, delimiter);
|
||||
} else { // single-selection
|
||||
if (validChecked.isEmpty()) {
|
||||
expanded = StringUtils.join(checked, delimiter);
|
||||
} else {
|
||||
params.put(input.name, validChecked);
|
||||
expanded = StringUtils.join(validChecked, delimiter);
|
||||
}
|
||||
} else {
|
||||
// single-selection
|
||||
expanded = value.toString();
|
||||
}
|
||||
replaced = match.replaceFirst(expanded);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
|
||||
// Map interpreter class name (to be used by hook registry) from
|
||||
// given replName in parapgraph
|
||||
// given replName in paragraph
|
||||
public abstract Map<String, String> getInterpreterClassMap();
|
||||
|
||||
public abstract List<Class> getSupportedClasses();
|
||||
|
|
@ -79,7 +79,8 @@ public abstract class BaseZeppelinContext {
|
|||
public abstract String showData(Object obj, int maxResult);
|
||||
|
||||
/**
|
||||
* @deprecated use z.textbox instead
|
||||
* Create paragraph level dynamic form of textbox with empty value.
|
||||
* @deprecated Use {@link #textbox(String) textbox} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
|
|
@ -88,7 +89,8 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated use z.textbox instead
|
||||
* Create paragraph level dynamic form of textbox with empty value.
|
||||
* @deprecated Use {@link #textbox(String, String) textbox} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
|
|
@ -96,82 +98,53 @@ public abstract class BaseZeppelinContext {
|
|||
return textbox(name, defaultValue.toString(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph level dynamic form of textbox with empty value.
|
||||
* TODO(zjffdu) Return String instead
|
||||
*
|
||||
* @param name
|
||||
* @return text value of this textbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object textbox(String name) {
|
||||
return textbox(name, "", false);
|
||||
return textbox(name, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph level dynamic form of textbox with default value.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @return text value of this textbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object textbox(String name, String defaultValue) {
|
||||
return textbox(name, defaultValue, false);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public Object password(String name) {
|
||||
return password(name, false);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public Object password(String name, boolean noteForm) {
|
||||
if (noteForm) {
|
||||
return noteGui.password(name);
|
||||
} else {
|
||||
return gui.password(name);
|
||||
}
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public List<Object> checkbox(String name, ParamOption[] options) {
|
||||
return checkbox(name, options, false);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public List<Object> checkbox(String name, List<Object> defaultChecked,
|
||||
ParamOption[] options) {
|
||||
return checkbox(name, defaultChecked, options, false);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public Object select(String name, Object defaultValue, ParamOption[] paramOptions) {
|
||||
return select(name, defaultValue, paramOptions, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create note level dynamic form of textbox with empty value.
|
||||
*
|
||||
* @param name
|
||||
* @return text value of this textbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object noteTextbox(String name) {
|
||||
return textbox(name, "");
|
||||
return noteTextbox(name, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create note level dynamic form of textbox with default value.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @return text value of this textbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object noteTextbox(String name, String defaultValue) {
|
||||
return textbox(name, defaultValue, true);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public List<Object> noteCheckbox(String name, ParamOption[] options) {
|
||||
return checkbox(name, options, true);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public List<Object> noteCheckbox(String name, List<Object> defaultChecked,
|
||||
ParamOption[] options) {
|
||||
return checkbox(name, defaultChecked, options, true);
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public Object noteSelect(String name, Object defaultValue, ParamOption[] paramOptions) {
|
||||
return select(name, defaultValue, paramOptions, true);
|
||||
}
|
||||
|
||||
|
||||
private Object select(String name, Object defaultValue, ParamOption[] paramOptions,
|
||||
boolean noteForm) {
|
||||
if (noteForm) {
|
||||
return noteGui.select(name, defaultValue, paramOptions);
|
||||
} else {
|
||||
return gui.select(name, defaultValue, paramOptions);
|
||||
}
|
||||
}
|
||||
|
||||
private Object textbox(String name, String defaultValue, boolean noteForm) {
|
||||
if (noteForm) {
|
||||
return noteGui.textbox(name, defaultValue);
|
||||
|
|
@ -180,25 +153,227 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
}
|
||||
|
||||
private List<Object> checkbox(String name, ParamOption[] options,
|
||||
boolean noteForm) {
|
||||
List<Object> defaultValues = new LinkedList<>();
|
||||
for (ParamOption option : options) {
|
||||
defaultValues.add(option.getValue());
|
||||
}
|
||||
/**
|
||||
* Create paragraph level dynamic form of password.
|
||||
*
|
||||
* @param name
|
||||
* @return text value of this password
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object password(String name) {
|
||||
return password(name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create note level dynamic form of password.
|
||||
*
|
||||
* @param name
|
||||
* @return text value of this password
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object notePassword(String name) {
|
||||
return password(name, true);
|
||||
}
|
||||
|
||||
private Object password(String name, boolean noteForm) {
|
||||
if (noteForm) {
|
||||
return noteGui.checkbox(name, defaultValues, options);
|
||||
return noteGui.password(name);
|
||||
} else {
|
||||
return gui.checkbox(name, defaultValues, options);
|
||||
return gui.password(name);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> checkbox(String name, List<Object> defaultChecked,
|
||||
ParamOption[] options, boolean noteForm) {
|
||||
/**
|
||||
* create paragraph level of dynamic form of checkbox with no item checked.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public List<Object> checkbox(String name, ParamOption[] options) {
|
||||
return checkbox(name, options, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of checkbox with default checked items.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @param defaultChecked
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public List<Object> checkbox(String name,
|
||||
ParamOption[] options,
|
||||
List defaultChecked) {
|
||||
return checkbox(name, options, defaultChecked, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of checkbox with default checked items.
|
||||
* @deprecated Use {@link #checkbox(String, ParamOption[], List<Object>) checkbox} instead.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultChecked
|
||||
* @param options
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
public List<Object> checkbox(String name,
|
||||
List<Object> defaultChecked,
|
||||
ParamOption[] options) {
|
||||
return checkbox(name, options, defaultChecked, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of checkbox with no item checked.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public List<Object> noteCheckbox(String name, ParamOption[] options) {
|
||||
return checkbox(name, options, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of checkbox with default checked items.
|
||||
* @deprecated Use {@link #noteCheckbox(String, ParamOption[], List<Object>) noteCheckbox} instead.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultChecked
|
||||
* @param options
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
public List<Object> noteCheckbox(String name,
|
||||
List<Object> defaultChecked,
|
||||
ParamOption[] options) {
|
||||
return checkbox(name, options, defaultChecked, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of checkbox with default checked items.
|
||||
*
|
||||
* @param name
|
||||
* @param options
|
||||
* @param defaultChecked
|
||||
* @return list of checked values of this checkbox
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public List<Object> noteCheckbox(String name,
|
||||
ParamOption[] options,
|
||||
List defaultChecked) {
|
||||
return checkbox(name, options, defaultChecked, true);
|
||||
}
|
||||
|
||||
private List<Object> checkbox(String name,
|
||||
ParamOption[] options,
|
||||
List<Object> defaultChecked,
|
||||
boolean noteForm) {
|
||||
if (defaultChecked == null ) {
|
||||
List<Object> defaultValues = new LinkedList<>();
|
||||
for (ParamOption option : options) {
|
||||
defaultValues.add(option.getValue());
|
||||
}
|
||||
}
|
||||
if (noteForm) {
|
||||
return noteGui.checkbox(name, defaultChecked, options);
|
||||
return noteGui.checkbox(name, options, defaultChecked);
|
||||
} else {
|
||||
return gui.checkbox(name, defaultChecked, options);
|
||||
return gui.checkbox(name, options, defaultChecked);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with no item selected.
|
||||
*
|
||||
* @param name
|
||||
* @param paramOptions
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object select(String name, ParamOption[] paramOptions) {
|
||||
return select(name, paramOptions, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with default selected item.
|
||||
* @deprecated Use {@link #select(String, ParamOption[], Object) select} instead.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @param paramOptions
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
public Object select(String name, Object defaultValue, ParamOption[] paramOptions) {
|
||||
return select(name, paramOptions, defaultValue, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with default selected item.
|
||||
*
|
||||
* @param name
|
||||
* @param paramOptions
|
||||
* @param defaultValue
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object select(String name, ParamOption[] paramOptions, Object defaultValue) {
|
||||
return select(name, paramOptions, defaultValue, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* create paragraph level of dynamic form of Select with no item selected.
|
||||
*
|
||||
* @param name
|
||||
* @param paramOptions
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object noteSelect(String name, ParamOption[] paramOptions) {
|
||||
return select(name, null, paramOptions, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of Select with default selected item.
|
||||
* @deprecated Use {@link #noteSelect(String, ParamOption[], Object) noteSelect} instead.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @param paramOptions
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@Deprecated
|
||||
@ZeppelinApi
|
||||
public Object noteSelect(String name, Object defaultValue, ParamOption[] paramOptions) {
|
||||
return select(name, paramOptions, defaultValue, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* create note level of dynamic form of Select with default selected item.
|
||||
*
|
||||
* @param name
|
||||
* @param paramOptions
|
||||
* @param defaultValue
|
||||
* @return text value of selected item
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public Object noteSelect(String name, ParamOption[] paramOptions, Object defaultValue) {
|
||||
return select(name, paramOptions, defaultValue, true);
|
||||
}
|
||||
|
||||
private Object select(String name, ParamOption[] paramOptions, Object defaultValue,
|
||||
boolean noteForm) {
|
||||
if (noteForm) {
|
||||
return noteGui.select(name, paramOptions, defaultValue);
|
||||
} else {
|
||||
return gui.select(name, paramOptions, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +385,6 @@ public abstract class BaseZeppelinContext {
|
|||
return gui;
|
||||
}
|
||||
|
||||
|
||||
public GUI getNoteGui() {
|
||||
return noteGui;
|
||||
}
|
||||
|
|
@ -287,7 +461,9 @@ public abstract class BaseZeppelinContext {
|
|||
* Run paragraph by id
|
||||
*
|
||||
* @param paragraphId
|
||||
* @param checkCurrentParagraph
|
||||
* @param checkCurrentParagraph check whether you call this run method in the current paragraph.
|
||||
* Set it to false only when you are sure you are not invoking this method to run current
|
||||
* paragraph. Otherwise you would run current paragraph in infinite loop.
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void run(String paragraphId, boolean checkCurrentParagraph) throws IOException {
|
||||
|
|
@ -306,7 +482,6 @@ public abstract class BaseZeppelinContext {
|
|||
*
|
||||
* @param noteId
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void run(String noteId, String paragraphId, InterpreterContext context)
|
||||
throws IOException {
|
||||
run(noteId, paragraphId, context, true);
|
||||
|
|
@ -318,8 +493,7 @@ public abstract class BaseZeppelinContext {
|
|||
* @param noteId
|
||||
* @param context
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void run(String noteId, String paragraphId, InterpreterContext context,
|
||||
private void run(String noteId, String paragraphId, InterpreterContext context,
|
||||
boolean checkCurrentParagraph) throws IOException {
|
||||
|
||||
if (paragraphId.equals(context.getParagraphId()) && checkCurrentParagraph) {
|
||||
|
|
@ -332,6 +506,7 @@ public abstract class BaseZeppelinContext {
|
|||
.runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId());
|
||||
}
|
||||
|
||||
@ZeppelinApi
|
||||
public void runNote(String noteId) throws IOException {
|
||||
runNote(noteId, interpreterContext);
|
||||
}
|
||||
|
|
@ -359,6 +534,7 @@ public abstract class BaseZeppelinContext {
|
|||
* Set it to false only when you are sure you are not invoking this method to run current
|
||||
* paragraph. Otherwise you would run current paragraph in infinite loop.
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void run(int idx, boolean checkCurrentParagraph) throws IOException {
|
||||
String noteId = interpreterContext.getNoteId();
|
||||
run(noteId, idx, interpreterContext, checkCurrentParagraph);
|
||||
|
|
@ -371,7 +547,7 @@ public abstract class BaseZeppelinContext {
|
|||
* @param idx index starting from 0
|
||||
* @param context interpreter context
|
||||
*/
|
||||
public void run(String noteId, int idx, InterpreterContext context) throws IOException {
|
||||
private void run(String noteId, int idx, InterpreterContext context) throws IOException {
|
||||
run(noteId, idx, context, true);
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +560,7 @@ public abstract class BaseZeppelinContext {
|
|||
* Set it to false only when you are sure you are not invoking this method to run current
|
||||
* paragraph. Otherwise you would run current paragraph in infinite loop.
|
||||
*/
|
||||
public void run(String noteId, int idx, InterpreterContext context,
|
||||
private void run(String noteId, int idx, InterpreterContext context,
|
||||
boolean checkCurrentParagraph) throws IOException {
|
||||
|
||||
List<String> paragraphIds = new ArrayList<>();
|
||||
|
|
@ -394,6 +570,11 @@ public abstract class BaseZeppelinContext {
|
|||
.runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all paragraphs of current note except this.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void runAll() throws IOException {
|
||||
runAll(interpreterContext);
|
||||
|
|
@ -401,8 +582,10 @@ public abstract class BaseZeppelinContext {
|
|||
|
||||
/**
|
||||
* Run all paragraphs. except this.
|
||||
*
|
||||
* @param context
|
||||
* @throws IOException
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void runAll(InterpreterContext context) throws IOException {
|
||||
runNote(context.getNoteId());
|
||||
}
|
||||
|
|
@ -418,7 +601,7 @@ public abstract class BaseZeppelinContext {
|
|||
|
||||
|
||||
/**
|
||||
* Get angular object. Look up notebook scope first and then global scope
|
||||
* Get angular object. Look up note scope first and then global scope
|
||||
*
|
||||
* @param name variable name
|
||||
* @return value
|
||||
|
|
@ -434,6 +617,13 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get note scope angular object.
|
||||
*
|
||||
* @param name
|
||||
* @param noteId
|
||||
* @return value
|
||||
*/
|
||||
public Object angular(String name, String noteId) {
|
||||
AngularObject ao = getAngularObject(name, noteId,
|
||||
interpreterContext.getParagraphId(), interpreterContext);
|
||||
|
|
@ -444,6 +634,14 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paragraph scope angular object.
|
||||
*
|
||||
* @param name
|
||||
* @param noteId
|
||||
* @param paragraphId
|
||||
* @return value
|
||||
*/
|
||||
public Object angular(String name, String noteId, String paragraphId) {
|
||||
AngularObject ao = getAngularObject(name, noteId, paragraphId, interpreterContext);
|
||||
if (ao == null) {
|
||||
|
|
@ -471,11 +669,12 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create angular variable in notebook scope and bind with front end Angular display system.
|
||||
* Create angular variable in note scope and bind with front end Angular display system.
|
||||
* If variable exists, it'll be overwritten.
|
||||
*
|
||||
* @param name name of the variable
|
||||
* @param o value
|
||||
* @throws TException
|
||||
*/
|
||||
@ZeppelinApi
|
||||
public void angularBind(String name, Object o) throws TException {
|
||||
|
|
@ -609,7 +808,7 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create angular variable in notebook scope and bind with front end Angular display system.
|
||||
* Create angular variable in note scope and bind with front end Angular display system.
|
||||
* If variable exists, it'll be overwritten.
|
||||
*
|
||||
* @param name name of the variable
|
||||
|
|
@ -627,7 +826,7 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create angular variable in notebook scope and bind with front end Angular display system.
|
||||
* Create angular variable in note scope and bind with front end Angular display system.
|
||||
* If variable exists, it'll be overwritten.
|
||||
*
|
||||
* @param name name of the variable
|
||||
|
|
@ -646,7 +845,7 @@ public abstract class BaseZeppelinContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create angular variable in notebook scope and bind with front end Angular display
|
||||
* Create angular variable in note scope and bind with front end Angular display
|
||||
* system.
|
||||
* If variable exists, value will be overwritten and watcher will be added.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,16 +49,16 @@ public class GUITest {
|
|||
@Test
|
||||
public void testSelect() {
|
||||
GUI gui = new GUI();
|
||||
Object selected = gui.select("list_1", null, options);
|
||||
Object selected = gui.select("list_1", options, null);
|
||||
// use the first one as the default value
|
||||
assertEquals("1", selected);
|
||||
|
||||
gui = new GUI();
|
||||
selected = gui.select("list_1", "2", options);
|
||||
selected = gui.select("list_1", options, "2");
|
||||
assertEquals("2", selected);
|
||||
// "2" is selected by above statement, so even this default value is "1", the selected value is
|
||||
// still "2"
|
||||
selected = gui.select("list_1", "1", options);
|
||||
selected = gui.select("list_1", options, "1");
|
||||
assertEquals("2", selected);
|
||||
}
|
||||
|
||||
|
|
@ -66,10 +66,10 @@ public class GUITest {
|
|||
public void testGson() {
|
||||
GUI gui = new GUI();
|
||||
gui.textbox("textbox_1", "default_text_1");
|
||||
gui.select("select_1", "1", options);
|
||||
gui.select("select_1", options, "1");
|
||||
List<Object> list = new ArrayList();
|
||||
list.add("1");
|
||||
gui.checkbox("checkbox_1", list, options);
|
||||
gui.checkbox("checkbox_1", options, list);
|
||||
|
||||
String json = gui.toJson();
|
||||
System.out.println(json);
|
||||
|
|
|
|||
|
|
@ -393,8 +393,8 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
|
|||
List<Object> defaultValues = new ArrayList();
|
||||
defaultValues.add("default1");
|
||||
defaultValues.add("default2");
|
||||
gui.checkbox("checkbox_id", defaultValues, paramOptions);
|
||||
gui.select("select_id", "default", paramOptions);
|
||||
gui.checkbox("checkbox_id", paramOptions, defaultValues);
|
||||
gui.select("select_id", paramOptions, "default");
|
||||
gui.textbox("textbox_id");
|
||||
Map<String, Input> expected = new LinkedHashMap<>(gui.getForms());
|
||||
Interpreter interpreter = interpreterSetting.getDefaultInterpreter("user1", "note1");
|
||||
|
|
|
|||
Loading…
Reference in a new issue