From de1caa5c49d336d3afaad2304eb52081fbeea9e2 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Wed, 10 Aug 2016 13:26:50 +0900 Subject: [PATCH 1/7] Add DRAFT of .proto, generated files and an automation script --- .gitignore | 3 + .../zeppelin/python2/PythonInterpreter2.java | 154 +++ .../python2/PythonInterpreterGrpc.java | 334 ++++++ .../python2/PythonInterpreterOuterClass.java | 961 ++++++++++++++++++ python/src/main/resources/genrpc.sh | 48 + .../main/resources/python_interpreter.proto | 31 + .../main/resources/python_interpreter_pb2.py | 188 ++++ 7 files changed, 1719 insertions(+) create mode 100644 python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java create mode 100644 python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java create mode 100644 python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java create mode 100755 python/src/main/resources/genrpc.sh create mode 100644 python/src/main/resources/python_interpreter.proto create mode 100644 python/src/main/resources/python_interpreter_pb2.py 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/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..277a7a57f55 --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -0,0 +1,154 @@ +/* +* 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 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.scheduler.Scheduler; +import org.apache.zeppelin.scheduler.SchedulerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Python interpreter for Zeppelin. + */ +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; + + 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)); + + //pick open serverPort + //start gRPC server ./interpreter.py on serverPort + //connect to it + } + + @Override + public void close() { + LOG.info("closing Python interpreter ....."); +// 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 output = sendCommandToPython(cmd); + + InterpreterResult result; + if (pythonErrorIn(output)) { + result = new InterpreterResult(Code.ERROR, output); + } else { + result = new InterpreterResult(Code.SUCCESS, output); + } + return result; + } + + @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()); + } + + /** + * Checks if there is a syntax error or an exception + * + * @param output Python interpreter output + * @return true if syntax error or exception has happened + */ + private boolean pythonErrorIn(String output) { + return false; + } + + /** + * Sends given text to Python interpreter + * + * @param cmd Python expression text + * @return output + */ + String sendCommandToPython(String cmd) { + LOG.debug("Sending : \n" + (cmd.length() > 200 ? cmd.substring(0, 200) + "..." : cmd)); + String output = ""; +// output = ...(cmd); +// LOG.error("Error when sending commands to python process", e); + LOG.debug("Got : \n" + output); + return output; + } + + 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/PythonInterpreterGrpc.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java new file mode 100644 index 00000000000..54cdbb9b134 --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java @@ -0,0 +1,334 @@ +package org.apache.zeppelin.python2; + +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(PythonInterpreterOuterClass.CodeRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(PythonInterpreterOuterClass.InterpetedResult.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 { + + /** + */ + @java.lang.Override + public void interprete(PythonInterpreterOuterClass.CodeRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_INTERPRETE, responseObserver); + } + + @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + METHOD_INTERPRETE, + asyncUnaryCall( + new MethodHandlers< + PythonInterpreterOuterClass.CodeRequest, + PythonInterpreterOuterClass.InterpetedResult>( + this, METHODID_INTERPRETE))) + .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); + } + + /** + */ + @java.lang.Override + public void interprete(PythonInterpreterOuterClass.CodeRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_INTERPRETE, 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); + } + + /** + */ + @java.lang.Override + public PythonInterpreterOuterClass.InterpetedResult interprete(PythonInterpreterOuterClass.CodeRequest request) { + return blockingUnaryCall( + getChannel(), METHOD_INTERPRETE, 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); + } + + /** + */ + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture interprete( + PythonInterpreterOuterClass.CodeRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_INTERPRETE, 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(PythonInterpreterOuterClass.CodeRequest 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 PythonInterpreterOuterClass.InterpetedResult interprete(PythonInterpreterOuterClass.CodeRequest 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( + PythonInterpreterOuterClass.CodeRequest 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< + PythonInterpreterOuterClass.CodeRequest, + PythonInterpreterOuterClass.InterpetedResult>( + serviceImpl, METHODID_INTERPRETE))) + .build(); + } + + private static final int METHODID_INTERPRETE = 0; + + 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((PythonInterpreterOuterClass.CodeRequest) 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); + } + +} diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java new file mode 100644 index 00000000000..5ab51767d6c --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java @@ -0,0 +1,961 @@ +package org.apache.zeppelin.python2; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: python_interpreter.proto + +public final class PythonInterpreterOuterClass { + private PythonInterpreterOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface CodeRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:CodeRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string code = 1; + */ + java.lang.String getCode(); + /** + * optional string code = 1; + */ + com.google.protobuf.ByteString + getCodeBytes(); + } + /** + * Protobuf type {@code CodeRequest} + */ + public static final class CodeRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:CodeRequest) + CodeRequestOrBuilder { + // Use CodeRequest.newBuilder() to construct. + private CodeRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CodeRequest() { + code_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CodeRequest( + 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; + } + } + } + } 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 PythonInterpreterOuterClass.internal_static_CodeRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return PythonInterpreterOuterClass.internal_static_CodeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + PythonInterpreterOuterClass.CodeRequest.class, PythonInterpreterOuterClass.CodeRequest.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; + } + } + + 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_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, code_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static PythonInterpreterOuterClass.CodeRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static PythonInterpreterOuterClass.CodeRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static PythonInterpreterOuterClass.CodeRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static PythonInterpreterOuterClass.CodeRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static PythonInterpreterOuterClass.CodeRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static PythonInterpreterOuterClass.CodeRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static PythonInterpreterOuterClass.CodeRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static PythonInterpreterOuterClass.CodeRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static PythonInterpreterOuterClass.CodeRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static PythonInterpreterOuterClass.CodeRequest 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(PythonInterpreterOuterClass.CodeRequest 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 CodeRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:CodeRequest) + PythonInterpreterOuterClass.CodeRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return PythonInterpreterOuterClass.internal_static_CodeRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return PythonInterpreterOuterClass.internal_static_CodeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + PythonInterpreterOuterClass.CodeRequest.class, PythonInterpreterOuterClass.CodeRequest.Builder.class); + } + + // Construct using PythonInterpreterOuterClass.CodeRequest.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_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return PythonInterpreterOuterClass.internal_static_CodeRequest_descriptor; + } + + public PythonInterpreterOuterClass.CodeRequest getDefaultInstanceForType() { + return PythonInterpreterOuterClass.CodeRequest.getDefaultInstance(); + } + + public PythonInterpreterOuterClass.CodeRequest build() { + PythonInterpreterOuterClass.CodeRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public PythonInterpreterOuterClass.CodeRequest buildPartial() { + PythonInterpreterOuterClass.CodeRequest result = new PythonInterpreterOuterClass.CodeRequest(this); + result.code_ = code_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof PythonInterpreterOuterClass.CodeRequest) { + return mergeFrom((PythonInterpreterOuterClass.CodeRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(PythonInterpreterOuterClass.CodeRequest other) { + if (other == PythonInterpreterOuterClass.CodeRequest.getDefaultInstance()) return this; + if (!other.getCode().isEmpty()) { + code_ = other.code_; + 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 { + PythonInterpreterOuterClass.CodeRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (PythonInterpreterOuterClass.CodeRequest) 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; + } + 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:CodeRequest) + } + + // @@protoc_insertion_point(class_scope:CodeRequest) + private static final PythonInterpreterOuterClass.CodeRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new PythonInterpreterOuterClass.CodeRequest(); + } + + public static PythonInterpreterOuterClass.CodeRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CodeRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CodeRequest(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 PythonInterpreterOuterClass.CodeRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface InterpetedResultOrBuilder extends + // @@protoc_insertion_point(interface_extends:InterpetedResult) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string result = 1; + */ + java.lang.String getResult(); + /** + * optional string result = 1; + */ + com.google.protobuf.ByteString + getResultBytes(); + } + /** + * 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() { + result_ = ""; + } + + @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(); + + result_ = 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 PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return PythonInterpreterOuterClass.internal_static_InterpetedResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + PythonInterpreterOuterClass.InterpetedResult.class, PythonInterpreterOuterClass.InterpetedResult.Builder.class); + } + + public static final int RESULT_FIELD_NUMBER = 1; + private volatile java.lang.Object result_; + /** + * optional string result = 1; + */ + public java.lang.String getResult() { + java.lang.Object ref = result_; + 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(); + result_ = s; + return s; + } + } + /** + * optional string result = 1; + */ + public com.google.protobuf.ByteString + getResultBytes() { + java.lang.Object ref = result_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + result_ = 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 (!getResultBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, result_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getResultBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, result_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static PythonInterpreterOuterClass.InterpetedResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static 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 PythonInterpreterOuterClass.InterpetedResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static PythonInterpreterOuterClass.InterpetedResult parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static PythonInterpreterOuterClass.InterpetedResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static PythonInterpreterOuterClass.InterpetedResult parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static PythonInterpreterOuterClass.InterpetedResult parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static PythonInterpreterOuterClass.InterpetedResult parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static PythonInterpreterOuterClass.InterpetedResult parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static 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(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) + PythonInterpreterOuterClass.InterpetedResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return PythonInterpreterOuterClass.internal_static_InterpetedResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + PythonInterpreterOuterClass.InterpetedResult.class, PythonInterpreterOuterClass.InterpetedResult.Builder.class); + } + + // Construct using 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(); + result_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; + } + + public PythonInterpreterOuterClass.InterpetedResult getDefaultInstanceForType() { + return PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance(); + } + + public PythonInterpreterOuterClass.InterpetedResult build() { + PythonInterpreterOuterClass.InterpetedResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public PythonInterpreterOuterClass.InterpetedResult buildPartial() { + PythonInterpreterOuterClass.InterpetedResult result = new PythonInterpreterOuterClass.InterpetedResult(this); + result.result_ = result_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof PythonInterpreterOuterClass.InterpetedResult) { + return mergeFrom((PythonInterpreterOuterClass.InterpetedResult)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(PythonInterpreterOuterClass.InterpetedResult other) { + if (other == PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance()) return this; + if (!other.getResult().isEmpty()) { + result_ = other.result_; + 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 { + PythonInterpreterOuterClass.InterpetedResult parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (PythonInterpreterOuterClass.InterpetedResult) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object result_ = ""; + /** + * optional string result = 1; + */ + public java.lang.String getResult() { + java.lang.Object ref = result_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + result_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string result = 1; + */ + public com.google.protobuf.ByteString + getResultBytes() { + java.lang.Object ref = result_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + result_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string result = 1; + */ + public Builder setResult( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + result_ = value; + onChanged(); + return this; + } + /** + * optional string result = 1; + */ + public Builder clearResult() { + + result_ = getDefaultInstance().getResult(); + onChanged(); + return this; + } + /** + * optional string result = 1; + */ + public Builder setResultBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + result_ = 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 PythonInterpreterOuterClass.InterpetedResult DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new PythonInterpreterOuterClass.InterpetedResult(); + } + + public static 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 PythonInterpreterOuterClass.InterpetedResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_CodeRequest_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_CodeRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_InterpetedResult_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_InterpetedResult_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\"\033\n\013CodeReques" + + "t\022\014\n\004code\030\001 \001(\t\"\"\n\020InterpetedResult\022\016\n\006r" + + "esult\030\001 \001(\t2B\n\021PythonInterpreter\022-\n\nInte" + + "rprete\022\014.CodeRequest\032\021.InterpetedResultb" + + "\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_CodeRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_CodeRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_CodeRequest_descriptor, + new java.lang.String[] { "Code", }); + 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[] { "Result", }); + } + + // @@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..d224886196e --- /dev/null +++ b/python/src/main/resources/genrpc.sh @@ -0,0 +1,48 @@ +#!/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)" + +protoc --java_out=./ --grpc-java_out=./ \ + --plugin=protoc-gen-grpc-java="${GRPC_PLUGIN}/build/exe/java_plugin/protoc-gen-grpc-java" \ + python_interpreter.proto + +#TODO(alex) +# add licence headers to generated files +# move .py and .java files to appropriate locations + + +#rm -rf gen-java +#rm -rf ../java/org/apache/zeppelin/interpreter/thrift +#thrift --gen java RemoteInterpreterService.thrift +#for file in gen-java/org/apache/zeppelin/interpreter/thrift/* ; do +# cat java_license_header.txt ${file} > ${file}.tmp +# mv -f ${file}.tmp ${file} +#done +#mv gen-java/org/apache/zeppelin/interpreter/thrift ../java/org/apache/zeppelin/interpreter/thrift +#rm -rf gen-java diff --git a/python/src/main/resources/python_interpreter.proto b/python/src/main/resources/python_interpreter.proto new file mode 100644 index 00000000000..3bdebfb2f31 --- /dev/null +++ b/python/src/main/resources/python_interpreter.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +option java_package = "io.grpc.examples.routeguide"; + + +service PythonInterpreter { + + // Blocking RPC to interpreter pice of code + // + // + rpc Interprete (CodeInterpreteRequest) returns (InterpetedResult); + + rpc AutoComplete (CodeCompletionRequest) return (CodeSuggestions); + //rpc Progress ???? + + // Terminates this RPC Server python process + rpc Shutdown(); + + //TODO(bzz): + // log (stderr) streaming? + // result streaming? What is result in TensorFlow? +} + +message CodeRequest { + string code = 1; +} + +message InterpetedResult { + string result = 1; + //string output = 1; + //string status = 2; //should be enum +} 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..085ae00bba6 --- /dev/null +++ b/python/src/main/resources/python_interpreter_pb2.py @@ -0,0 +1,188 @@ +# 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\"\x1b\n\x0b\x43odeRequest\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\"\"\n\x10InterpetedResult\x12\x0e\n\x06result\x18\x01 \x01(\t2B\n\x11PythonInterpreter\x12-\n\nInterprete\x12\x0c.CodeRequest\x1a\x11.InterpetedResultb\x06proto3') +) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + + + + +_CODEREQUEST = _descriptor.Descriptor( + name='CodeRequest', + full_name='CodeRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='code', full_name='CodeRequest.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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=28, + serialized_end=55, +) + + +_INTERPETEDRESULT = _descriptor.Descriptor( + name='InterpetedResult', + full_name='InterpetedResult', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='result', full_name='InterpetedResult.result', 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=57, + serialized_end=91, +) + +DESCRIPTOR.message_types_by_name['CodeRequest'] = _CODEREQUEST +DESCRIPTOR.message_types_by_name['InterpetedResult'] = _INTERPETEDRESULT + +CodeRequest = _reflection.GeneratedProtocolMessageType('CodeRequest', (_message.Message,), dict( + DESCRIPTOR = _CODEREQUEST, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:CodeRequest) + )) +_sym_db.RegisterMessage(CodeRequest) + +InterpetedResult = _reflection.GeneratedProtocolMessageType('InterpetedResult', (_message.Message,), dict( + DESCRIPTOR = _INTERPETEDRESULT, + __module__ = 'python_interpreter_pb2' + # @@protoc_insertion_point(class_scope:InterpetedResult) + )) +_sym_db.RegisterMessage(InterpetedResult) + + +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=CodeRequest.SerializeToString, + response_deserializer=InterpetedResult.FromString, + ) + + +class PythonInterpreterServicer(object): + + def Interprete(self, request, context): + 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=CodeRequest.FromString, + response_serializer=InterpetedResult.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): + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + + +class BetaPythonInterpreterStub(object): + def Interprete(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + raise NotImplementedError() + Interprete.future = None + + +def beta_create_PythonInterpreter_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): + request_deserializers = { + ('PythonInterpreter', 'Interprete'): CodeRequest.FromString, + } + response_serializers = { + ('PythonInterpreter', 'Interprete'): InterpetedResult.SerializeToString, + } + method_implementations = { + ('PythonInterpreter', 'Interprete'): face_utilities.unary_unary_inline(servicer.Interprete), + } + 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', 'Interprete'): CodeRequest.SerializeToString, + } + response_deserializers = { + ('PythonInterpreter', 'Interprete'): InterpetedResult.FromString, + } + cardinalities = { + 'Interprete': 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) From 2a47c824865c2e5a645d1807f268440a71d9b2cf Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Wed, 10 Aug 2016 13:27:22 +0900 Subject: [PATCH 2/7] Add first DRAFT of Python Interpreter servier impl --- python/src/main/resources/interpreter.py | 158 +++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100755 python/src/main/resources/interpreter.py diff --git a/python/src/main/resources/interpreter.py b/python/src/main/resources/interpreter.py new file mode 100755 index 00000000000..8d44c6a6eaa --- /dev/null +++ b/python/src/main/resources/interpreter.py @@ -0,0 +1,158 @@ +#!/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 time +import argparse + +import python_interpreter_pb2 + +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 + +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 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 Interprete(self, code, context): #CodeRequest + #return InterpetedResult + return python_interpreter_pb2.InterpetedResult(result="") + pass + + +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) +""" From 08345debe06e59d6f73b29425eea24c2297ba32f Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Fri, 12 Aug 2016 19:05:16 +0900 Subject: [PATCH 3/7] Add first DRAFT of Python Interpreter client impl --- python/pom.xml | 28 +++++++ .../zeppelin/python2/PythonInterpreter2.java | 75 +++++++++++++------ .../main/resources/interpreter-setting.json | 19 +++++ .../zeppelin/conf/ZeppelinConfiguration.java | 1 + 4 files changed, 102 insertions(+), 21 deletions(-) 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 index 277a7a57f55..769a495b03d 100644 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -17,6 +17,10 @@ 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; @@ -27,6 +31,9 @@ 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.PythonInterpreterGrpc.PythonInterpreterBlockingStub; +import org.apache.zeppelin.python2.PythonInterpreterOuterClass.CodeRequest; +import org.apache.zeppelin.python2.PythonInterpreterOuterClass.InterpetedResult; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; import org.slf4j.Logger; @@ -34,6 +41,12 @@ /** * 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); @@ -45,6 +58,8 @@ public class PythonInterpreter2 extends Interpreter { private int maxResult; + private PythonInterpreterBlockingStub blockingStub; + public PythonInterpreter2(Properties property) { super(property); } @@ -54,14 +69,25 @@ 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 + + int serverPort = 9090; //pick open serverPort //start gRPC server ./interpreter.py on serverPort - //connect to it + + /**connect to gRPC server on serverPort*/ + ManagedChannelBuilder channelBuilder = ManagedChannelBuilder + .forAddress("localhost", serverPort) + .usePlaintext(true); + ManagedChannel channel = channelBuilder.build(); + blockingStub = PythonInterpreterGrpc.newBlockingStub(channel); } @Override public void close() { LOG.info("closing Python interpreter ....."); + //TODO(bzz): blockingStub.shutdown(); // LOG.error("Can't close the interpreter", e); } @@ -70,16 +96,7 @@ public InterpreterResult interpret(String cmd, InterpreterContext contextInterpr if (cmd == null || cmd.isEmpty()) { return new InterpreterResult(Code.SUCCESS, ""); } - - String output = sendCommandToPython(cmd); - - InterpreterResult result; - if (pythonErrorIn(output)) { - result = new InterpreterResult(Code.ERROR, output); - } else { - result = new InterpreterResult(Code.SUCCESS, output); - } - return result; + return sendCommandToPython(cmd); } @Override @@ -122,23 +139,39 @@ private boolean pythonErrorIn(String output) { /** * Sends given text to Python interpreter - * + * * @param cmd Python expression text * @return output */ - String sendCommandToPython(String cmd) { - LOG.debug("Sending : \n" + (cmd.length() > 200 ? cmd.substring(0, 200) + "..." : cmd)); - String output = ""; -// output = ...(cmd); -// LOG.error("Error when sending commands to python process", e); - LOG.debug("Got : \n" + output); - return output; + InterpreterResult sendCommandToPython(String code) { + LOG.debug("Sending : \n" + (code.length() > 200 ? code.substring(0, 200) + "..." : code)); + CodeRequest cmd = CodeRequest.newBuilder().setCode((code)).build(); + + InterpetedResult fromPythonProcess; + try { + fromPythonProcess = blockingStub.interprete(cmd); + } catch (StatusRuntimeException e) { + LOG.error("Error when sending commands to Python process", e); + return new InterpreterResult(Code.ERROR, "Failed to communicate to interpreter"); + } + InterpreterResult result; + if (gotSuccess(fromPythonProcess)) { + result = new InterpreterResult(Code.SUCCESS, fromPythonProcess.getResult()); + } else { + result = new InterpreterResult(Code.ERROR, fromPythonProcess.getResult()); + } + LOG.debug("Got : \n" + result); + return result; + } + + private static boolean gotSuccess(InterpetedResult result) { + return result != null; // && result.getStatus() is ...; } - public Boolean isPy4jInstalled() { + /*public Boolean isPy4jInstalled() { String output = sendCommandToPython("\n\nimport py4j\n"); return !output.contains("ImportError"); - } + }*/ private static int findRandomOpenPortOnAllLocalInterfaces() { Integer port = -1; 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/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," From d2a1e506e575dfaa15e8b41d048709457b211fbd Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Fri, 12 Aug 2016 22:28:29 +0900 Subject: [PATCH 4/7] Update .proto and code generation scripts --- .../zeppelin/python2/PythonInterpreter2.java | 23 +- .../python2/PythonInterpreterGrpc.java | 334 -- .../python2/PythonInterpreterOuterClass.java | 961 ------ .../python2/rpc/PythonInterpreterGrpc.java | 588 ++++ .../rpc/PythonInterpreterOuterClass.java | 2839 +++++++++++++++++ python/src/main/resources/genrpc.sh | 98 +- python/src/main/resources/interpreter.py | 11 +- .../main/resources/python_interpreter.proto | 47 +- .../main/resources/python_interpreter_pb2.py | 306 +- .../main/resources/python_license_header.txt | 16 + 10 files changed, 3851 insertions(+), 1372 deletions(-) delete mode 100644 python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java delete mode 100644 python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java create mode 100644 python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterGrpc.java create mode 100644 python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java create mode 100644 python/src/main/resources/python_license_header.txt diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java index 769a495b03d..b4494268bd0 100644 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -31,9 +31,10 @@ 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.PythonInterpreterGrpc.PythonInterpreterBlockingStub; -import org.apache.zeppelin.python2.PythonInterpreterOuterClass.CodeRequest; -import org.apache.zeppelin.python2.PythonInterpreterOuterClass.InterpetedResult; +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; @@ -127,16 +128,6 @@ public Scheduler getScheduler() { PythonInterpreter2.class.getName() + this.hashCode()); } - /** - * Checks if there is a syntax error or an exception - * - * @param output Python interpreter output - * @return true if syntax error or exception has happened - */ - private boolean pythonErrorIn(String output) { - return false; - } - /** * Sends given text to Python interpreter * @@ -145,7 +136,7 @@ private boolean pythonErrorIn(String output) { */ InterpreterResult sendCommandToPython(String code) { LOG.debug("Sending : \n" + (code.length() > 200 ? code.substring(0, 200) + "..." : code)); - CodeRequest cmd = CodeRequest.newBuilder().setCode((code)).build(); + CodeInterpreteRequest cmd = CodeInterpreteRequest.newBuilder().setCode((code)).build(); InterpetedResult fromPythonProcess; try { @@ -156,9 +147,9 @@ InterpreterResult sendCommandToPython(String code) { } InterpreterResult result; if (gotSuccess(fromPythonProcess)) { - result = new InterpreterResult(Code.SUCCESS, fromPythonProcess.getResult()); + result = new InterpreterResult(Code.SUCCESS, fromPythonProcess.getOutput()); } else { - result = new InterpreterResult(Code.ERROR, fromPythonProcess.getResult()); + result = new InterpreterResult(Code.ERROR, fromPythonProcess.getOutput()); } LOG.debug("Got : \n" + result); return result; diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java deleted file mode 100644 index 54cdbb9b134..00000000000 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterGrpc.java +++ /dev/null @@ -1,334 +0,0 @@ -package org.apache.zeppelin.python2; - -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(PythonInterpreterOuterClass.CodeRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(PythonInterpreterOuterClass.InterpetedResult.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 { - - /** - */ - @java.lang.Override - public void interprete(PythonInterpreterOuterClass.CodeRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(METHOD_INTERPRETE, responseObserver); - } - - @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - METHOD_INTERPRETE, - asyncUnaryCall( - new MethodHandlers< - PythonInterpreterOuterClass.CodeRequest, - PythonInterpreterOuterClass.InterpetedResult>( - this, METHODID_INTERPRETE))) - .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); - } - - /** - */ - @java.lang.Override - public void interprete(PythonInterpreterOuterClass.CodeRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_INTERPRETE, 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); - } - - /** - */ - @java.lang.Override - public PythonInterpreterOuterClass.InterpetedResult interprete(PythonInterpreterOuterClass.CodeRequest request) { - return blockingUnaryCall( - getChannel(), METHOD_INTERPRETE, 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); - } - - /** - */ - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture interprete( - PythonInterpreterOuterClass.CodeRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_INTERPRETE, 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(PythonInterpreterOuterClass.CodeRequest 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 PythonInterpreterOuterClass.InterpetedResult interprete(PythonInterpreterOuterClass.CodeRequest 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( - PythonInterpreterOuterClass.CodeRequest 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< - PythonInterpreterOuterClass.CodeRequest, - PythonInterpreterOuterClass.InterpetedResult>( - serviceImpl, METHODID_INTERPRETE))) - .build(); - } - - private static final int METHODID_INTERPRETE = 0; - - 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((PythonInterpreterOuterClass.CodeRequest) 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); - } - -} diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java deleted file mode 100644 index 5ab51767d6c..00000000000 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreterOuterClass.java +++ /dev/null @@ -1,961 +0,0 @@ -package org.apache.zeppelin.python2; - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: python_interpreter.proto - -public final class PythonInterpreterOuterClass { - private PythonInterpreterOuterClass() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - public interface CodeRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:CodeRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string code = 1; - */ - java.lang.String getCode(); - /** - * optional string code = 1; - */ - com.google.protobuf.ByteString - getCodeBytes(); - } - /** - * Protobuf type {@code CodeRequest} - */ - public static final class CodeRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:CodeRequest) - CodeRequestOrBuilder { - // Use CodeRequest.newBuilder() to construct. - private CodeRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private CodeRequest() { - code_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private CodeRequest( - 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; - } - } - } - } 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 PythonInterpreterOuterClass.internal_static_CodeRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return PythonInterpreterOuterClass.internal_static_CodeRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - PythonInterpreterOuterClass.CodeRequest.class, PythonInterpreterOuterClass.CodeRequest.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; - } - } - - 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_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getCodeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, code_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static PythonInterpreterOuterClass.CodeRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static PythonInterpreterOuterClass.CodeRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static PythonInterpreterOuterClass.CodeRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static PythonInterpreterOuterClass.CodeRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static PythonInterpreterOuterClass.CodeRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static PythonInterpreterOuterClass.CodeRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static PythonInterpreterOuterClass.CodeRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static PythonInterpreterOuterClass.CodeRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static PythonInterpreterOuterClass.CodeRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static PythonInterpreterOuterClass.CodeRequest 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(PythonInterpreterOuterClass.CodeRequest 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 CodeRequest} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:CodeRequest) - PythonInterpreterOuterClass.CodeRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return PythonInterpreterOuterClass.internal_static_CodeRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return PythonInterpreterOuterClass.internal_static_CodeRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - PythonInterpreterOuterClass.CodeRequest.class, PythonInterpreterOuterClass.CodeRequest.Builder.class); - } - - // Construct using PythonInterpreterOuterClass.CodeRequest.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_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return PythonInterpreterOuterClass.internal_static_CodeRequest_descriptor; - } - - public PythonInterpreterOuterClass.CodeRequest getDefaultInstanceForType() { - return PythonInterpreterOuterClass.CodeRequest.getDefaultInstance(); - } - - public PythonInterpreterOuterClass.CodeRequest build() { - PythonInterpreterOuterClass.CodeRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public PythonInterpreterOuterClass.CodeRequest buildPartial() { - PythonInterpreterOuterClass.CodeRequest result = new PythonInterpreterOuterClass.CodeRequest(this); - result.code_ = code_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof PythonInterpreterOuterClass.CodeRequest) { - return mergeFrom((PythonInterpreterOuterClass.CodeRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(PythonInterpreterOuterClass.CodeRequest other) { - if (other == PythonInterpreterOuterClass.CodeRequest.getDefaultInstance()) return this; - if (!other.getCode().isEmpty()) { - code_ = other.code_; - 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 { - PythonInterpreterOuterClass.CodeRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (PythonInterpreterOuterClass.CodeRequest) 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; - } - 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:CodeRequest) - } - - // @@protoc_insertion_point(class_scope:CodeRequest) - private static final PythonInterpreterOuterClass.CodeRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new PythonInterpreterOuterClass.CodeRequest(); - } - - public static PythonInterpreterOuterClass.CodeRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CodeRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new CodeRequest(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 PythonInterpreterOuterClass.CodeRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface InterpetedResultOrBuilder extends - // @@protoc_insertion_point(interface_extends:InterpetedResult) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string result = 1; - */ - java.lang.String getResult(); - /** - * optional string result = 1; - */ - com.google.protobuf.ByteString - getResultBytes(); - } - /** - * 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() { - result_ = ""; - } - - @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(); - - result_ = 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 PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return PythonInterpreterOuterClass.internal_static_InterpetedResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - PythonInterpreterOuterClass.InterpetedResult.class, PythonInterpreterOuterClass.InterpetedResult.Builder.class); - } - - public static final int RESULT_FIELD_NUMBER = 1; - private volatile java.lang.Object result_; - /** - * optional string result = 1; - */ - public java.lang.String getResult() { - java.lang.Object ref = result_; - 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(); - result_ = s; - return s; - } - } - /** - * optional string result = 1; - */ - public com.google.protobuf.ByteString - getResultBytes() { - java.lang.Object ref = result_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - result_ = 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 (!getResultBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, result_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getResultBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, result_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static PythonInterpreterOuterClass.InterpetedResult parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static 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 PythonInterpreterOuterClass.InterpetedResult parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static PythonInterpreterOuterClass.InterpetedResult parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static PythonInterpreterOuterClass.InterpetedResult parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static PythonInterpreterOuterClass.InterpetedResult parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static PythonInterpreterOuterClass.InterpetedResult parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static PythonInterpreterOuterClass.InterpetedResult parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static PythonInterpreterOuterClass.InterpetedResult parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static 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(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) - PythonInterpreterOuterClass.InterpetedResultOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return PythonInterpreterOuterClass.internal_static_InterpetedResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - PythonInterpreterOuterClass.InterpetedResult.class, PythonInterpreterOuterClass.InterpetedResult.Builder.class); - } - - // Construct using 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(); - result_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return PythonInterpreterOuterClass.internal_static_InterpetedResult_descriptor; - } - - public PythonInterpreterOuterClass.InterpetedResult getDefaultInstanceForType() { - return PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance(); - } - - public PythonInterpreterOuterClass.InterpetedResult build() { - PythonInterpreterOuterClass.InterpetedResult result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public PythonInterpreterOuterClass.InterpetedResult buildPartial() { - PythonInterpreterOuterClass.InterpetedResult result = new PythonInterpreterOuterClass.InterpetedResult(this); - result.result_ = result_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof PythonInterpreterOuterClass.InterpetedResult) { - return mergeFrom((PythonInterpreterOuterClass.InterpetedResult)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(PythonInterpreterOuterClass.InterpetedResult other) { - if (other == PythonInterpreterOuterClass.InterpetedResult.getDefaultInstance()) return this; - if (!other.getResult().isEmpty()) { - result_ = other.result_; - 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 { - PythonInterpreterOuterClass.InterpetedResult parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (PythonInterpreterOuterClass.InterpetedResult) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object result_ = ""; - /** - * optional string result = 1; - */ - public java.lang.String getResult() { - java.lang.Object ref = result_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - result_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string result = 1; - */ - public com.google.protobuf.ByteString - getResultBytes() { - java.lang.Object ref = result_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - result_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string result = 1; - */ - public Builder setResult( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - result_ = value; - onChanged(); - return this; - } - /** - * optional string result = 1; - */ - public Builder clearResult() { - - result_ = getDefaultInstance().getResult(); - onChanged(); - return this; - } - /** - * optional string result = 1; - */ - public Builder setResultBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - result_ = 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 PythonInterpreterOuterClass.InterpetedResult DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new PythonInterpreterOuterClass.InterpetedResult(); - } - - public static 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 PythonInterpreterOuterClass.InterpetedResult getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static com.google.protobuf.Descriptors.Descriptor - internal_static_CodeRequest_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_CodeRequest_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_InterpetedResult_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_InterpetedResult_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\"\033\n\013CodeReques" + - "t\022\014\n\004code\030\001 \001(\t\"\"\n\020InterpetedResult\022\016\n\006r" + - "esult\030\001 \001(\t2B\n\021PythonInterpreter\022-\n\nInte" + - "rprete\022\014.CodeRequest\032\021.InterpetedResultb" + - "\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_CodeRequest_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_CodeRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_CodeRequest_descriptor, - new java.lang.String[] { "Code", }); - 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[] { "Result", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} 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..721b83aa305 --- /dev/null +++ b/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java @@ -0,0 +1,2839 @@ +/** + * 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(); + } + /** + * 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_ = ""; + } + + @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; + } + } + } + } 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; + } + } + + 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_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, code_); + } + 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_ = ""; + + 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_; + 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(); + } + 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; + } + 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; + * + *
+     *should be enum
+     * 
+ */ + java.lang.String getStatus(); + /** + * optional string status = 2; + * + *
+     *should be 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; + * + *
+     *should be 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; + * + *
+     *should be 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; + * + *
+       *should be 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; + * + *
+       *should be 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; + * + *
+       *should be enum
+       * 
+ */ + public Builder setStatus( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + status_ = value; + onChanged(); + return this; + } + /** + * optional string status = 2; + * + *
+       *should be enum
+       * 
+ */ + public Builder clearStatus() { + + status_ = getDefaultInstance().getStatus(); + onChanged(); + return this; + } + /** + * optional string status = 2; + * + *
+       *should be 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\"%\n\025CodeInterp" + + "reteRequest\022\014\n\004code\030\001 \001(\t\"2\n\020InterpetedR" + + "esult\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\013suggestions\030\001 \003(\t\"" + + "%\n\021ProgressIndicator\022\020\n\010progress\030\001 \001(\005\"\006" + + "\n\004Void2\307\001\n\021PythonInterpreter\0227\n\nInterpre" + + "te\022\026.CodeInterpreteRequest\032\021.InterpetedR" + + "esult\0228\n\014AutoComplete\022\026.CodeCompletionRe" + + "quest\032\020.CodeSuggestions\022%\n\010Progress\022\005.Vo", + "id\032\022.ProgressIndicator\022\030\n\010Shutdown\022\005.Voi" + + "d\032\005.VoidB!\n\037org.apache.zeppelin.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", }); + 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 index d224886196e..b190d35654e 100755 --- a/python/src/main/resources/genrpc.sh +++ b/python/src/main/resources/genrpc.sh @@ -1,23 +1,24 @@ #!/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. -# */ +# +# 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 @@ -27,22 +28,59 @@ # * 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}" -protoc --java_out=./ --grpc-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 -#TODO(alex) -# add licence headers to generated files -# move .py and .java files to appropriate locations +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 -#rm -rf gen-java -#rm -rf ../java/org/apache/zeppelin/interpreter/thrift -#thrift --gen java RemoteInterpreterService.thrift -#for file in gen-java/org/apache/zeppelin/interpreter/thrift/* ; do -# cat java_license_header.txt ${file} > ${file}.tmp -# mv -f ${file}.tmp ${file} -#done -#mv gen-java/org/apache/zeppelin/interpreter/thrift ../java/org/apache/zeppelin/interpreter/thrift -#rm -rf gen-java diff --git a/python/src/main/resources/interpreter.py b/python/src/main/resources/interpreter.py index 8d44c6a6eaa..0986212e789 100755 --- a/python/src/main/resources/interpreter.py +++ b/python/src/main/resources/interpreter.py @@ -1,5 +1,5 @@ #!/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. @@ -113,10 +113,11 @@ class PythonInterpreterServicer(python_interpreter_pb2.BetaPythonInterpreterServ def __init__(self): pass - def Interprete(self, code, context): #CodeRequest - #return InterpetedResult - return python_interpreter_pb2.InterpetedResult(result="") - pass + def Interprete(self, code_interprete_request, context): #CodeInterpreteRequest + print("Got \n```\n{}\n```\n to execute".format(code_interprete_request.code)) + time.sleep(5) + print("Done!") + return python_interpreter_pb2.InterpetedResult(output="Done!", status="success") def main(): diff --git a/python/src/main/resources/python_interpreter.proto b/python/src/main/resources/python_interpreter.proto index 3bdebfb2f31..444305aee90 100644 --- a/python/src/main/resources/python_interpreter.proto +++ b/python/src/main/resources/python_interpreter.proto @@ -1,5 +1,23 @@ +/** + * 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 = "io.grpc.examples.routeguide"; +option java_package = "org.apache.zeppelin.python2.rpc"; service PythonInterpreter { @@ -9,23 +27,36 @@ service PythonInterpreter { // rpc Interprete (CodeInterpreteRequest) returns (InterpetedResult); - rpc AutoComplete (CodeCompletionRequest) return (CodeSuggestions); - //rpc Progress ???? + rpc AutoComplete (CodeCompletionRequest) returns (CodeSuggestions); + rpc Progress (Void) returns (ProgressIndicator); // Terminates this RPC Server python process - rpc Shutdown(); + rpc Shutdown (Void) returns (Void); //TODO(bzz): // log (stderr) streaming? // result streaming? What is result in TensorFlow? } -message CodeRequest { +message CodeInterpreteRequest { string code = 1; } message InterpetedResult { - string result = 1; - //string output = 1; - //string status = 2; //should be enum + string output = 1; + string status = 2; //should be 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 index 085ae00bba6..ed1eb64e3c9 100644 --- a/python/src/main/resources/python_interpreter_pb2.py +++ b/python/src/main/resources/python_interpreter_pb2.py @@ -1,3 +1,19 @@ +# 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 @@ -19,22 +35,22 @@ name='python_interpreter.proto', package='', syntax='proto3', - serialized_pb=_b('\n\x18python_interpreter.proto\"\x1b\n\x0b\x43odeRequest\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\"\"\n\x10InterpetedResult\x12\x0e\n\x06result\x18\x01 \x01(\t2B\n\x11PythonInterpreter\x12-\n\nInterprete\x12\x0c.CodeRequest\x1a\x11.InterpetedResultb\x06proto3') + serialized_pb=_b('\n\x18python_interpreter.proto\"%\n\x15\x43odeInterpreteRequest\x12\x0c\n\x04\x63ode\x18\x01 \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) -_CODEREQUEST = _descriptor.Descriptor( - name='CodeRequest', - full_name='CodeRequest', +_CODEINTERPRETEREQUEST = _descriptor.Descriptor( + name='CodeInterpreteRequest', + full_name='CodeInterpreteRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='code', full_name='CodeRequest.code', index=0, + 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, @@ -53,7 +69,7 @@ oneofs=[ ], serialized_start=28, - serialized_end=55, + serialized_end=65, ) @@ -65,12 +81,81 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='result', full_name='InterpetedResult.result', index=0, + 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=67, + serialized_end=117, +) + + +_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=119, + serialized_end=159, +) + + +_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=[ ], @@ -83,19 +168,78 @@ extension_ranges=[], oneofs=[ ], - serialized_start=57, - serialized_end=91, + serialized_start=161, + serialized_end=199, ) -DESCRIPTOR.message_types_by_name['CodeRequest'] = _CODEREQUEST + +_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=201, + serialized_end=238, +) + + +_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=240, + serialized_end=246, +) + +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 -CodeRequest = _reflection.GeneratedProtocolMessageType('CodeRequest', (_message.Message,), dict( - DESCRIPTOR = _CODEREQUEST, +CodeInterpreteRequest = _reflection.GeneratedProtocolMessageType('CodeInterpreteRequest', (_message.Message,), dict( + DESCRIPTOR = _CODEINTERPRETEREQUEST, __module__ = 'python_interpreter_pb2' - # @@protoc_insertion_point(class_scope:CodeRequest) + # @@protoc_insertion_point(class_scope:CodeInterpreteRequest) )) -_sym_db.RegisterMessage(CodeRequest) +_sym_db.RegisterMessage(CodeInterpreteRequest) InterpetedResult = _reflection.GeneratedProtocolMessageType('InterpetedResult', (_message.Message,), dict( DESCRIPTOR = _INTERPETEDRESULT, @@ -104,7 +248,37 @@ )) _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 @@ -122,14 +296,50 @@ def __init__(self, channel): """ self.Interprete = channel.unary_unary( '/PythonInterpreter/Interprete', - request_serializer=CodeRequest.SerializeToString, + 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!') @@ -139,9 +349,24 @@ def add_PythonInterpreterServicer_to_server(servicer, server): rpc_method_handlers = { 'Interprete': grpc.unary_unary_rpc_method_handler( servicer.Interprete, - request_deserializer=CodeRequest.FromString, + 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) @@ -150,24 +375,60 @@ def add_PythonInterpreterServicer_to_server(servicer, server): 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', 'Interprete'): CodeRequest.FromString, + ('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) @@ -175,13 +436,22 @@ def beta_create_PythonInterpreter_server(servicer, pool=None, pool_size=None, de def beta_create_PythonInterpreter_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): request_serializers = { - ('PythonInterpreter', 'Interprete'): CodeRequest.SerializeToString, + ('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) 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. +# From 1345532aff3fd9b7a10f7aa8845ed7bb618e4af1 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Fri, 19 Aug 2016 18:20:40 +0900 Subject: [PATCH 5/7] Make interpreter interprete and report errors \w line numbers --- .../zeppelin/python2/PythonInterpreter2.java | 20 +++--- python/src/main/resources/interpreter.py | 61 +++++++++++++++++-- 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java index b4494268bd0..9b5024a9c74 100644 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -58,9 +58,12 @@ public class PythonInterpreter2 extends Interpreter { 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); } @@ -72,14 +75,11 @@ public void open() { //TODO(bzz): //%dep grpcio || %dep pip install grpcio + //this.serverPort = `pick open port` + //start `interpreter.py serverPort` - int serverPort = 9090; - //pick open serverPort - //start gRPC server ./interpreter.py on serverPort - - /**connect to gRPC server on serverPort*/ ManagedChannelBuilder channelBuilder = ManagedChannelBuilder - .forAddress("localhost", serverPort) + .forAddress(this.serverHost, this.serverPort) .usePlaintext(true); ManagedChannel channel = channelBuilder.build(); blockingStub = PythonInterpreterGrpc.newBlockingStub(channel); @@ -143,7 +143,13 @@ InterpreterResult sendCommandToPython(String code) { fromPythonProcess = blockingStub.interprete(cmd); } catch (StatusRuntimeException e) { LOG.error("Error when sending commands to Python process", e); - return new InterpreterResult(Code.ERROR, "Failed to communicate to interpreter"); + 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)) { diff --git a/python/src/main/resources/interpreter.py b/python/src/main/resources/interpreter.py index 0986212e789..706d27e6237 100755 --- a/python/src/main/resources/interpreter.py +++ b/python/src/main/resources/interpreter.py @@ -17,9 +17,13 @@ """Python interpreter exposed though gRPC server""" +import sys import time import argparse +#TODO python3 compatibility! i.e `import io` +from cStringIO import StringIO + import python_interpreter_pb2 _ONE_DAY_IN_SECONDS = 60 * 60 * 24 @@ -104,6 +108,11 @@ def _check_port_range(value): "{} 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 @@ -113,11 +122,55 @@ class PythonInterpreterServicer(python_interpreter_pb2.BetaPythonInterpreterServ def __init__(self): pass + def do_exec(self, code): + """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-effecto for the executed code + + Rises: + InterpreterError: an error with specific line number + """ + #TODO python3 compatibility! i.e io.BytesIO() + redirected_output = sys.stdout = StringIO() + try: + old_stdout = sys.stdout + #compile()? + exec(code, globals(), locals()) + #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, code_interprete_request, context): #CodeInterpreteRequest - print("Got \n```\n{}\n```\n to execute".format(code_interprete_request.code)) - time.sleep(5) - print("Done!") - return python_interpreter_pb2.InterpetedResult(output="Done!", status="success") + print("Got \n```\n{}\n```\nto execute".format(code_interprete_request.code)) + out = "" + try: + out = self.do_exec(code_interprete_request.code); + 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!") + return python_interpreter_pb2.InterpetedResult(output=out, status="success") def main(): From f3d4794cf03a16a00e7f4fd37f34ef223c620346 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Fri, 26 Aug 2016 16:09:26 +0900 Subject: [PATCH 6/7] add error detection to JVM and Python Shutdown() stub --- .../zeppelin/python2/PythonInterpreter2.java | 5 +++-- python/src/main/resources/interpreter.py | 17 ++++++++++++----- .../src/main/resources/python_interpreter.proto | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java index 9b5024a9c74..ab8bb032b81 100644 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -88,7 +88,7 @@ public void open() { @Override public void close() { LOG.info("closing Python interpreter ....."); - //TODO(bzz): blockingStub.shutdown(); + blockingStub.shutdown(null); // LOG.error("Can't close the interpreter", e); } @@ -162,7 +162,8 @@ InterpreterResult sendCommandToPython(String code) { } private static boolean gotSuccess(InterpetedResult result) { - return result != null; // && result.getStatus() is ...; + //TODO(bzz): replace string \w enum + return result != null && result.getStatus().toLowerCase().contains("success"); } /*public Boolean isPy4jInstalled() { diff --git a/python/src/main/resources/interpreter.py b/python/src/main/resources/interpreter.py index 706d27e6237..4fb6cf66ee6 100755 --- a/python/src/main/resources/interpreter.py +++ b/python/src/main/resources/interpreter.py @@ -20,9 +20,10 @@ import sys import time import argparse +import traceback -#TODO python3 compatibility! i.e `import io` -from cStringIO import StringIO + +from cStringIO import StringIO #TODO python3 compatibility! i.e `import io` import python_interpreter_pb2 @@ -137,10 +138,10 @@ def do_exec(self, 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: - old_stdout = sys.stdout #compile()? exec(code, globals(), locals()) #execfile()? @@ -170,8 +171,14 @@ def Interprete(self, code_interprete_request, context): #CodeInterpreteRequest out = "{} at line {}:\n{}".format(e.error_class, e.line_number, e.details) return python_interpreter_pb2.InterpetedResult(output=out, status="fail") print("Success!") - return python_interpreter_pb2.InterpetedResult(output=out, status="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 main(): parser = argparse.ArgumentParser( diff --git a/python/src/main/resources/python_interpreter.proto b/python/src/main/resources/python_interpreter.proto index 444305aee90..e85b91036da 100644 --- a/python/src/main/resources/python_interpreter.proto +++ b/python/src/main/resources/python_interpreter.proto @@ -44,7 +44,7 @@ message CodeInterpreteRequest { message InterpetedResult { string output = 1; - string status = 2; //should be enum + string status = 2; //TODO(bzz) replace \w enum } message CodeCompletionRequest { From c0c97c1496c4287d273353358cb7baded52db962 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Sat, 27 Aug 2016 13:39:26 +0900 Subject: [PATCH 7/7] Notes do not share context: vars, imports, etc --- .../zeppelin/python2/PythonInterpreter2.java | 12 +- .../rpc/PythonInterpreterOuterClass.java | 179 +++++++++++++++--- python/src/main/resources/interpreter.py | 27 ++- .../main/resources/python_interpreter.proto | 1 + .../main/resources/python_interpreter_pb2.py | 31 +-- 5 files changed, 204 insertions(+), 46 deletions(-) diff --git a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java index ab8bb032b81..69e06dc2df8 100644 --- a/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java +++ b/python/src/main/java/org/apache/zeppelin/python2/PythonInterpreter2.java @@ -97,7 +97,8 @@ public InterpreterResult interpret(String cmd, InterpreterContext contextInterpr if (cmd == null || cmd.isEmpty()) { return new InterpreterResult(Code.SUCCESS, ""); } - return sendCommandToPython(cmd); + String noteId = contextInterpreter.getNoteId(); + return sendCommandToPython(cmd, noteId); } @Override @@ -131,13 +132,16 @@ public Scheduler getScheduler() { /** * 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) { + InterpreterResult sendCommandToPython(String code, String noteId) { LOG.debug("Sending : \n" + (code.length() > 200 ? code.substring(0, 200) + "..." : code)); - CodeInterpreteRequest cmd = CodeInterpreteRequest.newBuilder().setCode((code)).build(); - + 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); 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 index 721b83aa305..7d6ad9472b9 100644 --- a/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java +++ b/python/src/main/java/org/apache/zeppelin/python2/rpc/PythonInterpreterOuterClass.java @@ -38,6 +38,16 @@ public interface CodeInterpreteRequestOrBuilder extends */ 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} @@ -52,6 +62,7 @@ private CodeInterpreteRequest(com.google.protobuf.GeneratedMessage.Builder bu } private CodeInterpreteRequest() { code_ = ""; + noteId_ = ""; } @java.lang.Override @@ -84,6 +95,12 @@ private CodeInterpreteRequest( code_ = s; break; } + case 18: { + String s = input.readStringRequireUtf8(); + + noteId_ = s; + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -142,6 +159,40 @@ public java.lang.String getCode() { } } + 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; @@ -157,6 +208,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) 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() { @@ -167,6 +221,9 @@ public int getSerializedSize() { 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; } @@ -280,6 +337,8 @@ public Builder clear() { super.clear(); code_ = ""; + noteId_ = ""; + return this; } @@ -303,6 +362,7 @@ public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.CodeInterpret 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; } @@ -322,6 +382,10 @@ public Builder mergeFrom(org.apache.zeppelin.python2.rpc.PythonInterpreterOuterC code_ = other.code_; onChanged(); } + if (!other.getNoteId().isEmpty()) { + noteId_ = other.noteId_; + onChanged(); + } onChanged(); return this; } @@ -416,6 +480,75 @@ public Builder setCodeBytes( 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; @@ -492,7 +625,7 @@ public interface InterpetedResultOrBuilder extends * optional string status = 2; * *
-     *should be enum
+     *TODO(bzz) replace \w enum
      * 
*/ java.lang.String getStatus(); @@ -500,7 +633,7 @@ public interface InterpetedResultOrBuilder extends * optional string status = 2; * *
-     *should be enum
+     *TODO(bzz) replace \w enum
      * 
*/ com.google.protobuf.ByteString @@ -622,7 +755,7 @@ public java.lang.String getOutput() { * optional string status = 2; * *
-     *should be enum
+     *TODO(bzz) replace \w enum
      * 
*/ public java.lang.String getStatus() { @@ -641,7 +774,7 @@ public java.lang.String getStatus() { * optional string status = 2; * *
-     *should be enum
+     *TODO(bzz) replace \w enum
      * 
*/ public com.google.protobuf.ByteString @@ -951,7 +1084,7 @@ public Builder setOutputBytes( * optional string status = 2; * *
-       *should be enum
+       *TODO(bzz) replace \w enum
        * 
*/ public java.lang.String getStatus() { @@ -970,7 +1103,7 @@ public java.lang.String getStatus() { * optional string status = 2; * *
-       *should be enum
+       *TODO(bzz) replace \w enum
        * 
*/ public com.google.protobuf.ByteString @@ -990,7 +1123,7 @@ public java.lang.String getStatus() { * optional string status = 2; * *
-       *should be enum
+       *TODO(bzz) replace \w enum
        * 
*/ public Builder setStatus( @@ -1007,7 +1140,7 @@ public Builder setStatus( * optional string status = 2; * *
-       *should be enum
+       *TODO(bzz) replace \w enum
        * 
*/ public Builder clearStatus() { @@ -1020,7 +1153,7 @@ public Builder clearStatus() { * optional string status = 2; * *
-       *should be enum
+       *TODO(bzz) replace \w enum
        * 
*/ public Builder setStatusBytes( @@ -2771,19 +2904,19 @@ public org.apache.zeppelin.python2.rpc.PythonInterpreterOuterClass.Void getDefau descriptor; static { java.lang.String[] descriptorData = { - "\n\030python_interpreter.proto\"%\n\025CodeInterp" + - "reteRequest\022\014\n\004code\030\001 \001(\t\"2\n\020InterpetedR" + - "esult\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\013suggestions\030\001 \003(\t\"" + - "%\n\021ProgressIndicator\022\020\n\010progress\030\001 \001(\005\"\006" + - "\n\004Void2\307\001\n\021PythonInterpreter\0227\n\nInterpre" + - "te\022\026.CodeInterpreteRequest\032\021.InterpetedR" + - "esult\0228\n\014AutoComplete\022\026.CodeCompletionRe" + - "quest\032\020.CodeSuggestions\022%\n\010Progress\022\005.Vo", - "id\032\022.ProgressIndicator\022\030\n\010Shutdown\022\005.Voi" + - "d\032\005.VoidB!\n\037org.apache.zeppelin.python2." + - "rpcb\006proto3" + "\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() { @@ -2802,7 +2935,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_CodeInterpreteRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_CodeInterpreteRequest_descriptor, - new java.lang.String[] { "Code", }); + new java.lang.String[] { "Code", "NoteId", }); internal_static_InterpetedResult_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_InterpetedResult_fieldAccessorTable = new diff --git a/python/src/main/resources/interpreter.py b/python/src/main/resources/interpreter.py index 4fb6cf66ee6..5bb4b1cde5d 100755 --- a/python/src/main/resources/interpreter.py +++ b/python/src/main/resources/interpreter.py @@ -28,6 +28,7 @@ import python_interpreter_pb2 _ONE_DAY_IN_SECONDS = 60 * 60 * 24 +_NOTE_GLOBALS = "{}_globals" def help(): print("""%html @@ -123,7 +124,7 @@ class PythonInterpreterServicer(python_interpreter_pb2.BetaPythonInterpreterServ def __init__(self): pass - def do_exec(self, code): + 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 @@ -133,7 +134,7 @@ def do_exec(self, code): code: string of Python code Returns: - String that is stdout, a side-effecto for the executed code + String that is stdout, a side-effect for the executed code Rises: InterpreterError: an error with specific line number @@ -142,8 +143,10 @@ def do_exec(self, code): #TODO python3 compatibility! i.e io.BytesIO() redirected_output = sys.stdout = StringIO() try: - #compile()? - exec(code, globals(), locals()) + #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: @@ -162,11 +165,13 @@ def do_exec(self, code): print("{} at line {}: {}".format(error_class, line_number, details)) raise InterpreterError(error_class, line_number, details) - def Interprete(self, code_interprete_request, context): #CodeInterpreteRequest - print("Got \n```\n{}\n```\nto execute".format(code_interprete_request.code)) + def Interprete(self, request, context): #CodeInterpreteRequest + print("Got \n```\n{}\n```\nfrom noteID '{}'".format(request.code, request.noteId)) out = "" try: - out = self.do_exec(code_interprete_request.code); + #_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") @@ -180,6 +185,14 @@ def Shutdown(self, void, context): #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.') diff --git a/python/src/main/resources/python_interpreter.proto b/python/src/main/resources/python_interpreter.proto index e85b91036da..d066c72e29c 100644 --- a/python/src/main/resources/python_interpreter.proto +++ b/python/src/main/resources/python_interpreter.proto @@ -40,6 +40,7 @@ service PythonInterpreter { message CodeInterpreteRequest { string code = 1; + string noteId = 2; } message InterpetedResult { diff --git a/python/src/main/resources/python_interpreter_pb2.py b/python/src/main/resources/python_interpreter_pb2.py index ed1eb64e3c9..0fd158ddd14 100644 --- a/python/src/main/resources/python_interpreter_pb2.py +++ b/python/src/main/resources/python_interpreter_pb2.py @@ -35,7 +35,7 @@ name='python_interpreter.proto', package='', syntax='proto3', - serialized_pb=_b('\n\x18python_interpreter.proto\"%\n\x15\x43odeInterpreteRequest\x12\x0c\n\x04\x63ode\x18\x01 \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') + 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) @@ -56,6 +56,13 @@ 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=[ ], @@ -69,7 +76,7 @@ oneofs=[ ], serialized_start=28, - serialized_end=65, + serialized_end=81, ) @@ -106,8 +113,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=67, - serialized_end=117, + serialized_start=83, + serialized_end=133, ) @@ -137,8 +144,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=119, - serialized_end=159, + serialized_start=135, + serialized_end=175, ) @@ -168,8 +175,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=161, - serialized_end=199, + serialized_start=177, + serialized_end=215, ) @@ -199,8 +206,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=201, - serialized_end=238, + serialized_start=217, + serialized_end=254, ) @@ -223,8 +230,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=240, - serialized_end=246, + serialized_start=256, + serialized_end=262, ) DESCRIPTOR.message_types_by_name['CodeInterpreteRequest'] = _CODEINTERPRETEREQUEST