mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Merge branch 'master' into add-git-notebook-repo
This commit is contained in:
commit
94720d9ade
7 changed files with 76 additions and 12 deletions
|
|
@ -24,6 +24,7 @@
|
|||
<!-- li><span><b>Install</b><span></li -->
|
||||
<li><a href="{{BASE_PATH}}/install/install.html">Install</a></li>
|
||||
<li><a href="{{BASE_PATH}}/install/yarn_install.html">YARN Install</a></li>
|
||||
<li><a href="{{BASE_PATH}}/install/virtual_machine.html">Virtual Machine Install</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<!-- li><span><b>Tutorial</b><span></li -->
|
||||
<li><a href="{{BASE_PATH}}/tutorial/tutorial.html">Tutorial</a></li>
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ class PyZeppelinContext(dict):
|
|||
def show(self, obj):
|
||||
from pyspark.sql import DataFrame
|
||||
if isinstance(obj, DataFrame):
|
||||
print gateway.jvm.org.apache.zeppelin.spark.ZeppelinContext.showDF(self.z, obj._jdf)
|
||||
print(gateway.jvm.org.apache.zeppelin.spark.ZeppelinContext.showDF(self.z, obj._jdf))
|
||||
else:
|
||||
print str(obj)
|
||||
print(str(obj))
|
||||
|
||||
# By implementing special methods it makes operating on it more Pythonic
|
||||
def __setitem__(self, key, item):
|
||||
|
|
|
|||
|
|
@ -27,6 +27,21 @@ import org.apache.zeppelin.display.GUI;
|
|||
* Interpreter context
|
||||
*/
|
||||
public class InterpreterContext {
|
||||
private static final ThreadLocal<InterpreterContext> threadIC =
|
||||
new ThreadLocal<InterpreterContext>();
|
||||
|
||||
public static InterpreterContext get() {
|
||||
return threadIC.get();
|
||||
}
|
||||
|
||||
public static void set(InterpreterContext ic) {
|
||||
threadIC.set(ic);
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
threadIC.remove();
|
||||
}
|
||||
|
||||
private final String noteId;
|
||||
private final String paragraphTitle;
|
||||
private final String paragraphId;
|
||||
|
|
@ -55,7 +70,7 @@ public class InterpreterContext {
|
|||
this.runners = runners;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getNoteId() {
|
||||
return noteId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,8 +294,13 @@ public class RemoteInterpreterServer
|
|||
|
||||
@Override
|
||||
protected Object jobRun() throws Throwable {
|
||||
InterpreterResult result = interpreter.interpret(script, context);
|
||||
return result;
|
||||
try {
|
||||
InterpreterContext.set(context);
|
||||
InterpreterResult result = interpreter.interpret(script, context);
|
||||
return result;
|
||||
} finally {
|
||||
InterpreterContext.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.interpreter;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class InterpreterContextTest {
|
||||
|
||||
@Test
|
||||
public void testThreadLocal() {
|
||||
assertNull(InterpreterContext.get());
|
||||
|
||||
InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null));
|
||||
assertNotNull(InterpreterContext.get());
|
||||
|
||||
InterpreterContext.remove();
|
||||
assertNull(InterpreterContext.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ public class Note implements Serializable, JobListener {
|
|||
public String id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ public class Note implements Serializable, JobListener {
|
|||
paragraphs.add(newParagraph);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert paragraph in given index.
|
||||
*
|
||||
|
|
@ -323,7 +323,7 @@ public class Note implements Serializable, JobListener {
|
|||
if (intp == null) {
|
||||
throw new InterpreterException("Interpreter " + p.getRequiredReplName() + " not found");
|
||||
}
|
||||
if ((Boolean) p.getConfig().get("enabled")) {
|
||||
if (p.getConfig().get("enabled") == null || (Boolean) p.getConfig().get("enabled")) {
|
||||
intp.getScheduler().submit(p);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,12 +206,18 @@ public class Paragraph extends Job implements Serializable, Cloneable {
|
|||
script = Input.getSimpleQuery(settings.getParams(), scriptBody);
|
||||
}
|
||||
logger().debug("RUN : " + script);
|
||||
InterpreterResult ret = repl.interpret(script, getInterpreterContext());
|
||||
try {
|
||||
InterpreterContext context = getInterpreterContext();
|
||||
InterpreterContext.set(context);
|
||||
InterpreterResult ret = repl.interpret(script, context);
|
||||
|
||||
if (Code.KEEP_PREVIOUS_RESULT == ret.code()) {
|
||||
return getReturn();
|
||||
if (Code.KEEP_PREVIOUS_RESULT == ret.code()) {
|
||||
return getReturn();
|
||||
}
|
||||
return ret;
|
||||
} finally {
|
||||
InterpreterContext.remove();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue