mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
feat: Support spell info
This commit is contained in:
parent
822a1d8744
commit
5be2890b20
12 changed files with 89 additions and 37 deletions
|
|
@ -102,7 +102,7 @@ public class ApplicationLoader {
|
|||
*/
|
||||
public Application load(HeliumPackage packageInfo, ApplicationContext context)
|
||||
throws Exception {
|
||||
if (packageInfo.getType() != HeliumPackage.Type.APPLICATION) {
|
||||
if (packageInfo.getType() != HeliumType.APPLICATION) {
|
||||
throw new ApplicationException(
|
||||
"Can't instantiate " + packageInfo.getType() + " package using ApplicationLoader");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.apache.zeppelin.annotation.Experimental;
|
|||
*/
|
||||
@Experimental
|
||||
public class HeliumPackage {
|
||||
private Type type;
|
||||
private HeliumType type;
|
||||
private String name; // user friendly name of this application
|
||||
private String description; // description
|
||||
private String artifact; // artifact name e.g) groupId:artifactId:versionId
|
||||
|
|
@ -33,18 +33,9 @@ public class HeliumPackage {
|
|||
private String license;
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* Type of package
|
||||
*/
|
||||
public static enum Type {
|
||||
INTERPRETER,
|
||||
NOTEBOOK_REPO,
|
||||
APPLICATION,
|
||||
VISUALIZATION,
|
||||
SPELL
|
||||
}
|
||||
public SpellPackageInfo spell;
|
||||
|
||||
public HeliumPackage(Type type,
|
||||
public HeliumPackage(HeliumType type,
|
||||
String name,
|
||||
String description,
|
||||
String artifact,
|
||||
|
|
@ -77,13 +68,13 @@ public class HeliumPackage {
|
|||
return type == info.type && artifact.equals(info.artifact) && className.equals(info.className);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
public HeliumType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static boolean isBundleType(Type type) {
|
||||
return (type == Type.VISUALIZATION ||
|
||||
type == Type.SPELL);
|
||||
public static boolean isBundleType(HeliumType type) {
|
||||
return (type == HeliumType.VISUALIZATION ||
|
||||
type == HeliumType.SPELL);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -112,4 +103,8 @@ public class HeliumPackage {
|
|||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public SpellPackageInfo getSpellInfo() {
|
||||
return spell;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package org.apache.zeppelin.helium;
|
||||
|
||||
/**
|
||||
* Type of Helium Package
|
||||
*/
|
||||
public enum HeliumType {
|
||||
INTERPRETER,
|
||||
NOTEBOOK_REPO,
|
||||
APPLICATION,
|
||||
VISUALIZATION,
|
||||
SPELL
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.apache.zeppelin.helium;
|
||||
|
||||
/**
|
||||
* Info for Helium Spell Package.
|
||||
*/
|
||||
public class SpellPackageInfo {
|
||||
private String magic;
|
||||
private String usage;
|
||||
|
||||
public String getMagic() {
|
||||
return magic;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,6 @@ package org.apache.zeppelin.helium;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.zeppelin.dep.DependencyResolver;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutput;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutputListener;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResultMessageOutput;
|
||||
import org.apache.zeppelin.resource.LocalResourcePool;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
@ -74,7 +72,7 @@ public class ApplicationLoaderTest {
|
|||
|
||||
public HeliumPackage createPackageInfo(String className, String artifact) {
|
||||
HeliumPackage app1 = new HeliumPackage(
|
||||
HeliumPackage.Type.APPLICATION,
|
||||
HeliumType.APPLICATION,
|
||||
"name1",
|
||||
"desc1",
|
||||
artifact,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package org.apache.zeppelin.helium;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class HeliumPackageTest {
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@Test
|
||||
public void parseSpellPackageInfo() {
|
||||
String exampleSpell = "{\n" +
|
||||
" \"type\" : \"SPELL\",\n" +
|
||||
" \"name\" : \"echo-spell\",\n" +
|
||||
" \"description\" : \"'%echo' - return just what receive (example)\",\n" +
|
||||
" \"artifact\" : \"./zeppelin-examples/zeppelin-example-spell-echo\",\n" +
|
||||
" \"license\" : \"Apache-2.0\",\n" +
|
||||
" \"icon\" : \"<i class='fa fa-repeat'></i>\",\n" +
|
||||
" \"spell\": {\n" +
|
||||
" \"magic\": \"%echo\",\n" +
|
||||
" \"usage\": \"%echo <TEXT>\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
HeliumPackage p = gson.fromJson(exampleSpell, HeliumPackage.class);
|
||||
assertEquals(p.getSpellInfo().getMagic(), "%echo");
|
||||
assertEquals(p.getSpellInfo().getUsage(), "%echo <TEXT>");
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ public class ZeppelinServer extends Application {
|
|||
conf.getHeliumConfPath(),
|
||||
conf.getHeliumRegistry(),
|
||||
new File(conf.getRelativeDir(ConfVars.ZEPPELIN_DEP_LOCALREPO),
|
||||
"helium_registry_cache"),
|
||||
"helium-registry-cache"),
|
||||
heliumBundleFactory,
|
||||
heliumApplicationFactory);
|
||||
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ public class Helium {
|
|||
|
||||
for (List<HeliumPackageSearchResult> pkgs : getAllPackageInfo().values()) {
|
||||
for (HeliumPackageSearchResult pkg : pkgs) {
|
||||
if (pkg.getPkg().getType() == HeliumPackage.Type.APPLICATION && pkg.isEnabled()) {
|
||||
if (pkg.getPkg().getType() == HeliumType.APPLICATION && pkg.isEnabled()) {
|
||||
ResourceSet resources = ApplicationLoader.findRequiredResourceSet(
|
||||
pkg.getPkg().getResources(),
|
||||
paragraph.getNote().getId(),
|
||||
|
|
@ -351,7 +351,7 @@ public class Helium {
|
|||
List<HeliumPackage> packages = getBundlePackagesToBundle();
|
||||
|
||||
for (HeliumPackage pkg : packages) {
|
||||
if (HeliumPackage.Type.VISUALIZATION == pkg.getType()) {
|
||||
if (HeliumType.VISUALIZATION == pkg.getType()) {
|
||||
orderedPackageList.add(pkg.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
public void testLoadRunUnloadApplication()
|
||||
throws IOException, ApplicationException, InterruptedException {
|
||||
// given
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumPackage.Type.APPLICATION,
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION,
|
||||
"name1",
|
||||
"desc1",
|
||||
"",
|
||||
|
|
@ -175,7 +175,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
@Test
|
||||
public void testUnloadOnParagraphRemove() throws IOException {
|
||||
// given
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumPackage.Type.APPLICATION,
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION,
|
||||
"name1",
|
||||
"desc1",
|
||||
"",
|
||||
|
|
@ -215,7 +215,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
@Test
|
||||
public void testUnloadOnInterpreterUnbind() throws IOException {
|
||||
// given
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumPackage.Type.APPLICATION,
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION,
|
||||
"name1",
|
||||
"desc1",
|
||||
"",
|
||||
|
|
@ -276,7 +276,7 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
|
|||
@Test
|
||||
public void testUnloadOnInterpreterRestart() throws IOException {
|
||||
// given
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumPackage.Type.APPLICATION,
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION,
|
||||
"name1",
|
||||
"desc1",
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class HeliumBundleFactoryTest {
|
|||
@Test
|
||||
public void downloadPackage() throws TaskRunnerException {
|
||||
HeliumPackage pkg = new HeliumPackage(
|
||||
HeliumPackage.Type.VISUALIZATION,
|
||||
HeliumType.VISUALIZATION,
|
||||
"lodash",
|
||||
"lodash",
|
||||
"lodash@3.9.3",
|
||||
|
|
@ -85,7 +85,7 @@ public class HeliumBundleFactoryTest {
|
|||
@Test
|
||||
public void bundlePackage() throws IOException, TaskRunnerException {
|
||||
HeliumPackage pkg = new HeliumPackage(
|
||||
HeliumPackage.Type.VISUALIZATION,
|
||||
HeliumType.VISUALIZATION,
|
||||
"zeppelin-bubblechart",
|
||||
"zeppelin-bubblechart",
|
||||
"zeppelin-bubblechart@0.0.3",
|
||||
|
|
@ -113,7 +113,7 @@ public class HeliumBundleFactoryTest {
|
|||
String localPkg = resDir + "/../../../src/test/resources/helium/vis1";
|
||||
|
||||
HeliumPackage pkg = new HeliumPackage(
|
||||
HeliumPackage.Type.VISUALIZATION,
|
||||
HeliumType.VISUALIZATION,
|
||||
"vis1",
|
||||
"vis1",
|
||||
localPkg,
|
||||
|
|
@ -135,7 +135,7 @@ public class HeliumBundleFactoryTest {
|
|||
String localPkg = resDir + "/../../../src/test/resources/helium/vis2";
|
||||
|
||||
HeliumPackage pkg = new HeliumPackage(
|
||||
HeliumPackage.Type.VISUALIZATION,
|
||||
HeliumType.VISUALIZATION,
|
||||
"vis2",
|
||||
"vis2",
|
||||
localPkg,
|
||||
|
|
@ -163,7 +163,7 @@ public class HeliumBundleFactoryTest {
|
|||
String resDir = new File(res.getFile()).getParent();
|
||||
|
||||
HeliumPackage pkgV1 = new HeliumPackage(
|
||||
HeliumPackage.Type.VISUALIZATION,
|
||||
HeliumType.VISUALIZATION,
|
||||
"zeppelin-bubblechart",
|
||||
"zeppelin-bubblechart",
|
||||
"zeppelin-bubblechart@0.0.3",
|
||||
|
|
@ -174,7 +174,7 @@ public class HeliumBundleFactoryTest {
|
|||
);
|
||||
|
||||
HeliumPackage pkgV2 = new HeliumPackage(
|
||||
HeliumPackage.Type.VISUALIZATION,
|
||||
HeliumType.VISUALIZATION,
|
||||
"zeppelin-bubblechart",
|
||||
"zeppelin-bubblechart",
|
||||
"zeppelin-bubblechart@0.0.1",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class HeliumLocalRegistryTest {
|
|||
|
||||
// when
|
||||
Gson gson = new Gson();
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumPackage.Type.APPLICATION,
|
||||
HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION,
|
||||
"app1",
|
||||
"desc1",
|
||||
"artifact1",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.junit.Test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -79,7 +78,7 @@ public class HeliumTest {
|
|||
|
||||
// when
|
||||
registry1.add(new HeliumPackage(
|
||||
HeliumPackage.Type.APPLICATION,
|
||||
HeliumType.APPLICATION,
|
||||
"name1",
|
||||
"desc1",
|
||||
"artifact1",
|
||||
|
|
@ -89,7 +88,7 @@ public class HeliumTest {
|
|||
""));
|
||||
|
||||
registry2.add(new HeliumPackage(
|
||||
HeliumPackage.Type.APPLICATION,
|
||||
HeliumType.APPLICATION,
|
||||
"name2",
|
||||
"desc2",
|
||||
"artifact2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue