diff --git a/.gitignore b/.gitignore index 1c359d6ff0e..089ccc7eb19 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,6 @@ tramp # tmp files /tmp/ + +# Python +*.pyc diff --git a/python/pom.xml b/python/pom.xml index 0d022e98d4d..aa5a4372f91 100644 --- a/python/pom.xml +++ b/python/pom.xml @@ -40,6 +40,16 @@ + + + + com.google.guava + guava + [18.0,) + + + + ${project.groupId} @@ -71,6 +81,24 @@ slf4j-log4j12 + + io.grpc + grpc-netty + 0.15.0 + + + + io.grpc + grpc-protobuf + 0.15.0 + + + + io.grpc + grpc-stub + 0.15.0 + + junit junit diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java new file mode 100644 index 00000000000..69e06dc2df8 --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -0,0 +1,189 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You 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. +*/ + +package org.apache.zeppelin.python2; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.StatusRuntimeException; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.List; +import java.util.Properties; + +import org.apache.zeppelin.interpreter.Interpreter; +import org.apache.zeppelin.interpreter.InterpreterContext; +import org.apache.zeppelin.interpreter.InterpreterResult; +import org.apache.zeppelin.interpreter.InterpreterResult.Code; +import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; +import org.apache.zeppelin.python2.rpc.PythonInterpreterGrpc; +import org.apache.zeppelin.python2.rpc.PythonInterpreterGrpc.PythonInterpreterBlockingStub; +import org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest; +import org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult; +import org.apache.zeppelin.scheduler.Scheduler; +import org.apache.zeppelin.scheduler.SchedulerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Python interpreter for Zeppelin. + * + * Current implementation is thread-safe, + * but by design it can serve only 1 simultanius request at the time: + * it delegates everything to a single Python process. + * + * So it's intended to be used with FIFOScheduler only. + */ +public class PythonInterpreter2 extends Interpreter { + private static final Logger LOG = LoggerFactory.getLogger(PythonInterpreter2.class); + + public static final String INTERPRETER_PY = "/interpreter.py"; + public static final String ZEPPELIN_PYTHON = "zeppelin.python"; + public static final String DEFAULT_ZEPPELIN_PYTHON = "python"; + public static final String MAX_RESULT = "zeppelin.python.maxResult"; + + private int maxResult; + private int serverPort = 9090; + private String serverHost = "localhost"; + + private PythonInterpreterBlockingStub blockingStub; + + + public PythonInterpreter2(Properties property) { + super(property); + } + + @Override + public void open() { + LOG.info("Starting Python interpreter ....."); + LOG.info("Python path is set to:" + property.getProperty(ZEPPELIN_PYTHON)); + + //TODO(bzz): + //%dep grpcio || %dep pip install grpcio + //this.serverPort = `pick open port` + //start `interpreter.py serverPort` + + ManagedChannelBuilder channelBuilder = ManagedChannelBuilder + .forAddress(this.serverHost, this.serverPort) + .usePlaintext(true); + ManagedChannel channel = channelBuilder.build(); + blockingStub = PythonInterpreterGrpc.newBlockingStub(channel); + } + + @Override + public void close() { + LOG.info("closing Python interpreter ....."); + blockingStub.shutdown(null); +// LOG.error("Can't close the interpreter", e); + } + + @Override + public InterpreterResult interpret(String cmd, InterpreterContext contextInterpreter) { + if (cmd == null || cmd.isEmpty()) { + return new InterpreterResult(Code.SUCCESS, ""); + } + String noteId = contextInterpreter.getNoteId(); + return sendCommandToPython(cmd, noteId); + } + + @Override + public void cancel(InterpreterContext context) { +// LOG.error("Can't interrupt the python interpreter", e); + } + + @Override + public int getProgress(InterpreterContext context) { + //TODO(bzz): get progreess! + return 0; + } + + @Override + public List completion(String buf, int cursor) { + //TODO(bzz): get progreess! + return null; + } + + @Override + public FormType getFormType() { + return FormType.NATIVE; + } + + @Override + public Scheduler getScheduler() { + return SchedulerFactory.singleton().createOrGetFIFOScheduler( + PythonInterpreter2.class.getName() + this.hashCode()); + } + + /** + * Sends given text to Python interpreter + * + * @param noteId id of the notebook, to separate contexts: variables, definitions, etc + * @param cmd Python expression text + * @return output + */ + InterpreterResult sendCommandToPython(String code, String noteId) { + LOG.debug("Sending : \n" + (code.length() > 200 ? code.substring(0, 200) + "..." : code)); + CodeInterpreteRequest cmd = CodeInterpreteRequest.newBuilder() + .setCode(code) + .setNoteId(noteId) //pass same 'noteId', for 'shared' interpreter context for all notes + .build(); + InterpetedResult fromPythonProcess; + try { + fromPythonProcess = blockingStub.interprete(cmd); + } catch (StatusRuntimeException e) { + LOG.error("Error when sending commands to Python process", e); + String errorMsg = e.getMessage() + .replace("UNKNOWN: Exception calling application:", "Exception in interpreter.py:"); + if (e.getCause() instanceof java.net.ConnectException) { + errorMsg = "Failed to communicate to Python interpreter.py on " + + this.serverHost + ":" + this.serverPort; + } + return new InterpreterResult(Code.ERROR, errorMsg); + } + InterpreterResult result; + if (gotSuccess(fromPythonProcess)) { + result = new InterpreterResult(Code.SUCCESS, fromPythonProcess.getOutput()); + } else { + result = new InterpreterResult(Code.ERROR, fromPythonProcess.getOutput()); + } + LOG.debug("Got : \n" + result); + return result; + } + + private static boolean gotSuccess(InterpetedResult result) { + //TODO(bzz): replace string \w enum + return result != null && result.getStatus().toLowerCase().contains("success"); + } + + /*public Boolean isPy4jInstalled() { + String output = sendCommandToPython("\n\nimport py4j\n"); + return !output.contains("ImportError"); + }*/ + + private static int findRandomOpenPortOnAllLocalInterfaces() { + Integer port = -1; + try (ServerSocket socket = new ServerSocket(0);) { + port = socket.getLocalPort(); + socket.close(); + } catch (IOException e) { + LOG.error("Can't find an open port", e); + } + return port; + } + +} diff --git a/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterGrpc.java b/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterGrpc.java new file mode 100644 index 00000000000..795b2b72ef9 --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterGrpc.java @@ -0,0 +1,588 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.zeppelin.python2.rpc; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.1.0-SNAPSHOT)", + comments = "Source: python_interpreter.proto") +public class PythonInterpreterGrpc { + + private PythonInterpreterGrpc() {} + + public static final String SERVICE_NAME = "PythonInterpreter"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_INTERPRETE = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "PythonInterpreter", "Interprete"), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance())); + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_AUTO_COMPLETE = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "PythonInterpreter", "AutoComplete"), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.getDefaultInstance())); + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_PROGRESS = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "PythonInterpreter", "Progress"), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.getDefaultInstance())); + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_SHUTDOWN = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "PythonInterpreter", "Shutdown"), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.getDefaultInstance())); + + /** + * Creates a new async stub that supports all call types for the service + */ + public static PythonInterpreterStub newStub(io.grpc.Channel channel) { + return new PythonInterpreterStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static PythonInterpreterBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new PythonInterpreterBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service + */ + public static PythonInterpreterFutureStub newFutureStub( + io.grpc.Channel channel) { + return new PythonInterpreterFutureStub(channel); + } + + /** + */ + public static abstract class PythonInterpreterImplBase implements io.grpc.BindableService, PythonInterpreter { + + /** + *
+     * Blocking RPC to interpreter pice of code
+     * 
+ */ + @java.lang.Override + public void interprete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_INTERPRETE, responseObserver); + } + + /** + */ + @java.lang.Override + public void autoComplete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_AUTO_COMPLETE, responseObserver); + } + + /** + */ + @java.lang.Override + public void progress(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_PROGRESS, responseObserver); + } + + /** + *
+     * Terminates this RPC Server python process
+     * 
+ */ + @java.lang.Override + public void shutdown(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_SHUTDOWN, responseObserver); + } + + @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + METHOD_INTERPRETE, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult>( + this, METHODID_INTERPRETE))) + .addMethod( + METHOD_AUTO_COMPLETE, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions>( + this, METHODID_AUTO_COMPLETE))) + .addMethod( + METHOD_PROGRESS, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator>( + this, METHODID_PROGRESS))) + .addMethod( + METHOD_SHUTDOWN, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void>( + this, METHODID_SHUTDOWN))) + .build(); + } + } + + /** + */ + public static class PythonInterpreterStub extends io.grpc.stub.AbstractStub + implements PythonInterpreter { + private PythonInterpreterStub(io.grpc.Channel channel) { + super(channel); + } + + private PythonInterpreterStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected PythonInterpreterStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PythonInterpreterStub(channel, callOptions); + } + + /** + *
+     * Blocking RPC to interpreter pice of code
+     * 
+ */ + @java.lang.Override + public void interprete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_INTERPRETE, getCallOptions()), request, responseObserver); + } + + /** + */ + @java.lang.Override + public void autoComplete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_AUTO_COMPLETE, getCallOptions()), request, responseObserver); + } + + /** + */ + @java.lang.Override + public void progress(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_PROGRESS, getCallOptions()), request, responseObserver); + } + + /** + *
+     * Terminates this RPC Server python process
+     * 
+ */ + @java.lang.Override + public void shutdown(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_SHUTDOWN, getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static class PythonInterpreterBlockingStub extends io.grpc.stub.AbstractStub + implements PythonInterpreterBlockingClient { + private PythonInterpreterBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private PythonInterpreterBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected PythonInterpreterBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PythonInterpreterBlockingStub(channel, callOptions); + } + + /** + *
+     * Blocking RPC to interpreter pice of code
+     * 
+ */ + @java.lang.Override + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult interprete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request) { + return blockingUnaryCall( + getChannel(), METHOD_INTERPRETE, getCallOptions(), request); + } + + /** + */ + @java.lang.Override + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions autoComplete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request) { + return blockingUnaryCall( + getChannel(), METHOD_AUTO_COMPLETE, getCallOptions(), request); + } + + /** + */ + @java.lang.Override + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator progress(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request) { + return blockingUnaryCall( + getChannel(), METHOD_PROGRESS, getCallOptions(), request); + } + + /** + *
+     * Terminates this RPC Server python process
+     * 
+ */ + @java.lang.Override + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void shutdown(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request) { + return blockingUnaryCall( + getChannel(), METHOD_SHUTDOWN, getCallOptions(), request); + } + } + + /** + */ + public static class PythonInterpreterFutureStub extends io.grpc.stub.AbstractStub + implements PythonInterpreterFutureClient { + private PythonInterpreterFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private PythonInterpreterFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected PythonInterpreterFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PythonInterpreterFutureStub(channel, callOptions); + } + + /** + *
+     * Blocking RPC to interpreter pice of code
+     * 
+ */ + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture interprete( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_INTERPRETE, getCallOptions()), request); + } + + /** + */ + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture autoComplete( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_AUTO_COMPLETE, getCallOptions()), request); + } + + /** + */ + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture progress( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request) { + return futureUnaryCall( + getChannel().newCall(METHOD_PROGRESS, getCallOptions()), request); + } + + /** + *
+     * Terminates this RPC Server python process
+     * 
+ */ + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture shutdown( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request) { + return futureUnaryCall( + getChannel().newCall(METHOD_SHUTDOWN, getCallOptions()), request); + } + } + + /** + * This will be removed in the next release. + * If your code has been using gRPC-java v0.15.0 or higher already, + * the following changes to your code are suggested: + *
    + *
  • replace {@code extends/implements PythonInterpreter} with {@code extends PythonInterpreterImplBase} for server side;
  • + *
  • replace {@code PythonInterpreter} with {@code PythonInterpreterStub} for client side;
  • + *
  • replace usage of {@code PythonInterpreter} with {@code PythonInterpreterImplBase};
  • + *
  • replace usage of {@code AbstractPythonInterpreter} with {@link PythonInterpreterImplBase};
  • + *
  • replace {@code serverBuilder.addService(PythonInterpreterGrpc.bindService(serviceImpl))} + * with {@code serverBuilder.addService(serviceImpl)};
  • + *
  • if you are mocking stubs using mockito, please do not mock them. + * See the documentation on testing with gRPC-java;
  • + *
  • replace {@code PythonInterpreterBlockingClient} with {@link PythonInterpreterBlockingStub};
  • + *
  • replace {@code PythonInterpreterFutureClient} with {@link PythonInterpreterFutureStub}.
  • + *
+ */ + @java.lang.Deprecated public static interface PythonInterpreter { + + public void interprete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void autoComplete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void progress(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request, + io.grpc.stub.StreamObserver responseObserver); + + public void shutdown(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request, + io.grpc.stub.StreamObserver responseObserver); + } + + /** + * This will be removed in the next release. + * If your code has been using gRPC-java v0.15.0 or higher already, + * the following changes to your code are suggested: + *
    + *
  • replace {@code extends/implements PythonInterpreter} with {@code extends PythonInterpreterImplBase} for server side;
  • + *
  • replace {@code PythonInterpreter} with {@code PythonInterpreterStub} for client side;
  • + *
  • replace usage of {@code PythonInterpreter} with {@code PythonInterpreterImplBase};
  • + *
  • replace usage of {@code AbstractPythonInterpreter} with {@link PythonInterpreterImplBase};
  • + *
  • replace {@code serverBuilder.addService(PythonInterpreterGrpc.bindService(serviceImpl))} + * with {@code serverBuilder.addService(serviceImpl)};
  • + *
  • if you are mocking stubs using mockito, please do not mock them. + * See the documentation on testing with gRPC-java;
  • + *
  • replace {@code PythonInterpreterBlockingClient} with {@link PythonInterpreterBlockingStub};
  • + *
  • replace {@code PythonInterpreterFutureClient} with {@link PythonInterpreterFutureStub}.
  • + *
+ */ + @java.lang.Deprecated public static interface PythonInterpreterBlockingClient { + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult interprete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request); + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions autoComplete(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request); + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator progress(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request); + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void shutdown(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request); + } + + /** + * This will be removed in the next release. + * If your code has been using gRPC-java v0.15.0 or higher already, + * the following changes to your code are suggested: + *
    + *
  • replace {@code extends/implements PythonInterpreter} with {@code extends PythonInterpreterImplBase} for server side;
  • + *
  • replace {@code PythonInterpreter} with {@code PythonInterpreterStub} for client side;
  • + *
  • replace usage of {@code PythonInterpreter} with {@code PythonInterpreterImplBase};
  • + *
  • replace usage of {@code AbstractPythonInterpreter} with {@link PythonInterpreterImplBase};
  • + *
  • replace {@code serverBuilder.addService(PythonInterpreterGrpc.bindService(serviceImpl))} + * with {@code serverBuilder.addService(serviceImpl)};
  • + *
  • if you are mocking stubs using mockito, please do not mock them. + * See the documentation on testing with gRPC-java;
  • + *
  • replace {@code PythonInterpreterBlockingClient} with {@link PythonInterpreterBlockingStub};
  • + *
  • replace {@code PythonInterpreterFutureClient} with {@link PythonInterpreterFutureStub}.
  • + *
+ */ + @java.lang.Deprecated public static interface PythonInterpreterFutureClient { + + public com.google.common.util.concurrent.ListenableFuture interprete( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest request); + + public com.google.common.util.concurrent.ListenableFuture autoComplete( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest request); + + public com.google.common.util.concurrent.ListenableFuture progress( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request); + + public com.google.common.util.concurrent.ListenableFuture shutdown( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void request); + } + + /** + * This will be removed in the next release. + * If your code has been using gRPC-java v0.15.0 or higher already, + * the following changes to your code are suggested: + *
    + *
  • replace {@code extends/implements PythonInterpreter} with {@code extends PythonInterpreterImplBase} for server side;
  • + *
  • replace {@code PythonInterpreter} with {@code PythonInterpreterStub} for client side;
  • + *
  • replace usage of {@code PythonInterpreter} with {@code PythonInterpreterImplBase};
  • + *
  • replace usage of {@code AbstractPythonInterpreter} with {@link PythonInterpreterImplBase};
  • + *
  • replace {@code serverBuilder.addService(PythonInterpreterGrpc.bindService(serviceImpl))} + * with {@code serverBuilder.addService(serviceImpl)};
  • + *
  • if you are mocking stubs using mockito, please do not mock them. + * See the documentation on testing with gRPC-java;
  • + *
  • replace {@code PythonInterpreterBlockingClient} with {@link PythonInterpreterBlockingStub};
  • + *
  • replace {@code PythonInterpreterFutureClient} with {@link PythonInterpreterFutureStub}.
  • + *
+ */ + @java.lang.Deprecated public static abstract class AbstractPythonInterpreter extends PythonInterpreterImplBase {} + + /** + * This will be removed in the next release. + * If your code has been using gRPC-java v0.15.0 or higher already, + * the following changes to your code are suggested: + *
    + *
  • replace {@code extends/implements PythonInterpreter} with {@code extends PythonInterpreterImplBase} for server side;
  • + *
  • replace {@code PythonInterpreter} with {@code PythonInterpreterStub} for client side;
  • + *
  • replace usage of {@code PythonInterpreter} with {@code PythonInterpreterImplBase};
  • + *
  • replace usage of {@code AbstractPythonInterpreter} with {@link PythonInterpreterImplBase};
  • + *
  • replace {@code serverBuilder.addService(PythonInterpreterGrpc.bindService(serviceImpl))} + * with {@code serverBuilder.addService(serviceImpl)};
  • + *
  • if you are mocking stubs using mockito, please do not mock them. + * See the documentation on testing with gRPC-java;
  • + *
  • replace {@code PythonInterpreterBlockingClient} with {@link PythonInterpreterBlockingStub};
  • + *
  • replace {@code PythonInterpreterFutureClient} with {@link PythonInterpreterFutureStub}.
  • + *
+ */ + @java.lang.Deprecated public static io.grpc.ServerServiceDefinition bindService(final PythonInterpreter serviceImpl) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + METHOD_INTERPRETE, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult>( + serviceImpl, METHODID_INTERPRETE))) + .addMethod( + METHOD_AUTO_COMPLETE, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions>( + serviceImpl, METHODID_AUTO_COMPLETE))) + .addMethod( + METHOD_PROGRESS, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator>( + serviceImpl, METHODID_PROGRESS))) + .addMethod( + METHOD_SHUTDOWN, + asyncUnaryCall( + new MethodHandlers< + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void, + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void>( + serviceImpl, METHODID_SHUTDOWN))) + .build(); + } + + private static final int METHODID_INTERPRETE = 0; + private static final int METHODID_AUTO_COMPLETE = 1; + private static final int METHODID_PROGRESS = 2; + private static final int METHODID_SHUTDOWN = 3; + + private static class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final PythonInterpreter serviceImpl; + private final int methodId; + + public MethodHandlers(PythonInterpreter serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_INTERPRETE: + serviceImpl.interprete((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_AUTO_COMPLETE: + serviceImpl.autoComplete((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_PROGRESS: + serviceImpl.progress((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_SHUTDOWN: + serviceImpl.shutdown((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + return new io.grpc.ServiceDescriptor(SERVICE_NAME, + METHOD_INTERPRETE, + METHOD_AUTO_COMPLETE, + METHOD_PROGRESS, + METHOD_SHUTDOWN); + } + +} diff --git a/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java b/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java new file mode 100644 index 00000000000..7d6ad9472b9 --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java @@ -0,0 +1,2972 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: python_interpreter.proto + +package org.apache.zeppelin.python2.rpc; + +public final class PythonInterpreterOuterClass { + private PythonInterpreterOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface CodeInterpreteRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:CodeInterpreteRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string code = 1; + */ + java.lang.String getCode(); + /** + * optional string code = 1; + */ + com.google.protobuf.ByteString + getCodeBytes(); + + /** + * optional string noteId = 2; + */ + java.lang.String getNoteId(); + /** + * optional string noteId = 2; + */ + com.google.protobuf.ByteString + getNoteIdBytes(); + } + /** + * Protobuf type {@code CodeInterpreteRequest} + */ + public static final class CodeInterpreteRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:CodeInterpreteRequest) + CodeInterpreteRequestOrBuilder { + // Use CodeInterpreteRequest.newBuilder() to construct. + private CodeInterpreteRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CodeInterpreteRequest() { + code_ = ""; + noteId_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CodeInterpreteRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + code_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + noteId_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeInterpreteRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeInterpreteRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.Builder.class); + } + + public static final int CODE_FIELD_NUMBER = 1; + private volatile java.lang.Object code_; + /** + * optional string code = 1; + */ + public java.lang.String getCode() { + java.lang.Object ref = code_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + code_ = s; + return s; + } + } + /** + * optional string code = 1; + */ + public com.google.protobuf.ByteString + getCodeBytes() { + java.lang.Object ref = code_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + code_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NOTEID_FIELD_NUMBER = 2; + private volatile java.lang.Object noteId_; + /** + * optional string noteId = 2; + */ + public java.lang.String getNoteId() { + java.lang.Object ref = noteId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + noteId_ = s; + return s; + } + } + /** + * optional string noteId = 2; + */ + public com.google.protobuf.ByteString + getNoteIdBytes() { + java.lang.Object ref = noteId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + noteId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, code_); + } + if (!getNoteIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, noteId_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, code_); + } + if (!getNoteIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, noteId_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code CodeInterpreteRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:CodeInterpreteRequest) + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeInterpreteRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeInterpreteRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.Builder.class); + } + + // Construct using org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + code_ = ""; + + noteId_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeInterpreteRequest_descriptor; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest getDefaultInstanceForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.getDefaultInstance(); + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest build() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest buildPartial() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest result = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest(this); + result.code_ = code_; + result.noteId_ = noteId_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest) { + return mergeFrom((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest other) { + if (other == org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest.getDefaultInstance()) return this; + if (!other.getCode().isEmpty()) { + code_ = other.code_; + onChanged(); + } + if (!other.getNoteId().isEmpty()) { + noteId_ = other.noteId_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object code_ = ""; + /** + * optional string code = 1; + */ + public java.lang.String getCode() { + java.lang.Object ref = code_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + code_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string code = 1; + */ + public com.google.protobuf.ByteString + getCodeBytes() { + java.lang.Object ref = code_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + code_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string code = 1; + */ + public Builder setCode( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value; + onChanged(); + return this; + } + /** + * optional string code = 1; + */ + public Builder clearCode() { + + code_ = getDefaultInstance().getCode(); + onChanged(); + return this; + } + /** + * optional string code = 1; + */ + public Builder setCodeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + code_ = value; + onChanged(); + return this; + } + + private java.lang.Object noteId_ = ""; + /** + * optional string noteId = 2; + */ + public java.lang.String getNoteId() { + java.lang.Object ref = noteId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + noteId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string noteId = 2; + */ + public com.google.protobuf.ByteString + getNoteIdBytes() { + java.lang.Object ref = noteId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + noteId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string noteId = 2; + */ + public Builder setNoteId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + noteId_ = value; + onChanged(); + return this; + } + /** + * optional string noteId = 2; + */ + public Builder clearNoteId() { + + noteId_ = getDefaultInstance().getNoteId(); + onChanged(); + return this; + } + /** + * optional string noteId = 2; + */ + public Builder setNoteIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + noteId_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:CodeInterpreteRequest) + } + + // @@protoc_insertion_point(class_scope:CodeInterpreteRequest) + private static final org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest(); + } + + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CodeInterpreteRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CodeInterpreteRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpreteRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface InterpetedResultOrBuilder extends + // @@protoc_insertion_point(interface_extends:InterpetedResult) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string output = 1; + */ + java.lang.String getOutput(); + /** + * optional string output = 1; + */ + com.google.protobuf.ByteString + getOutputBytes(); + + /** + * optional string status = 2; + * + *
+     *TODO(bzz) replace \w enum
+     * 
+ */ + java.lang.String getStatus(); + /** + * optional string status = 2; + * + *
+     *TODO(bzz) replace \w enum
+     * 
+ */ + com.google.protobuf.ByteString + getStatusBytes(); + } + /** + * Protobuf type {@code InterpetedResult} + */ + public static final class InterpetedResult extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:InterpetedResult) + InterpetedResultOrBuilder { + // Use InterpetedResult.newBuilder() to construct. + private InterpetedResult(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private InterpetedResult() { + output_ = ""; + status_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private InterpetedResult( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + output_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + status_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_InterpetedResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.Builder.class); + } + + public static final int OUTPUT_FIELD_NUMBER = 1; + private volatile java.lang.Object output_; + /** + * optional string output = 1; + */ + public java.lang.String getOutput() { + java.lang.Object ref = output_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + output_ = s; + return s; + } + } + /** + * optional string output = 1; + */ + public com.google.protobuf.ByteString + getOutputBytes() { + java.lang.Object ref = output_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + output_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STATUS_FIELD_NUMBER = 2; + private volatile java.lang.Object status_; + /** + * optional string status = 2; + * + *
+     *TODO(bzz) replace \w enum
+     * 
+ */ + public java.lang.String getStatus() { + java.lang.Object ref = status_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + status_ = s; + return s; + } + } + /** + * optional string status = 2; + * + *
+     *TODO(bzz) replace \w enum
+     * 
+ */ + public com.google.protobuf.ByteString + getStatusBytes() { + java.lang.Object ref = status_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + status_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getOutputBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, output_); + } + if (!getStatusBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, status_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getOutputBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, output_); + } + if (!getStatusBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, status_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code InterpetedResult} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:InterpetedResult) + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_InterpetedResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.Builder.class); + } + + // Construct using org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + output_ = ""; + + status_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult getDefaultInstanceForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance(); + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult build() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult buildPartial() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult result = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult(this); + result.output_ = output_; + result.status_ = status_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult) { + return mergeFrom((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult other) { + if (other == org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance()) return this; + if (!other.getOutput().isEmpty()) { + output_ = other.output_; + onChanged(); + } + if (!other.getStatus().isEmpty()) { + status_ = other.status_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object output_ = ""; + /** + * optional string output = 1; + */ + public java.lang.String getOutput() { + java.lang.Object ref = output_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + output_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string output = 1; + */ + public com.google.protobuf.ByteString + getOutputBytes() { + java.lang.Object ref = output_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + output_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string output = 1; + */ + public Builder setOutput( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + output_ = value; + onChanged(); + return this; + } + /** + * optional string output = 1; + */ + public Builder clearOutput() { + + output_ = getDefaultInstance().getOutput(); + onChanged(); + return this; + } + /** + * optional string output = 1; + */ + public Builder setOutputBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + output_ = value; + onChanged(); + return this; + } + + private java.lang.Object status_ = ""; + /** + * optional string status = 2; + * + *
+       *TODO(bzz) replace \w enum
+       * 
+ */ + public java.lang.String getStatus() { + java.lang.Object ref = status_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + status_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string status = 2; + * + *
+       *TODO(bzz) replace \w enum
+       * 
+ */ + public com.google.protobuf.ByteString + getStatusBytes() { + java.lang.Object ref = status_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + status_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string status = 2; + * + *
+       *TODO(bzz) replace \w enum
+       * 
+ */ + public Builder setStatus( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + status_ = value; + onChanged(); + return this; + } + /** + * optional string status = 2; + * + *
+       *TODO(bzz) replace \w enum
+       * 
+ */ + public Builder clearStatus() { + + status_ = getDefaultInstance().getStatus(); + onChanged(); + return this; + } + /** + * optional string status = 2; + * + *
+       *TODO(bzz) replace \w enum
+       * 
+ */ + public Builder setStatusBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + status_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:InterpetedResult) + } + + // @@protoc_insertion_point(class_scope:InterpetedResult) + private static final org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult(); + } + + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public InterpetedResult parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new InterpetedResult(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.InterpetedResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface CodeCompletionRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:CodeCompletionRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string context = 1; + */ + java.lang.String getContext(); + /** + * optional string context = 1; + */ + com.google.protobuf.ByteString + getContextBytes(); + } + /** + * Protobuf type {@code CodeCompletionRequest} + */ + public static final class CodeCompletionRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:CodeCompletionRequest) + CodeCompletionRequestOrBuilder { + // Use CodeCompletionRequest.newBuilder() to construct. + private CodeCompletionRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CodeCompletionRequest() { + context_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CodeCompletionRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + context_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeCompletionRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeCompletionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.Builder.class); + } + + public static final int CONTEXT_FIELD_NUMBER = 1; + private volatile java.lang.Object context_; + /** + * optional string context = 1; + */ + public java.lang.String getContext() { + java.lang.Object ref = context_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + context_ = s; + return s; + } + } + /** + * optional string context = 1; + */ + public com.google.protobuf.ByteString + getContextBytes() { + java.lang.Object ref = context_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + context_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getContextBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, context_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getContextBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, context_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code CodeCompletionRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:CodeCompletionRequest) + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeCompletionRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeCompletionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.Builder.class); + } + + // Construct using org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + context_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeCompletionRequest_descriptor; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest getDefaultInstanceForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.getDefaultInstance(); + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest build() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest buildPartial() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest result = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest(this); + result.context_ = context_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest) { + return mergeFrom((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest other) { + if (other == org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest.getDefaultInstance()) return this; + if (!other.getContext().isEmpty()) { + context_ = other.context_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object context_ = ""; + /** + * optional string context = 1; + */ + public java.lang.String getContext() { + java.lang.Object ref = context_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + context_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string context = 1; + */ + public com.google.protobuf.ByteString + getContextBytes() { + java.lang.Object ref = context_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + context_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string context = 1; + */ + public Builder setContext( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + context_ = value; + onChanged(); + return this; + } + /** + * optional string context = 1; + */ + public Builder clearContext() { + + context_ = getDefaultInstance().getContext(); + onChanged(); + return this; + } + /** + * optional string context = 1; + */ + public Builder setContextBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + context_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:CodeCompletionRequest) + } + + // @@protoc_insertion_point(class_scope:CodeCompletionRequest) + private static final org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest(); + } + + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CodeCompletionRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CodeCompletionRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeCompletionRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface CodeSuggestionsOrBuilder extends + // @@protoc_insertion_point(interface_extends:CodeSuggestions) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated string suggestions = 1; + */ + com.google.protobuf.ProtocolStringList + getSuggestionsList(); + /** + * repeated string suggestions = 1; + */ + int getSuggestionsCount(); + /** + * repeated string suggestions = 1; + */ + java.lang.String getSuggestions(int index); + /** + * repeated string suggestions = 1; + */ + com.google.protobuf.ByteString + getSuggestionsBytes(int index); + } + /** + * Protobuf type {@code CodeSuggestions} + */ + public static final class CodeSuggestions extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:CodeSuggestions) + CodeSuggestionsOrBuilder { + // Use CodeSuggestions.newBuilder() to construct. + private CodeSuggestions(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CodeSuggestions() { + suggestions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CodeSuggestions( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + suggestions_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + suggestions_.add(s); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + suggestions_ = suggestions_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeSuggestions_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeSuggestions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.Builder.class); + } + + public static final int SUGGESTIONS_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList suggestions_; + /** + * repeated string suggestions = 1; + */ + public com.google.protobuf.ProtocolStringList + getSuggestionsList() { + return suggestions_; + } + /** + * repeated string suggestions = 1; + */ + public int getSuggestionsCount() { + return suggestions_.size(); + } + /** + * repeated string suggestions = 1; + */ + public java.lang.String getSuggestions(int index) { + return suggestions_.get(index); + } + /** + * repeated string suggestions = 1; + */ + public com.google.protobuf.ByteString + getSuggestionsBytes(int index) { + return suggestions_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < suggestions_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, suggestions_.getRaw(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < suggestions_.size(); i++) { + dataSize += computeStringSizeNoTag(suggestions_.getRaw(i)); + } + size += dataSize; + size += 1 * getSuggestionsList().size(); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code CodeSuggestions} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:CodeSuggestions) + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeSuggestions_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeSuggestions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.Builder.class); + } + + // Construct using org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + suggestions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_CodeSuggestions_descriptor; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions getDefaultInstanceForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.getDefaultInstance(); + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions build() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions buildPartial() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions result = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + suggestions_ = suggestions_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.suggestions_ = suggestions_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions) { + return mergeFrom((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions other) { + if (other == org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions.getDefaultInstance()) return this; + if (!other.suggestions_.isEmpty()) { + if (suggestions_.isEmpty()) { + suggestions_ = other.suggestions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSuggestionsIsMutable(); + suggestions_.addAll(other.suggestions_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.LazyStringList suggestions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureSuggestionsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + suggestions_ = new com.google.protobuf.LazyStringArrayList(suggestions_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string suggestions = 1; + */ + public com.google.protobuf.ProtocolStringList + getSuggestionsList() { + return suggestions_.getUnmodifiableView(); + } + /** + * repeated string suggestions = 1; + */ + public int getSuggestionsCount() { + return suggestions_.size(); + } + /** + * repeated string suggestions = 1; + */ + public java.lang.String getSuggestions(int index) { + return suggestions_.get(index); + } + /** + * repeated string suggestions = 1; + */ + public com.google.protobuf.ByteString + getSuggestionsBytes(int index) { + return suggestions_.getByteString(index); + } + /** + * repeated string suggestions = 1; + */ + public Builder setSuggestions( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSuggestionsIsMutable(); + suggestions_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string suggestions = 1; + */ + public Builder addSuggestions( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSuggestionsIsMutable(); + suggestions_.add(value); + onChanged(); + return this; + } + /** + * repeated string suggestions = 1; + */ + public Builder addAllSuggestions( + java.lang.Iterable values) { + ensureSuggestionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, suggestions_); + onChanged(); + return this; + } + /** + * repeated string suggestions = 1; + */ + public Builder clearSuggestions() { + suggestions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string suggestions = 1; + */ + public Builder addSuggestionsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureSuggestionsIsMutable(); + suggestions_.add(value); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:CodeSuggestions) + } + + // @@protoc_insertion_point(class_scope:CodeSuggestions) + private static final org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions(); + } + + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CodeSuggestions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CodeSuggestions(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeSuggestions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ProgressIndicatorOrBuilder extends + // @@protoc_insertion_point(interface_extends:ProgressIndicator) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 progress = 1; + */ + int getProgress(); + } + /** + * Protobuf type {@code ProgressIndicator} + */ + public static final class ProgressIndicator extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:ProgressIndicator) + ProgressIndicatorOrBuilder { + // Use ProgressIndicator.newBuilder() to construct. + private ProgressIndicator(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ProgressIndicator() { + progress_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ProgressIndicator( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + progress_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_ProgressIndicator_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_ProgressIndicator_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.Builder.class); + } + + public static final int PROGRESS_FIELD_NUMBER = 1; + private int progress_; + /** + * optional int32 progress = 1; + */ + public int getProgress() { + return progress_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (progress_ != 0) { + output.writeInt32(1, progress_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (progress_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, progress_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code ProgressIndicator} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:ProgressIndicator) + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicatorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_ProgressIndicator_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_ProgressIndicator_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.Builder.class); + } + + // Construct using org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + progress_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_ProgressIndicator_descriptor; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator getDefaultInstanceForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.getDefaultInstance(); + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator build() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator buildPartial() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator result = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator(this); + result.progress_ = progress_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator) { + return mergeFrom((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator other) { + if (other == org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator.getDefaultInstance()) return this; + if (other.getProgress() != 0) { + setProgress(other.getProgress()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int progress_ ; + /** + * optional int32 progress = 1; + */ + public int getProgress() { + return progress_; + } + /** + * optional int32 progress = 1; + */ + public Builder setProgress(int value) { + + progress_ = value; + onChanged(); + return this; + } + /** + * optional int32 progress = 1; + */ + public Builder clearProgress() { + + progress_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:ProgressIndicator) + } + + // @@protoc_insertion_point(class_scope:ProgressIndicator) + private static final org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator(); + } + + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ProgressIndicator parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ProgressIndicator(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.ProgressIndicator getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface VoidOrBuilder extends + // @@protoc_insertion_point(interface_extends:Void) + com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code Void} + */ + public static final class Void extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Void) + VoidOrBuilder { + // Use Void.newBuilder() to construct. + private Void(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Void() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Void( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_Void_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_Void_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.Builder.class); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Void} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Void) + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.VoidOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_Void_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_Void_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.class, org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.Builder.class); + } + + // Construct using org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.internal_static_Void_descriptor; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void getDefaultInstanceForType() { + return org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.getDefaultInstance(); + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void build() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void buildPartial() { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void result = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void) { + return mergeFrom((org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void other) { + if (other == org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void.getDefaultInstance()) return this; + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:Void) + } + + // @@protoc_insertion_point(class_scope:Void) + private static final org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void(); + } + + public static org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Void parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Void(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_CodeInterpreteRequest_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_CodeInterpreteRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_InterpetedResult_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_InterpetedResult_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_CodeCompletionRequest_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_CodeCompletionRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_CodeSuggestions_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_CodeSuggestions_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_ProgressIndicator_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_ProgressIndicator_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_Void_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_Void_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\030python_interpreter.proto\"5\n\025CodeInterp" + + "reteRequest\022\014\n\004code\030\001 \001(\t\022\016\n\006noteId\030\002 \001(" + + "\t\"2\n\020InterpetedResult\022\016\n\006output\030\001 \001(\t\022\016\n" + + "\006status\030\002 \001(\t\"(\n\025CodeCompletionRequest\022\017" + + "\n\007context\030\001 \001(\t\"&\n\017CodeSuggestions\022\023\n\013su" + + "ggestions\030\001 \003(\t\"%\n\021ProgressIndicator\022\020\n\010" + + "progress\030\001 \001(\005\"\006\n\004Void2\307\001\n\021PythonInterpr" + + "eter\0227\n\nInterprete\022\026.CodeInterpreteReque" + + "st\032\021.InterpetedResult\0228\n\014AutoComplete\022\026." + + "CodeCompletionRequest\032\020.CodeSuggestions\022", + "%\n\010Progress\022\005.Void\032\022.ProgressIndicator\022\030" + + "\n\010Shutdown\022\005.Void\032\005.VoidB!\n\037org.apache.z" + + "eppelin.python2.rpcb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_CodeInterpreteRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_CodeInterpreteRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_CodeInterpreteRequest_descriptor, + new java.lang.String[] { "Code", "NoteId", }); + internal_static_InterpetedResult_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_InterpetedResult_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_InterpetedResult_descriptor, + new java.lang.String[] { "Output", "Status", }); + internal_static_CodeCompletionRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_CodeCompletionRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_CodeCompletionRequest_descriptor, + new java.lang.String[] { "Context", }); + internal_static_CodeSuggestions_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_CodeSuggestions_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_CodeSuggestions_descriptor, + new java.lang.String[] { "Suggestions", }); + internal_static_ProgressIndicator_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_ProgressIndicator_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_ProgressIndicator_descriptor, + new java.lang.String[] { "Progress", }); + internal_static_Void_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_Void_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Void_descriptor, + new java.lang.String[] { }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/python/src/main/resources/genrpc.sh b/python/src/main/resources/genrpc.sh new file mode 100755 index 00000000000..b190d35654e --- /dev/null +++ b/python/src/main/resources/genrpc.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +# +# Generates gRPC service stubs. +# +# Requires: +# - protoc +# * https://developers.google.com/protocol-buffers/docs/downloads +# * or `brew instsall protobuff` +# - gprc plugin for protoc is installed +# * git checkout git clone git@github.com:grpc/grpc-java.git google-grpc-java +# * cd google-grpc-java/compiler +# * ../gradlew java_pluginExecutable +# * export GRPC_PLUGIN="$(pwd)" +# - python grpcio-tool installed +# * http://www.grpc.io/docs/tutorials/basic/python.html#generating-client-and-server-code +# * pip install grpcio-tools + + +E_BAD_CONFIG=-1 +E_FAIL_COMPILE=-2 +E_BAD_GRPC_JAVA=-3 +E_BAD_GRPC_PY=-4 + +if ! $(hash 'protoc' 2>/dev/null) ; then + echo "Please install protobuff compiler + grpc-java plugin" + exit "${E_BAD_GRPC_JAVA}" +fi + +if [[ -z "${GRPC_PLUGIN}" ]]; then + echo "Please set env var GRPC_PLUGIN poining to grpc-java protoc compiler plugin" + exit "${E_BAD_CONFIG}" +fi + +if ! $(python -m grpc.tools.protoc 2>/dev/null) ; then + echo "Please install 'grpcio-tools' Python package" + exit "${E_BAD_GRPC_PY}" +fi + +java_out="./gen-java" +rm -rf "${java_out}" +rm -rf ../java/org/apache/zeppelin/python2/rpc +mkdir "${java_out}" + +echo "Generating Java code" +protoc --java_out="${java_out}" --grpc-java_out="${java_out}" \ + --plugin=protoc-gen-grpc-java="${GRPC_PLUGIN}/build/exe/java_plugin/protoc-gen-grpc-java" \ + python_interpreter.proto +if [[ "$?" -ne 0 ]]; then + echo "GRPC code generation for Java failed" >&2 + exit "${E_FAIL_COMPILE}" +fi + +for file in "${java_out}"/org/apache/zeppelin/python2/rpc/* ; do + echo "Adding ASF License header to ${file}" + cat ../../../../zeppelin-interpreter/src/main/thrift/java_license_header.txt ${file} > ${file}.tmp + mv -f ${file}.tmp ${file} +done +mv "${java_out}"/org/apache/zeppelin/python2/rpc ../java/org/apache/zeppelin/python2/rpc +rm -rf gen-java + +find . -name "*_pb2.py" -exec rm -rf {} \; +echo "Generating Python code" +python -m grpc.tools.protoc -I./ --python_out=. --grpc_python_out=. ./python_interpreter.proto +for file in $(find . -name '*_pb2.py'); do + echo "Adding ASF License header to ${file}" + cat python_license_header.txt ${file} > ${file}.tmp + mv -f ${file}.tmp ${file} +done + diff --git a/python/src/main/resources/interpreter-setting.json b/python/src/main/resources/interpreter-setting.json index d3df586defd..0afb8ce8cf4 100644 --- a/python/src/main/resources/interpreter-setting.json +++ b/python/src/main/resources/interpreter-setting.json @@ -26,5 +26,24 @@ "name": "sql", "className": "org.apache.zeppelin.python.PythonInterpreterPandasSql", "properties": { } + }, + { + "group": "python2", + "name": "python2", + "className": "org.apache.zeppelin.python2.PythonInterpreter2", + "properties": { + "zeppelin.python": { + "envName": null, + "propertyName": "zeppelin.python2", + "defaultValue": "python", + "description": "Python directory. It is set to python by default.(assume python is in your $PATH)" + }, + "zeppelin.python2.maxResult": { + "envName": null, + "propertyName": "zeppelin.python.maxResult", + "defaultValue": "1000", + "description": "Max number of dataframe rows to display." + } + } } ] diff --git a/python/src/main/resources/interpreter.py b/python/src/main/resources/interpreter.py new file mode 100755 index 00000000000..5bb4b1cde5d --- /dev/null +++ b/python/src/main/resources/interpreter.py @@ -0,0 +1,232 @@ +#!/usr/bin/env python +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +"""Python interpreter exposed though gRPC server""" + +import sys +import time +import argparse +import traceback + + +from cStringIO import StringIO #TODO python3 compatibility! i.e `import io` + +import python_interpreter_pb2 + +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 +_NOTE_GLOBALS = "{}_globals" + +def help(): + print("""%html +

Python Interpreter help

+

Python 2 & 3 compatibility

+

The interpreter is compatible with Python 2 & 3.
+ To change Python version, + change in the interpreter configuration the python to the + desired version (example : python=/usr/bin/python3)

+

Python modules

+

The interpreter can use all modules already installed + (with pip, easy_install, etc)

+ +

Forms

+ You must install py4j in order to use + the form feature (pip install py4j) + +

Input form

+
print (z.input("f1","defaultValue"))
+

Selection form

+
print(z.select("f2", [("o1","1"), ("o2","2")],2))
+

Checkbox form

+
 print("".join(z.checkbox("f3", [("o1","1"), ("o2","2")],["1"])))
') + +

Matplotlib graph

+
The interpreter can display matplotlib graph with + the function z.show()
+
You need to already have matplotlib module installed + to use this functionality !

+
import matplotlib.pyplot as plt
+ plt.figure()
+ (.. ..)
+ z.show(plt)
+ plt.close()
+ 
+

z.show function can take optional parameters + to adapt graph width and height
+
example : +
z.show(plt,width='50px
+ z.show(plt,height='150px') 
+ +

Pandas DataFrame

+
You need to have Pandas module installed + to use this functionality (pip install pandas) !

+
The interpreter can visualize Pandas DataFrame + with the function z.show() +
+ import pandas as pd
+ df = pd.read_csv("bank.csv", sep=";")
+ z.show(df)
+ 
+ +

SQL over Pandas DataFrame

+
You need to have Pandas&Pandasql modules installed + to use this functionality (pip install pandas pandasql) !

+ +
Python interpreter group includes %sql interpreter that can query + Pandas DataFrames using SQL and visualize results using Zeppelin Table Display System + +
+ %python
+ import pandas as pd
+ df = pd.read_csv("bank.csv", sep=";")
+ 
+
+
+ %python.sql
+ %sql
+ SELECT * from df LIMIT 5
+ 
+
+ """) + +def _check_port_range(value): + """Checks portnumber to be [0, 65536]""" + ival = int(value) + if ival < 0 or ival > 65536: + raise argparse.ArgumentTypeError( + "{} is an invalid port number. Use 0-65536".format(value)) + return ival + +class InterpreterError(Exception): + def __init__(self, error_class, line_number, details): + self.error_class = error_class + self.line_number = line_number + self.details = details + +class PythonInterpreterServicer(python_interpreter_pb2.BetaPythonInterpreterServicer): + """Implementing the servicer interface generated from our service definition + with functions that perform the actual "work" of the service. + """ + + def __init__(self): + pass + + def do_exec(self, code, note_id): + """Executes give python string in same environment + + Uses exec() to run the code. In order to report the + results\output, temroray replaces stdout. + + Args: + code: string of Python code + + Returns: + String that is stdout, a side-effect for the executed code + + Rises: + InterpreterError: an error with specific line number + """ + old_stdout = sys.stdout + #TODO python3 compatibility! i.e io.BytesIO() + redirected_output = sys.stdout = StringIO() + try: + #compile(code)? + gdict = _get_globals_or_default(note_id) + exec(code, gdict, gdict) + globals()[_NOTE_GLOBALS.format(note_id)] = gdict + #execfile()? + sys.stdout = old_stdout + except SyntaxError as err: + sys.stdout = old_stdout + error_class = err.__class__.__name__ + details = err.args[0] + line_number = err.lineno + except Exception as err: + sys.stdout = old_stdout + error_class = err.__class__.__name__ + details = err.args[0] + cl, exc, tb = sys.exc_info() + line_number = traceback.extract_tb(tb)[-1][1] + else: + return redirected_output + print("{} at line {}: {}".format(error_class, line_number, details)) + raise InterpreterError(error_class, line_number, details) + + def Interprete(self, request, context): #CodeInterpreteRequest + print("Got \n```\n{}\n```\nfrom noteID '{}'".format(request.code, request.noteId)) + out = "" + try: + #_debug_print_note_locals_globals("Before", request.noteId) + out = self.do_exec(request.code, request.noteId); + #_debug_print_note_locals_globals("After", request.noteId) + except InterpreterError as e: + out = "{} at line {}:\n{}".format(e.error_class, e.line_number, e.details) + return python_interpreter_pb2.InterpetedResult(output=out, status="fail") + print("Success!") + output = out.getvalue() + out.flush() + return python_interpreter_pb2.InterpetedResult(output=output, status="success") + + def Shutdown(self, void, context): + print("Shuting down Python process") + #TODO(bzz): make main exit i.e \w signal.SIGINT + #return python_interpreter_pb2.Void() + +def _get_globals_or_default(note_id, default={}): + key = _NOTE_GLOBALS.format(note_id) + return globals()[key] if key in globals() else default + +def _debug_print_note_locals_globals(when, note_id): + print("{} globals() {}: {}".format(note_id, when, _get_globals_or_default(note_id))) + + +def main(): + parser = argparse.ArgumentParser( + description='Expose python interpreter as gRPC service.') + parser.add_argument('port', type=_check_port_range, + help='Port number to run the sGRC server') + + args = parser.parse_args() + print("Starting gRPC server on {}".format(args.port)) + + # Run a gRPC server to listen for requests from clients and transmit responses + server = python_interpreter_pb2.beta_create_PythonInterpreter_server(PythonInterpreterServicer()) + server.add_insecure_port('[::]:{}'.format(args.port)) + server.start() + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + server.stop(0) + + +if __name__ == '__main__': + main() + + + + +""" +def serve(port, sleep_time): + server = python_interpreter_pb2.beta_create_PythonInterpreter_server(PythonInterpreterServicer()) + server.add_insecure_port('[::]:{}'.format(port)) + server.start() + try: + while True: + time.sleep(sleep_time) + except KeyboardInterrupt: + server.stop(0) +""" diff --git a/python/src/main/resources/python_interpreter.proto b/python/src/main/resources/python_interpreter.proto new file mode 100644 index 00000000000..d066c72e29c --- /dev/null +++ b/python/src/main/resources/python_interpreter.proto @@ -0,0 +1,63 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +syntax = "proto3"; +option java_package = "org.apache.zeppelin.python2.rpc"; + + +service PythonInterpreter { + + // Blocking RPC to interpreter pice of code + // + // + rpc Interprete (CodeInterpreteRequest) returns (InterpetedResult); + + rpc AutoComplete (CodeCompletionRequest) returns (CodeSuggestions); + rpc Progress (Void) returns (ProgressIndicator); + + // Terminates this RPC Server python process + rpc Shutdown (Void) returns (Void); + + //TODO(bzz): + // log (stderr) streaming? + // result streaming? What is result in TensorFlow? +} + +message CodeInterpreteRequest { + string code = 1; + string noteId = 2; +} + +message InterpetedResult { + string output = 1; + string status = 2; //TODO(bzz) replace \w enum +} + +message CodeCompletionRequest { + string context = 1; +} +message CodeSuggestions { + repeated string suggestions=1; +} + +message ProgressIndicator { + int32 progress = 1; +} + +message Void { +} \ No newline at end of file diff --git a/python/src/main/resources/python_interpreter_pb2.py b/python/src/main/resources/python_interpreter_pb2.py new file mode 100644 index 00000000000..0fd158ddd14 --- /dev/null +++ b/python/src/main/resources/python_interpreter_pb2.py @@ -0,0 +1,465 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: python_interpreter.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='python_interpreter.proto', + package='', + syntax='proto3', + serialized_pb=_b('\n\x18python_interpreter.proto\"5\n\x15\x43odeInterpreteRequest\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\x12\x0e\n\x06noteId\x18\x02 \x01(\t\"2\n\x10InterpetedResult\x12\x0e\n\x06output\x18\x01 \x01(\t\x12\x0e\n\x06status\x18\x02 \x01(\t\"(\n\x15\x43odeCompletionRequest\x12\x0f\n\x07\x63ontext\x18\x01 \x01(\t\"&\n\x0f\x43odeSuggestions\x12\x13\n\x0bsuggestions\x18\x01 \x03(\t\"%\n\x11ProgressIndicator\x12\x10\n\x08progress\x18\x01 \x01(\x05\"\x06\n\x04Void2\xc7\x01\n\x11PythonInterpreter\x12\x37\n\nInterprete\x12\x16.CodeInterpreteRequest\x1a\x11.InterpetedResult\x12\x38\n\x0c\x41utoComplete\x12\x16.CodeCompletionRequest\x1a\x10.CodeSuggestions\x12%\n\x08Progress\x12\x05.Void\x1a\x12.ProgressIndicator\x12\x18\n\x08Shutdown\x12\x05.Void\x1a\x05.VoidB!\n\x1forg.apache.zeppelin.python2.rpcb\x06proto3') +) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + + + + +_CODEINTERPRETEREQUEST = _descriptor.Descriptor( + name='CodeInterpreteRequest', + full_name='CodeInterpreteRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='code', full_name='CodeInterpreteRequest.code', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='noteId', full_name='CodeInterpreteRequest.noteId', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=28, + serialized_end=81, +) + + +_INTERPETEDRESULT = _descriptor.Descriptor( + name='InterpetedResult', + full_name='InterpetedResult', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='output', full_name='InterpetedResult.output', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='status', full_name='InterpetedResult.status', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=83, + serialized_end=133, +) + + +_CODECOMPLETIONREQUEST = _descriptor.Descriptor( + name='CodeCompletionRequest', + full_name='CodeCompletionRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='context', full_name='CodeCompletionRequest.context', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=135, + serialized_end=175, +) + + +_CODESUGGESTIONS = _descriptor.Descriptor( + name='CodeSuggestions', + full_name='CodeSuggestions', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='suggestions', full_name='CodeSuggestions.suggestions', index=0, + number=1, type=9, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=177, + serialized_end=215, +) + + +_PROGRESSINDICATOR = _descriptor.Descriptor( + name='ProgressIndicator', + full_name='ProgressIndicator', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='progress', full_name='ProgressIndicator.progress', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=217, + serialized_end=254, +) + + +_VOID = _descriptor.Descriptor( + name='Void', + full_name='Void', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=256, + serialized_end=262, +) + +DESCRIPTOR.message_types_by_name['CodeInterpreteRequest'] = _CODEINTERPRETEREQUEST +DESCRIPTOR.message_types_by_name['InterpetedResult'] = _INTERPETEDRESULT +DESCRIPTOR.message_types_by_name['CodeCompletionRequest'] = _CODECOMPLETIONREQUEST +DESCRIPTOR.message_types_by_name['CodeSuggestions'] = _CODESUGGESTIONS +DESCRIPTOR.message_types_by_name['ProgressIndicator'] = _PROGRESSINDICATOR +DESCRIPTOR.message_types_by_name['Void'] = _VOID + +CodeInterpreteRequest = _reflection.GeneratedProtocolMessageType('CodeInterpreteRequest', (_message.Message,), dict( + DESCRIPTOR = _CODEINTERPRETEREQUEST, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:CodeInterpreteRequest) + )) +_sym_db.RegisterMessage(CodeInterpreteRequest) + +InterpetedResult = _reflection.GeneratedProtocolMessageType('InterpetedResult', (_message.Message,), dict( + DESCRIPTOR = _INTERPETEDRESULT, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:InterpetedResult) + )) +_sym_db.RegisterMessage(InterpetedResult) + +CodeCompletionRequest = _reflection.GeneratedProtocolMessageType('CodeCompletionRequest', (_message.Message,), dict( + DESCRIPTOR = _CODECOMPLETIONREQUEST, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:CodeCompletionRequest) + )) +_sym_db.RegisterMessage(CodeCompletionRequest) + +CodeSuggestions = _reflection.GeneratedProtocolMessageType('CodeSuggestions', (_message.Message,), dict( + DESCRIPTOR = _CODESUGGESTIONS, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:CodeSuggestions) + )) +_sym_db.RegisterMessage(CodeSuggestions) + +ProgressIndicator = _reflection.GeneratedProtocolMessageType('ProgressIndicator', (_message.Message,), dict( + DESCRIPTOR = _PROGRESSINDICATOR, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:ProgressIndicator) + )) +_sym_db.RegisterMessage(ProgressIndicator) + +Void = _reflection.GeneratedProtocolMessageType('Void', (_message.Message,), dict( + DESCRIPTOR = _VOID, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:Void) + )) +_sym_db.RegisterMessage(Void) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\037org.apache.zeppelin.python2.rpc')) +import grpc +from grpc.beta import implementations as beta_implementations +from grpc.beta import interfaces as beta_interfaces +from grpc.framework.common import cardinality +from grpc.framework.interfaces.face import utilities as face_utilities + + +class PythonInterpreterStub(object): + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.Interprete = channel.unary_unary( + '/PythonInterpreter/Interprete', + request_serializer=CodeInterpreteRequest.SerializeToString, + response_deserializer=InterpetedResult.FromString, + ) + self.AutoComplete = channel.unary_unary( + '/PythonInterpreter/AutoComplete', + request_serializer=CodeCompletionRequest.SerializeToString, + response_deserializer=CodeSuggestions.FromString, + ) + self.Progress = channel.unary_unary( + '/PythonInterpreter/Progress', + request_serializer=Void.SerializeToString, + response_deserializer=ProgressIndicator.FromString, + ) + self.Shutdown = channel.unary_unary( + '/PythonInterpreter/Shutdown', + request_serializer=Void.SerializeToString, + response_deserializer=Void.FromString, + ) + + +class PythonInterpreterServicer(object): + + def Interprete(self, request, context): + """Blocking RPC to interpreter pice of code + + + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def AutoComplete(self, request, context): + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Progress(self, request, context): + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Shutdown(self, request, context): + """Terminates this RPC Server python process + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_PythonInterpreterServicer_to_server(servicer, server): + rpc_method_handlers = { + 'Interprete': grpc.unary_unary_rpc_method_handler( + servicer.Interprete, + request_deserializer=CodeInterpreteRequest.FromString, + response_serializer=InterpetedResult.SerializeToString, + ), + 'AutoComplete': grpc.unary_unary_rpc_method_handler( + servicer.AutoComplete, + request_deserializer=CodeCompletionRequest.FromString, + response_serializer=CodeSuggestions.SerializeToString, + ), + 'Progress': grpc.unary_unary_rpc_method_handler( + servicer.Progress, + request_deserializer=Void.FromString, + response_serializer=ProgressIndicator.SerializeToString, + ), + 'Shutdown': grpc.unary_unary_rpc_method_handler( + servicer.Shutdown, + request_deserializer=Void.FromString, + response_serializer=Void.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'PythonInterpreter', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + +class BetaPythonInterpreterServicer(object): + def Interprete(self, request, context): + """Blocking RPC to interpreter pice of code + + + """ + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + def AutoComplete(self, request, context): + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + def Progress(self, request, context): + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + def Shutdown(self, request, context): + """Terminates this RPC Server python process + """ + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + + +class BetaPythonInterpreterStub(object): + def Interprete(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + """Blocking RPC to interpreter pice of code + + + """ + raise NotImplementedError() + Interprete.future = None + def AutoComplete(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + raise NotImplementedError() + AutoComplete.future = None + def Progress(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + raise NotImplementedError() + Progress.future = None + def Shutdown(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + """Terminates this RPC Server python process + """ + raise NotImplementedError() + Shutdown.future = None + + +def beta_create_PythonInterpreter_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): + request_deserializers = { + ('PythonInterpreter', 'AutoComplete'): CodeCompletionRequest.FromString, + ('PythonInterpreter', 'Interprete'): CodeInterpreteRequest.FromString, + ('PythonInterpreter', 'Progress'): Void.FromString, + ('PythonInterpreter', 'Shutdown'): Void.FromString, + } + response_serializers = { + ('PythonInterpreter', 'AutoComplete'): CodeSuggestions.SerializeToString, + ('PythonInterpreter', 'Interprete'): InterpetedResult.SerializeToString, + ('PythonInterpreter', 'Progress'): ProgressIndicator.SerializeToString, + ('PythonInterpreter', 'Shutdown'): Void.SerializeToString, + } + method_implementations = { + ('PythonInterpreter', 'AutoComplete'): face_utilities.unary_unary_inline(servicer.AutoComplete), + ('PythonInterpreter', 'Interprete'): face_utilities.unary_unary_inline(servicer.Interprete), + ('PythonInterpreter', 'Progress'): face_utilities.unary_unary_inline(servicer.Progress), + ('PythonInterpreter', 'Shutdown'): face_utilities.unary_unary_inline(servicer.Shutdown), + } + server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) + return beta_implementations.server(method_implementations, options=server_options) + + +def beta_create_PythonInterpreter_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): + request_serializers = { + ('PythonInterpreter', 'AutoComplete'): CodeCompletionRequest.SerializeToString, + ('PythonInterpreter', 'Interprete'): CodeInterpreteRequest.SerializeToString, + ('PythonInterpreter', 'Progress'): Void.SerializeToString, + ('PythonInterpreter', 'Shutdown'): Void.SerializeToString, + } + response_deserializers = { + ('PythonInterpreter', 'AutoComplete'): CodeSuggestions.FromString, + ('PythonInterpreter', 'Interprete'): InterpetedResult.FromString, + ('PythonInterpreter', 'Progress'): ProgressIndicator.FromString, + ('PythonInterpreter', 'Shutdown'): Void.FromString, + } + cardinalities = { + 'AutoComplete': cardinality.Cardinality.UNARY_UNARY, + 'Interprete': cardinality.Cardinality.UNARY_UNARY, + 'Progress': cardinality.Cardinality.UNARY_UNARY, + 'Shutdown': cardinality.Cardinality.UNARY_UNARY, + } + stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) + return beta_implementations.dynamic_stub(channel, 'PythonInterpreter', cardinalities, options=stub_options) +# @@protoc_insertion_point(module_scope) diff --git a/python/src/main/resources/python_license_header.txt b/python/src/main/resources/python_license_header.txt new file mode 100644 index 00000000000..ae0098691d2 --- /dev/null +++ b/python/src/main/resources/python_license_header.txt @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java index d819869f8fd..de655c2cefd 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java @@ -524,6 +524,7 @@ public static enum ConfVars { + "org.apache.zeppelin.flink.FlinkInterpreter," + "org.apache.zeppelin.python.PythonInterpreter," + "org.apache.zeppelin.python.PythonInterpreterPandasSql," + + "org.apache.zeppelin.python2.PythonInterpreter2," + "org.apache.zeppelin.ignite.IgniteInterpreter," + "org.apache.zeppelin.ignite.IgniteSqlInterpreter," + "org.apache.zeppelin.lens.LensInterpreter,"