Commit graph

119 commits

Author SHA1 Message Date
dickmao
84fa177a1e When I C-c C-c also C-c C-r if necessary
If user wants to execute cell, and the connection is down,
automatically reconnect, then execute the cell.
2018-11-06 18:36:46 -05:00
dickmao
d7985ffc6b sometimes travis finds bugs 2018-11-04 21:38:20 -06:00
dickmao
7d31fe7f34 fix the osx testing bug 2018-11-04 21:38:20 -06:00
dickmao
ee3b0f095c Follow-up to cleaning up websockets
Renaming of functions with better understanding of reconnects.  Under
the original logic, reconnecting blithely created a new session if
the original no longer existed.  Now it will alert the user when this
happens.

Also hopefully fixes #381 as there was a bug of missing argument not
being caught by lisp's undisciplined typing.
2018-11-04 21:38:20 -06:00
John Miller
85d80f4394 Merge branch 'fix-oinfo-errors' 2018-11-02 16:16:39 -05:00
dickmao
5023b0796b Reconnect is not restart #377
Upon disconnection, the jupyter server apparently returns the same kernel for a given
notebook path input.  So reconnect is a thing, and restart is very
distinct from that.

Fixes #377
2018-11-02 11:32:12 -04:00
John Miller
db310073c4 Robustly build oinfo cache.
EIN tries to build a cached of pdef's for all potential completion symbols. This
is problematic because not all completion symbols have a pdef and can cause
python to throw exceptions in entertaining and hard to catch ways. We take a
liberal approach and ignore anything that throws an exception when we try to
inspect it.

Eldoc support should also be more robust because of these changes as well.
2018-11-01 20:26:42 -05:00
dickmao
db2856f445 Restart if kernel still alive needs to work 2018-11-01 20:08:10 -04:00
dickmao
d621944797 Clean up websocket callbacks
Coursera appears to kill websockets every minute or so, and I'm
observing firsthand the buggy behaviors described in #356.  This PR
cleans up the websocket code and kernel restart logic.  Removed
backwards compatibility for the v2 messaging api
as keeping it in the presence of the refactoring would make it more
broken that it already was.
2018-10-31 23:38:45 -04:00
dickmao
b950bd3a4c Fix "Kernel is busy..." bug
One line change to fix header not updating after cell execution
(keeps saying "Kernel is busy").

The bug does not manifest when running with `ein:debug` true since
EMACS's display loop updates more frequently with debug messages.

In tracking this bug, noticed eldoc support isn't quite there.
`__import__('ein').print_object_info_for(%s)` appears in
`ein-completer` and `ein-pytools`, and is invalid python syntax
afaict.  Took a few steps to make it whole, but incomplete.
2018-10-27 23:04:04 -04:00
dickmao
0490031ec8 Sane File Navigation
As emacs users we prefer and have the luxury of fuzzy file navigation
via ido and projectile.  From a notebook or notebooklist buffer, the commands

`C-c C-f` ein:file-open
`C-c C-o` ein:notebook-open

offer an ido alternative to point and click navigation.

To populate the ido lists, retrieving the content hierarchy is on by
default.  Two custom variables determine how wide and deep the content query
probes (currently at 2 levels deep and 6 directories wide).  Set both
to zero to turn off.

tkf half finished code to quickly go from local file buffers to notebook
mode via `C-c C-z` or `C-c C-o`.  This is now possible.  EIN will
start the server from a suitable parent directory of the visited file.

Enable ido completion for `notebooklist-login`.

Remove the albatross `ein-loaddefs.el` in favor of more standard
`ein-autoloads.el` that is not git tracked.

