Search in sources :

Example 1 with HeliumPackage

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();
}
Also used : Note(org.apache.zeppelin.notebook.Note) HeliumPackage(org.apache.zeppelin.helium.HeliumPackage) JsonResponse(org.apache.zeppelin.server.JsonResponse) Paragraph(org.apache.zeppelin.notebook.Paragraph)

Example 2 with HeliumPackage

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());
    }
}
Also used : ApplicationContext(org.apache.zeppelin.helium.ApplicationContext) HeliumPackage(org.apache.zeppelin.helium.HeliumPackage) RemoteApplicationResult(org.apache.zeppelin.interpreter.thrift.RemoteApplicationResult) Application(org.apache.zeppelin.helium.Application) TTransportException(org.apache.thrift.transport.TTransportException) InterpreterRPCException(org.apache.zeppelin.interpreter.thrift.InterpreterRPCException) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) ApplicationException(org.apache.zeppelin.helium.ApplicationException) TException(org.apache.thrift.TException) IOException(java.io.IOException)

Example 3 with HeliumPackage

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);
}
Also used : HeliumPackage(org.apache.zeppelin.helium.HeliumPackage) Before(org.junit.Before)

Example 4 with HeliumPackage

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();
    }
}
Also used : HeliumPackage(org.apache.zeppelin.helium.HeliumPackage) IOException(java.io.IOException) JsonResponse(org.apache.zeppelin.server.JsonResponse) Paragraph(org.apache.zeppelin.notebook.Paragraph) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

HeliumPackage (org.apache.zeppelin.helium.HeliumPackage)4 IOException (java.io.IOException)2 Paragraph (org.apache.zeppelin.notebook.Paragraph)2 JsonResponse (org.apache.zeppelin.server.JsonResponse)2 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1 Application (org.apache.zeppelin.helium.Application)1 ApplicationContext (org.apache.zeppelin.helium.ApplicationContext)1 ApplicationException (org.apache.zeppelin.helium.ApplicationException)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 InterpreterRPCException (org.apache.zeppelin.interpreter.thrift.InterpreterRPCException)1 RemoteApplicationResult (org.apache.zeppelin.interpreter.thrift.RemoteApplicationResult)1 Note (org.apache.zeppelin.notebook.Note)1 Before (org.junit.Before)1