zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject incubator-zeppelin git commit: [ZEPPELIN-680] Cron job will run cells that have had their run disabled
Date Tue, 23 Feb 2016 03:13:06 GMT
Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 7a1f921ce -> e0fa38693


[ZEPPELIN-680] Cron job will run cells that have had their run disabled

### What is this PR for?
When I run a cron job, cells that I have selected the "disable run" option will still run.
This PR fixes the problem.

### What type of PR is it?
Bug Fix

### Todos
* [x] - exclude disabled paragraph from runAll

### Is there a relevant Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-680?jql=project%20%3D%20ZEPPELIN

### How should this be tested?
Create paragraph and disable it.
Then enable cron scheduling a notebook.
The paragraph supposed to not run.

### Screenshots (if appropriate)
N/A

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <moon@apache.org>

Closes #730 from Leemoonsoo/ZEPPELIN-680 and squashes the following commits:

ced9aee [Lee moon soo] Exclude disabled paragraph from runAll


Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/e0fa3869
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/e0fa3869
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/e0fa3869

Branch: refs/heads/master
Commit: e0fa3869302a872464670a1451f036526736bc28
Parents: 7a1f921
Author: Lee moon soo <moon@apache.org>
Authored: Fri Feb 19 23:55:50 2016 -0800
Committer: Lee moon soo <moon@apache.org>
Committed: Mon Feb 22 19:16:40 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/zeppelin/notebook/Note.java |  3 ++
 .../org/apache/zeppelin/notebook/Paragraph.java |  5 +++
 .../apache/zeppelin/notebook/NotebookTest.java  | 34 +++++++++++++++-----
 3 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/e0fa3869/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
index 52e7ea3..b0470c8 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
@@ -349,6 +349,9 @@ public class Note implements Serializable, JobListener {
   public void runAll() {
     synchronized (paragraphs) {
       for (Paragraph p : paragraphs) {
+        if (!p.isEnabled()) {
+          continue;
+        }
         p.setNoteReplLoader(replLoader);
         p.setListener(jobListenerFactory.getParagraphJobListener(this));
         Interpreter intp = replLoader.get(p.getRequiredReplName());

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/e0fa3869/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
index bf17c35..4bd4d1d 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
@@ -91,6 +91,11 @@ public class Paragraph extends Job implements Serializable, Cloneable {
     return note;
   }
 
+  public boolean isEnabled() {
+    Boolean enabled = (Boolean) config.get("enabled");
+    return enabled == null || enabled.booleanValue();
+  }
+
   public String getRequiredReplName() {
     return getRequiredReplName(text);
   }

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/e0fa3869/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index 1988f1c..d96f7a9 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -204,20 +204,38 @@ public class NotebookTest implements JobListenerFactory{
   public void testRunAll() throws IOException {
     Note note = notebook.createNote();
     note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList());
+
+    // p1
     Paragraph p1 = note.addParagraph();
-    Map config = p1.getConfig();
-    config.put("enabled", true);
-    p1.setConfig(config);
+    Map config1 = p1.getConfig();
+    config1.put("enabled", true);
+    p1.setConfig(config1);
     p1.setText("p1");
+
+    // p2
     Paragraph p2 = note.addParagraph();
-    Map config1 = p2.getConfig();
-    p2.setConfig(config1);
+    Map config2 = p2.getConfig();
+    config2.put("enabled", false);
+    p2.setConfig(config2);
     p2.setText("p2");
-    assertEquals(null, p2.getResult());
+
+    // p3
+    Paragraph p3 = note.addParagraph();
+    p3.setText("p3");
+
+    // when
     note.runAll();
 
-    while(p2.isTerminated()==false || p2.getResult()==null) Thread.yield();
-    assertEquals("repl1: p2", p2.getResult().message());
+    // wait for finish
+    while(p3.isTerminated()==false) {
+      Thread.yield();
+    }
+
+    assertEquals("repl1: p1", p1.getResult().message());
+    assertNull(p2.getResult());
+    assertEquals("repl1: p3", p3.getResult().message());
+
+    notebook.removeNote(note.getId());
   }
 
   @Test


Mime
View raw message