Convenience `make install` from git source (local alternative to
melpa).
2018-10-26 18:40:19 -04:00
Tomasz Mieszkowski
80cf9808a9 Fix ein:pytools-export-buffer 2018-10-13 19:59:41 +02:00
John Miller
4d9c05f2dc Maybe fix for #334
ein wasn't using the correct protocol for "inspect_request" messages for recent
versions (>5.0) of the protocol.
2018-09-09 09:44:59 -05:00
John Miller
d117ce915f Fix for #325
EIN's complete_request wasn't using the correct parameter for recent (> 5.0)
of the jupyter messaging protocol.
2018-08-16 08:43:25 -05:00
John Miller
926055e5fb Fix for #317.
Python JSON keywords use underscores - I am too use to the lisp way which uses
dashes.
2018-08-07 08:36:26 -05:00
John Miller
9ad9b4f4e6 Hooks to customize behavior during kernel execution.
New hooks `ein:pre-kernel-execute-functions', `ein:on-execute-reply-functions'
and `ein:on-shell-reply-functions'. See variable documentation for more
information.
2018-05-12 17:32:32 -05:00
Miller
710a5a6b91 ein-kernel: Handle generic stdin channel requests
That is, stdin requests that are generated by calls to `input' in Python (and
whatever is equivalent in other kernels).
2018-03-05 15:56:16 -06:00
John Miller
9d5309af59 Trying something new with testing.
Let's do this with ert-runner instead of python. Maybe it will work for once.
2018-02-27 14:38:13 -06:00
John Miller
045d9e9a89 Adjustments to debug logging.
Added some verbosity, removed some calls that were causing errors.
2018-02-14 18:24:20 -06:00
John Miller
34902e104f ein-company: Avoid completing around punctuation.
For some reason this causes the IPython kernel to return a very large number of
potential matches.
2017-10-20 11:55:31 -05:00
John Miller
4419818dde Merge branch 'back-to-eieio' 2017-07-29 23:08:35 -05:00
John Miller
4f5f29d351 ein-jupyterhub: Fix websocket connects.
Made sure to add the right cookies to the websocket request. Websockets
authenticate and everything is peachy now.
2017-07-25 16:57:32 -05:00
John Miller
9a1579d5f6 ein-jupyterhub: Support contents api
When running against jupyterhub master (which will someday be v0.8) can know log
in and make calls to the contents api.

Everything is working except for opening websocket connections.
2017-07-25 15:36:07 -05:00
John Miller
c78711a7c4 Back to eieio
It seems there are enough people out there still on Emacs 24 to warrant undoing
some of my recent moves away from eieio to cl-generic. For the near future I
will try to keep any changes that are incompatible with Emacs 24 to a
development branch. There is still probably plenty of opportunity to make the
code more future-proof for an eventual move away from eieio (I'm looking at you
oref and sref...)
2017-07-12 14:38:04 -05:00
John Miller
4b92b3adcc ein-kernel: Support (anew) starting kernels in older versions of jupyter.
Overzealously looking to the future was my sin here.
2017-05-18 09:04:49 -05:00
John Miller
91b5f605ee Implementat company doc-buffer command.
ein company backend will now show results of inspect_request in a company
documentation buffer when company requests documentation via the doc-buffer
command.
2017-04-21 17:57:16 -05:00
John Miller
d13e85b370 Minimally functional company-mode support.
There is now a company mode backend for ein. It generates completions by sending
complete_request to the running kernel so for the moment no jedi integration.

Configuring is maybe non-obvious - user should at minimum set
`ein:use-auto-complete` and `ein:use-auto-complete-superpack` to nil. Adding a
`(require 'ein-company)` probably should be done somewhere in the user's init
file. This could all be done better so I will attempt to address in later
commits.
2017-04-19 10:12:45 -05:00
John Miller
f0f0c0d206 Typos, more efficient kernelspec querying.
Silly typo in ein-kernel.el. Querying kernelspecs is slightly more efficient,
caching results when url is a string or port (previously just cached results for
ports).
2017-04-11 17:09:30 -05:00
John Miller
39f5d329f1 Functional tests start jupyter using ein:jupyter-server-start
This reduces some of the complexity in testein.py, but unfortunately running
tests is still unreliable. Running batchwise tests don't work at all in Windows,
and running from inside emacs tests often need to be run multiple times before
they pass.

The worst offender is the delete notebook test, which will pass on usually only
1 out of 3 tries.

Testing seems to have revealed a couple bugs, so win??
2017-04-07 08:18:41 -05:00
John Miller
8cb69fe4e7 Update to latest sessions API
Set POST body during session creation per
http://jupyter-api.surge.sh/#!/sessions/get_sessions.
2017-03-16 22:28:17 -05:00
John Miller
1b3aa10d51 Properly detect set_next_input payloads.
With this change %load magic works correctly.
2016-12-18 23:09:07 -06:00
John Miller
2b7b9f20fa Improving ipdb support.
EIN ipdb buffer should look better on Linux machines now. The extra characters
were someone's (ipython?) attempt at doing ansi coloring I think.

Also trying to make the ipdb comint buffer more canonical, with the hope to get
it to work with realgud. Not quite there yet, unfortunately.
2016-11-29 22:06:03 -06:00
John Miller
c70dee7733 Taceback from cell edit buffer, more informative version
Jump to tracebacks from cell edit buffers.

Slightly more informative on version of jupyter we are working with.
2016-11-05 17:49:52 -05:00
John Miller
19303cb637 Fix notebooklist render, remove connect_request
Notebooklist was not showing kernel status anymore.

Connect_request messages are deprecated since v5.0 of the messaging
spec, and ein never did much anyway with the message.
2016-10-29 09:43:40 -05:00
John Miller
586879598a Switch kernel in running notebook.
Does so by changing kernelspec and restarting notebook.
2016-08-26 20:52:54 -05:00
John Miller
8aaae29a23 Fix what introducing kernelspecs broke.
Embarassing, really. Missing parameters and some poorly placed branching
logic conspired to bring down ein on IPython 2.x. Should be better now.
2016-04-15 16:08:53 -05:00
John Miller
8efa954308 Account for when url-or-port is an integer
For determining websocket protocol, if url-or-port is an integer don't
need to check if it contains `https://`.
2016-03-30 21:38:33 -05:00
John Miller
847d4a0d3e closes #81
This works by detecting if 'https:' appears in the url-or-port string,
which will be the case if you call `ein:notebooklist-open` using https:
+ url + port.

Note also that on windows, at least, I get SSL errors when using curl as
request backend. Using url-retrieve eliminates the errors and SSL access
works as advertised.
2016-03-30 21:32:14 -05:00
John Miller
90920e28c6 Create notebooks with user-specified kernels.
This works with the New Notebook widget in the notebooklist,
need to check if the menu commands also work.
2016-01-13 08:30:15 -06:00
John Miller
a89aa6aebd Including kernelspecs into the notebooklist view.
EIN now shows kernels available for the Jupyter server being view in the
notebooklist buffer. We don't do much with the info, yet, though.
2016-01-13 07:52:02 -06:00
John Miller
447854fdac Query Jupyter for kernelspecs
Structures and logic for querying Jupyter server for a list of available
kernelspecs.
2016-01-11 09:20:40 -07:00
John Miller
0bbe7ad204 Be more friendly in ein:notebooklist-open
Accept URL's even if protocol not specified. If no protocol is specified
then assume http.
2015-07-08 16:17:54 -05:00
John Miller
e76251f8ef Fix for #63
EIN didn't know how to generate websocket URL's for remote hosts. It
does now.
2015-07-08 13:37:09 -05:00
John Miller
6d667f630a Fix typo in ein:kernel-del. 2015-07-08 13:10:45 -05:00
John Miller
488bb67f09 Add kernel reconnect command, fix restart.
New commend `ein:notebook-reconnect-kernel` which will close then reopen
the websocket connection to a running kernel - without killing the
kernel.

Was not correctly killing and restarting the kernel in
`ein:kernel-restart.`

Fixed `ein-restart-kernel` to use REST API to kill kernel, then
restart/reconnect, again using the REST API.

Got rid of the `ein:kernel-stop` function. Seems confusing to have
'stop' and 'kill' methods running around.
2015-07-05 22:27:52 -05:00
Diego Berrocal
8d02d8b6e4 Important fix, there is a g where there shouldn't be.
This goes into the MELPA version, making it unusable
2015-05-28 14:19:09 -05:00
John Miller
0cf283a43b Use session query to show running kernels.
Stopping a kernel now doesn't automatically close a buffer, nor does
closing a buffer automatically stop a running kernel. This is
functionality more in line of what EIN supported for IPython 0.x and
1.x.
2015-05-28 11:56:40 -05:00
John Miller
81583c4411 API for querying active sessions, don't kill session on closing buffer. 2015-05-27 21:49:48 -05:00
John Miller
a4c6892551 Support set-buffer-file-name
In support of fixing issues #46 and #47.
2015-05-15 23:23:56 -05:00
John Miller
d2681d88e3 Proper implementation of #42, fix restart-kernel command.
Can jump to notebook cells from traceback buffer, kernel restart command
works on both IPython 2.x and 3.x.
2015-05-12 15:12:33 -05:00