From 1da03d69f6986b8d4a33ba89ea1e9f6601fb58b9 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 29 Apr 2019 12:09:27 -0400 Subject: [PATCH 1/3] Stop bug, Image bug Initial SIGTERM prompts server to dutifully shutdown kernel, but another SIGTERM necessary to kill server. Perhaps ipython changed since the last time I tested this. Ipython doesn't send a display_data message upon initial plot request. This is probably our bug, or is it? Document this bug in an ecukes test. Also enforce emacs version >= 25 --- features/notebook.feature | 20 ++++++++++++++++++++ lisp/ein-jupyter.el | 8 ++++++-- lisp/ein-kernel.el | 9 ++------- lisp/ein-pkg.el | 3 ++- lisp/ein.el | 1 - 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/features/notebook.feature b/features/notebook.feature index 7ec5c05..63f0267 100644 --- a/features/notebook.feature +++ b/features/notebook.feature @@ -60,6 +60,26 @@ Scenario: rename notebook And I switch to buffer like "Untitled" And rename notebook to "Renamed" succeeds +@image +Scenario: image fails to materialize initially. Document this in a test. + Given new default notebook + And I type "import numpy, math, matplotlib.pyplot as plt" + And I press "RET" + And I type "x = numpy.linspace(0, 2*math.pi)" + And I press "RET" + And I type "plt.plot(x, numpy.sin(x))" + And I press "RET" + And I clear log expr "ein:log-all-buffer-name" + And I wait for cell to execute + And I dump buffer + And I switch to log expr "ein:log-all-buffer-name" + Then I should not see "msg_type=display_data" + And I switch to buffer like "Untitled" + And I wait for cell to execute + And I dump buffer + And I switch to log expr "ein:log-all-buffer-name" + Then I should see "msg_type=display_data" + @switch Scenario: switch kernel Given new default notebook diff --git a/lisp/ein-jupyter.el b/lisp/ein-jupyter.el index d373a3f..8095e60 100644 --- a/lisp/ein-jupyter.el +++ b/lisp/ein-jupyter.el @@ -231,9 +231,13 @@ the log of the running jupyter server." ;; Both (quit-process) and (delete-process) leaked child kernels, so signal (if (eql system-type 'windows-nt) (delete-process proc) - (let ((pid (process-id proc))) + (lexical-let* ((proc proc) + (pid (process-id proc))) (ein:log 'verbose "Signaled %s with pid %s" proc pid) - (signal-process pid 15))) + (signal-process pid 15) + (run-at-time 2 nil (lambda () + (ein:log 'verbose "Resignaled %s with pid %s" proc pid) + (signal-process pid 15))))) (ein:log 'info "Stopped Jupyter notebook server.") diff --git a/lisp/ein-kernel.el b/lisp/ein-kernel.el index 165f88e..ffc9463 100644 --- a/lisp/ein-kernel.el +++ b/lisp/ein-kernel.el @@ -671,7 +671,6 @@ We need this to have proper behavior for the 'Stop' command in the ein:notebookl (puthash msg-id callbacks (ein:$kernel-msg-callbacks kernel))) (defun ein:kernel--handle-stdin-reply (kernel packet) - (ein:log 'debug "KERNEL--HANDLE-STDIN-REPLY") (setf (ein:$kernel-stdin-activep kernel) t) (destructuring-bind (&key header parent_header metadata content &allow-other-keys) @@ -697,7 +696,6 @@ We need this to have proper behavior for the 'Stop' command in the ein:notebookl (setf (ein:$kernel-stdin-activep kernel) nil)))))))))) (defun ein:kernel--handle-shell-reply (kernel packet) - (ein:log 'debug "KERNEL--HANDLE-SHELL-REPLY") (destructuring-bind (&key header content metadata parent_header &allow-other-keys) (ein:json-read-from-string packet) @@ -716,8 +714,7 @@ We need this to have proper behavior for the 'Stop' command in the ein:notebookl (("execute_reply") (ein:aif (plist-get content :execution_count) ;; It can be `nil' for silent execution - (ein:events-trigger events 'execution_count.Kernel it))))))) - (ein:log 'debug "KERNEL--HANDLE-SHELL-REPLY: finished")) + (ein:events-trigger events 'execution_count.Kernel it)))))))) (defun ein:kernel--handle-payload (kernel callbacks payload) (loop with events = (ein:$kernel-events kernel) @@ -742,7 +739,6 @@ We need this to have proper behavior for the 'Stop' command in the ein:notebookl (when cb (ein:funcall-packed cb text))))) (defun ein:kernel--handle-iopub-reply (kernel packet) - (ein:log 'debug "KERNEL--HANDLE-IOPUB-REPLY") (if (ein:$kernel-stdin-activep kernel) (ein:ipdb--handle-iopub-reply kernel packet) (destructuring-bind @@ -772,8 +768,7 @@ We need this to have proper behavior for the 'Stop' command in the ein:notebookl (ein:log 'verbose (format "Received data_pub message w/content %s" packet))) (("clear_output") (ein:aif (plist-get callbacks :clear_output) - (ein:funcall-packed it content metadata)))))))) - (ein:log 'debug "KERNEL--HANDLE-IOPUB-REPLY: finished")) + (ein:funcall-packed it content metadata))))))))) ;;; Utility functions diff --git a/lisp/ein-pkg.el b/lisp/ein-pkg.el index a0e29db..2ad4962 100644 --- a/lisp/ein-pkg.el +++ b/lisp/ein-pkg.el @@ -1,7 +1,8 @@ (define-package "ein" "0.16.0" "Emacs IPython Notebook" - '((websocket "1.7") + '((emacs "25") + (websocket "1.7") (auto-complete "1.4.0") (request "0.3") (deferred "0.5") diff --git a/lisp/ein.el b/lisp/ein.el index 45a0894..f7f8556 100644 --- a/lisp/ein.el +++ b/lisp/ein.el @@ -5,7 +5,6 @@ ;; Author: John Miller , Takafumi Arakaki ;; URL: http://millejoh.github.io/emacs-ipython-notebook/ ;; Keywords: applications, tools -;; Version: 0.15.0 ;; This file is NOT part of GNU Emacs. From d3b0b97037a16508ded5c60466aee4c88602cc49 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 29 Apr 2019 15:35:32 -0400 Subject: [PATCH 2/3] pm--get-existing-mode changed signature. --- lisp/ein-pkg.el | 2 +- lisp/ein-worksheet.el | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/ein-pkg.el b/lisp/ein-pkg.el index 2ad4962..d3a64be 100644 --- a/lisp/ein-pkg.el +++ b/lisp/ein-pkg.el @@ -6,7 +6,7 @@ (auto-complete "1.4.0") (request "0.3") (deferred "0.5") - (polymode "20190102.1910") + (polymode "20190426.1729") (markdown-mode "20171116.756") (dash "2.13.0") (s "1.11.0") diff --git a/lisp/ein-worksheet.el b/lisp/ein-worksheet.el index 4b72e55..3952af0 100644 --- a/lisp/ein-worksheet.el +++ b/lisp/ein-worksheet.el @@ -388,7 +388,8 @@ Normalize `buffer-undo-list' by removing extraneous details, and update the ein: (replace-regexp-in-string "poly-\\|-mode" "" (symbol-name - (pm--get-existing-mode (eieio-oref chunkmode 'mode)))))) + (pm--get-existing-mode (eieio-oref chunkmode 'mode) + (eieio-oref chunkmode 'fallback-mode)))))) simple-name))))))) (cl-defmethod ein:worksheet-set-modified-p ((ws ein:worksheet) dirty) From 910e6ea5654a94dbe98550a2223bb4b462007724 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 29 Apr 2019 17:16:55 -0400 Subject: [PATCH 3/3] can't specify version in `cask install`. Need to apply blunt instrument. --- tools/install-cask.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-cask.sh b/tools/install-cask.sh index 1be2973..245a37a 100644 --- a/tools/install-cask.sh +++ b/tools/install-cask.sh @@ -24,6 +24,7 @@ cask_install_or_reset() { set +x fi cask install || { rm -rf .cask && false; } + cask update # travis cache rsync -vazSHe ssh .cask $HOME/ }