use of org.apache.zeppelin.helium.HeliumPackage in project zeppelin by apache.
the class HeliumRestApi method suggest.
@POST
@Path("load/{noteId}/{paragraphId}")
public Response suggest(@PathParam("noteId") String noteId, @PathParam("paragraphId") String paragraphId, String heliumPackage) {
Note note = notebook.getNote(noteId);
if (note == null) {
return new JsonResponse(Response.Status.NOT_FOUND, "Note " + noteId + " not found").build();
}
Paragraph paragraph = note.getParagraph(paragraphId);
if (paragraph == null) {
return new JsonResponse(Response.Status.NOT_FOUND, "Paragraph " + paragraphId + " not found").build();
}
HeliumPackage pkg = gson.fromJson(heliumPackage, HeliumPackage.class);
String appId = helium.getApplicationFactory().loadAndRun(pkg, paragraph);
return new JsonResponse(Response.Status.OK, "", appId).build();
}
use of org.apache.zeppelin.helium.HeliumPackage in project zeppelin by apache.
the class RemoteInterpreterServer method loadApplication.
@Override
public RemoteApplicationResult loadApplication(String applicationInstanceId, String packageInfo, String noteId, String paragraphId) throws InterpreterRPCException, TException {
if (runningApplications.containsKey(applicationInstanceId)) {
LOGGER.warn("Application instance {} is already running", applicationInstanceId);
return new RemoteApplicationResult(true, "");
}
HeliumPackage pkgInfo = HeliumPackage.fromJson(packageInfo);
ApplicationContext context = getApplicationContext(pkgInfo, noteId, paragraphId, applicationInstanceId);
try {
Application app = null;
LOGGER.info("Loading application {}({}), artifact={}, className={} into note={}, paragraph={}", pkgInfo.getName(), applicationInstanceId, pkgInfo.getArtifact(), pkgInfo.getClassName(), noteId, paragraphId);
app = appLoader.load(pkgInfo, context);
runningApplications.put(applicationInstanceId, new RunningApplication(pkgInfo, app, noteId, paragraphId));
return new RemoteApplicationResult(true, "");
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return new RemoteApplicationResult(false, e.getMessage());
}
}
use of org.apache.zeppelin.helium.HeliumPackage in project zeppelin by apache.
the class HeliumTestRegistry method setUp.
@Before
public void setUp() throws IOException {
HeliumTestRegistry registry = new HeliumTestRegistry("r1", "r1");
helium.clear();
registry.add(new HeliumPackage(HeliumType.APPLICATION, "name1", "desc1", "artifact1", "className1", new String[][] {}, "", ""));
registry.add(new HeliumPackage(HeliumType.APPLICATION, "name2", "desc2", "artifact2", "className2", new String[][] {}, "", ""));
helium.addRegistry(registry);
}
use of org.apache.zeppelin.helium.HeliumPackage in project zeppelin by apache.
the class HeliumRestApi method load.
@POST
@Path("load/{noteId}/{paragraphId}")
public Response load(@PathParam("noteId") String noteId, @PathParam("paragraphId") String paragraphId, String heliumPackage) {
try {
return notebook.processNote(noteId, note -> {
if (note == null) {
return new JsonResponse<>(Response.Status.NOT_FOUND, "Note " + noteId + " not found").build();
}
Paragraph paragraph = note.getParagraph(paragraphId);
if (paragraph == null) {
return new JsonResponse<>(Response.Status.NOT_FOUND, "Paragraph " + paragraphId + " not found").build();
}
HeliumPackage pkg = HeliumPackage.fromJson(heliumPackage);
try {
return new JsonResponse<>(Response.Status.OK, "", helium.getApplicationFactory().loadAndRun(pkg, paragraph)).build();
} catch (RuntimeException e) {
logger.error(e.getMessage(), e);
return new JsonResponse<>(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build();
}
});
} catch (IOException e) {
return new JsonResponse<>(Response.Status.NOT_FOUND, "Fail to get note: " + noteId + "\n" + ExceptionUtils.getStackTrace(e)).build();
}
}
Aggregations