You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by jo...@apache.org on 2018/12/04 06:10:01 UTC
zeppelin git commit: [ZEPPELIN-3893] Bug Fix that clear paragraphs
when executing the Paragraph API asynchronously
Repository: zeppelin
Updated Branches:
refs/heads/master 354b06f73 -> eb941056b
[ZEPPELIN-3893] Bug Fix that clear paragraphs when executing the Paragraph API asynchronously
### What is this PR for?
When calling the asynchronous execution of the paragraph API,
```
http://[zeppelin-server]:[zeppelin-port]/api/notebook/run/[noteId]/[paragraphId]
```
The title and text of the paragraph will be cleared.
### What type of PR is it?
[Bug Fix]
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3893
### How should this be tested?
[CI pass](https://travis-ci.org/liuxunorg/zeppelin/builds/462203315)
### Screenshots (if appropriate)
No
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: liuxunorg <33...@qq.com>
Closes #3245 from liuxunorg/ZEPPELIN-3893 and squashes the following commits:
c1b4e9c36 [liuxunorg] Revert "merge zjffdu@29593d7 PR & rebase HEAD^"
94eb8a650 [liuxunorg] merge zjffdu@29593d7 PR & rebase HEAD^
76907320a [liuxunorg] Add test case of executing the Paragraph API asynchronously.
77ad6566e [liuxunorg] [ZEPPELIN-3893] Bug Fix that clear paragraphs when executing the Paragraph API asynchronously
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/eb941056
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/eb941056
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/eb941056
Branch: refs/heads/master
Commit: eb941056b5d35323a5f08123f681d777e170ea2b
Parents: 354b06f
Author: liuxunorg <33...@qq.com>
Authored: Tue Dec 4 10:24:16 2018 +0800
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Tue Dec 4 15:09:57 2018 +0900
----------------------------------------------------------------------
.../apache/zeppelin/rest/NotebookRestApi.java | 11 ++++++--
.../zeppelin/rest/NotebookRestApiTest.java | 29 ++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/eb941056/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
index cd449c5..ebeff6f 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
@@ -798,15 +798,22 @@ public class NotebookRestApi extends AbstractRestApi {
throws IOException, IllegalArgumentException {
LOG.info("run paragraph synchronously {} {} {}", noteId, paragraphId, message);
+ Note note = notebook.getNote(noteId);
+ checkIfNoteIsNotNull(note);
+ Paragraph paragraph = note.getParagraph(paragraphId);
+ checkIfParagraphIsNotNull(paragraph);
+
Map<String, Object> params = new HashMap<>();
if (!StringUtils.isEmpty(message)) {
RunParagraphWithParametersRequest request =
RunParagraphWithParametersRequest.fromJson(message);
params = request.getParams();
}
- if (notebookService.runParagraph(noteId, paragraphId, "", "", params,
+
+ if (notebookService.runParagraph(noteId, paragraphId, paragraph.getTitle(),
+ paragraph.getText(), params,
new HashMap<>(), false, true, getServiceContext(), new RestServiceCallback<>())) {
- Note note = notebookService.getNote(noteId, getServiceContext(), new RestServiceCallback<>());
+ note = notebookService.getNote(noteId, getServiceContext(), new RestServiceCallback<>());
Paragraph p = note.getParagraph(paragraphId);
InterpreterResult result = p.getReturn();
if (result.code() == InterpreterResult.Code.SUCCESS) {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/eb941056/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
index 2fcee08..daf74b8 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
@@ -122,6 +122,35 @@ public class NotebookRestApiTest extends AbstractTestRestApi {
}
@Test
+ public void testRunParagraphSynchronously() throws IOException {
+ Note note1 = ZeppelinServer.notebook.createNote("note1", anonymous);
+ note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
+
+ Paragraph p = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
+
+ // run non-blank paragraph
+ String title = "title";
+ String text = "%sh\n sleep 1";
+ p.setTitle(title);
+ p.setText(text);
+
+ PostMethod post = httpPost("/notebook/run/" + note1.getId() + "/" + p.getId(), "");
+ assertThat(post, isAllowed());
+ Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(),
+ new TypeToken<Map<String, Object>>() {}.getType());
+ assertEquals(resp.get("status"), "OK");
+ post.releaseConnection();
+ assertNotEquals(p.getStatus(), Job.Status.READY);
+
+ // Check if the paragraph is emptied
+ assertEquals(title, p.getTitle());
+ assertEquals(text, p.getText());
+
+ // cleanup
+ ZeppelinServer.notebook.removeNote(note1.getId(), anonymous);
+ }
+
+ @Test
public void testRunAllParagraph_AllSuccess() throws IOException {
Note note1 = ZeppelinServer.notebook.createNote("note1", anonymous);
// 2 paragraphs