Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-process kernel support (take 2) #2397

Closed
wants to merge 14 commits into from
Closed

In-process kernel support (take 2) #2397

wants to merge 14 commits into from

Conversation

epatters
Copy link
Contributor

This PR is functionally equivalent to #2382 but involves substantially less refactoring. Note, however, that ZMQ is now required.

The gist referenced in the previous PR contains usage examples: https://gist.github.com/3659874.

@epatters
Copy link
Contributor Author

@ccordoba12, I'm now responding to your questions in #2382 (comment). Sorry for the delay.

  1. The EmbeddedKernel is really only an abstraction layer to let frontends talk to the underlying InteractiveShell. If you want to get object info from elsewhere in Spyder, you should bypass the kernel and call kernel.shell.object_inspect() directly. This is an example of how the in-process kernel is extremely convenient.
  2. Here's an example:
kernel = EmbeddedKernel()
km1 = QtEmbeddedKernelManager(kernel=kernel)
km2 = QtEmbeddedKernelManager(kernel=kernel)
kernel.frontends = [km1, km2]
[assign km1 and km2 to two different frontend widgets]

This is just like the out-of-process situation: each frontend should have its own kernel manager, but the kernel managers may be connected to the same kernel. However, unlike the out-of-process situation, you must explicitly tell the kernel about the frontends.

  1. No JSON connection files are used.
  2. By default, stdout/stderr will be directed to the frontend only during execution. If you want stderr to always appear in the frontend, you can manually set sys.stderr = kernel.stderr.

@@ -37,7 +37,7 @@ class ZMQShellDisplayHook(DisplayHook):
topic=None

session = Instance(Session)
pub_socket = Instance('zmq.Socket')
pub_socket = Any()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of these Any() traits, do you think it's worthwhile to do a simple trait validator that checks for the necessary interfaces (just send_multipart, I believe)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPython requires 2.6 now, doesn't it? We could make an ABC that checks for the necessary methods, and then use a plain Instance trait.

http://docs.python.org/library/abc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Robert. I'll try this.

@minrk
Copy link
Member

minrk commented Sep 11, 2012

Thanks for doing this, it does make it easier to see what's actually going on. Ultimately, we certainly will want to make it work without zmq imports, because once it is up to snuff, plain single-process terminal IPython should be using the embedded Kernel/KernelManager code, so we finally have a consolidated codebase.

@epatters
Copy link
Contributor Author

@fperez, @minrk, any word on this? Thanks.

@minrk
Copy link
Member

minrk commented Sep 15, 2012

I don't have time for a full review, but most of it looks good. One concern is that the embedded kernel manager is almost entirely a copy/paste from the original with no inheritance. That doesn't seem right to me, and the cost of large duplicate code, particularly in a relatively unused path like this (e.g. the old pykernel), has shown itself to be quite high. Can you make the case for not reusing any code?

Also, a minor naming consideration: We have a notion of 'embedding', which is IPython running in a particular namespace. This is largely unrelated to that, where embedded means the kernel is in the same process as the frontend. Perhaps there is a better name that we are not already using to mean something else?

@epatters
Copy link
Contributor Author

I think you should look at the kernel managers a little more carefully. In contrast to the EmbeddedKernel in my original approach, the EmbeddedKernelManager here duplicates only interface, not implementation. This is because the implementation of the (base) kernel manager is almost entirely devoted to IO loops and kernel process management, which are irrelevant to the embedded case. Were we writing in, say, Java, it would be proper to define a kernel manager interface, and have two separate implementations for in and out of process kernels. In Python, we are settling (perhaps incorrectly) for duck typing in this case. The maintenance problem is only one of maintaining a consistent kernel manager interface, which you must do in any case to avoid breaking users' code.

Also, notice that for the kernel manager subclasses (both blocking and Qt), where it does make sense to share code, I have done so through the (somewhat kludgey) technique of mixin classes.

As to the name I don't particularly care. Originally, I eschewed InProcess for being two words and hence awkward to type, but if you prefer that or something else I would be happy to change it.

@ccordoba12
Copy link
Member

Thanks @epatters for your explanation. It seems this really is the right approach for us. One more thing: it's not entirely clear for me if EmbeddedKernel is based or not on ZMQ. I'm asking this because we would like our users could enjoy the benefits of IPython.parallel too.

Besides, I downloaded your branch to try to play with it but it's giving me a segmentation fault if I try to run your gist or even when I'm just trying to start qtconsole. I don't know where that could be coming from, because master is working just fine.

@epatters
Copy link
Contributor Author

EmbeddedKernel doesn't use ZMQ (though at the present time, it does import ZMQ). For the sake of frontends, it sends messages conforming to the messaging spec, but through "dummy" sockets that don't do anything. As far as you're concerned, this is just an implementation detail.

I'm afraid I know very little about IPython's parallel infrastructure. What did you have in mind?

As for the segfault---that's not good. What platform are running? What version of PySide or PyQt? Could you give a stack trace? Thanks.

@takluyver
Copy link
Member

Could you add an example like that in the gist to the examples directory (at least for Qt - I wouldn't promote the terminal one at present)?

Also, one key use case for this is 'embed a shell with access to Python objects already in the process' - what's the most efficient way to start a kernel with specific objects in the namespace?

@hsyed
Copy link

hsyed commented Sep 17, 2012

Hello, Thomas K guided me to this branch from stack overflow. I am trying to get the example code to run (https://gist.github.com/3659874#file_embedded_qtconsole.py) using this branch. But I am getting the following error :

Traceback (most recent call last):
File "ipqt.py", line 31, in
main()
File "ipqt.py", line 14, in main
km.start_kernel()
File "../ipython/IPython/frontend/qt/base_kernelmanager.py", line 223, in start_kernel
self.started_kernel.emit()
AttributeError: signal was not defined in the first super-class of class 'QtEmbeddedKernelManager'

I'm not a python expert, or a QT expert (C/C++ is my Forté).

I'm also interested in what Thomas is talking about in the previous comment --i.e., passing objects from my pyqt app into the ipython embedded shell.

@epatters
Copy link
Contributor Author

@takluyver, I'll work on this. I have a question for you, though. What is the best way to modify/replace the user namespace using InteractiveShell? Because that's basically all you would do.

@hsyed, are you running PyQt? If so, what version? I only tested the code under PySide---probably a terrible mistake.

@takluyver
Copy link
Member

@epatters : If possible, the simplest way is to pass either user_ns or user_module when InteractiveShell is instantiated. If not, I think this should work:

shell.init_create_namespaces(user_ns={'foo': 1})
# You could alternatively pass `user_module`, which should be
# a module-like object, so user_module.foo works

# To add IPython features like `exit`, `In`, `get_ipython` etc.:
shell.init_user_ns()

@hsyed
Copy link

hsyed commented Sep 17, 2012

@epatters Yes I am using PyQt. I suppose I could install pyside. But it will probably go pear shaped since my code runs PyQt ? PyQt is at 4.9.4.

@epatters
Copy link
Contributor Author

@hsyed, PyQt should absolutely work. I'm going to test it out right now.

@epatters
Copy link
Contributor Author

Or, what I mean to say, is that PyQt is supposed to work.

@epatters
Copy link
Contributor Author

@hsyed, this should fix the PyQt4 problems (including yours, @ccordoba12).

@epatters
Copy link
Contributor Author

@takluyver, the reason I ask is that EmbeddedKernel and EmbeddedKernelManager really only exist to present a consistent interface to the frontends. If you want to do anything programatically--like modify the user namespace--you should just use the underlying InteractiveShell (accessible from the shell attribute of EmbeddedKernel). There is no magic here, which is what makes the in-process kernel very convenient (if unsafe).

I assumed that updating the user namespace would be as simple as

kernel.shell.user_ns.update({...})

Is that right?

@takluyver
Copy link
Member

Good point, thanks. In fact, there's a shell.push(dict) method which does that and takes care of hiding or unhiding variables. Could we add that to the example from your gist and put it in docs/examples/?

@epatters
Copy link
Contributor Author

Great, that's exactly what I wanted to know. I'll add an updated example to the docs.

@epatters
Copy link
Contributor Author

I wasn't sure exactly where to put this, so I created a 'frontend' directory.

@hsyed
Copy link

hsyed commented Sep 17, 2012

I haven't tried the code yet. But I was wondering if I could share references between the two interpreters ? Say if I wanted to pass a reference to some functions between a GUI app and an embedded interpreter, would this work ?

@epatters
Copy link
Contributor Author

@hsyed, you could indeed share references between the two interpreters, provided that everything remains in process.

@takluyver
Copy link
Member

@hsyed: That's what I was just discussing with @epatters. Have a look at the example that's now in the pull request, specifically the kernel.shell.push() line. You can simply push a dictionary referring to whatever functions you want to expose in the shell.

As a technical detail, there's only one interpreter, used by both the PyQt application and the in-process kernel. So you just need to add the relevant objects to the namespace that the IPython shell is using. That's what the push method does.

@hsyed
Copy link

hsyed commented Sep 18, 2012

@takluyver fantastic, Was a bit confused since technically one could always serialize a dictionary across using pass-by-copy :D

@epatters epatters reopened this Sep 26, 2012
@epatters
Copy link
Contributor Author

Blast, GitHub! Anyway, @fperez, please let me know if anything remains to be done here.

@epatters
Copy link
Contributor Author

Oh, and my last day before heading back to school is Friday, so we need to get this wrapped up soon.

@fperez
Copy link
Member

fperez commented Sep 26, 2012

Mmh, something's gone awry with those tests. While running them via nosetests as you did above I get the same results, if I use the official test runner, iptest, they crash catastrophically. iptest is a thin wrapper around nosetests that sets a few variables, in particular the global ipython instance. It's a bit clunky to do so, but we've found it in the past to be necessary to have an ipython instance each group of tests can rely on, so for now we're stuck with that.

So I'm afraid that before we merge this one, we'll absolutely have to figure out what's going on here and get the 'real' test suite passing. For more details on how to run our tests, see the testing section of our docs.

This is what I get:

longs[junk]> iptest IPython.inprocess
EEEEEEEE
======================================================================
ERROR: Does pylab work in the in-process kernel?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernel.py", line 34, in test_pylab
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does the in-process kernel handle raw_input correctly?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernel.py", line 43, in test_raw_input
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does the in-process kernel correctly capture IO?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernel.py", line 57, in test_stdout
    kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does requesting completion from an in-process kernel work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernelmanager.py", line 67, in test_complete
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does executing code in an in-process kernel work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernelmanager.py", line 59, in test_execute
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does requesting history from an in-process kernel work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernelmanager.py", line 91, in test_history
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does the in-process kernel manager implement the basic KM interface?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernelmanager.py", line 37, in test_inteface
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

======================================================================
ERROR: Does requesting object information from an in-process kernel work?
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/tests/test_kernelmanager.py", line 79, in test_object_info
    km.start_kernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/kernelmanager.py", line 369, in start_kernel
    self.kernel = InProcessKernel()
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/inprocess/ipkernel.py", line 66, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.py", line 147, in __init__
    user_ns     = self.user_ns,
  File "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/configurable.py", line 329, in instance
    '%s are being created.' % cls.__name__
MultipleInstanceError: Multiple incompatible subclass instances of InProcessInteractiveShell are being created.

----------------------------------------------------------------------
Ran 8 tests in 0.019s

FAILED (errors=8)

@epatters
Copy link
Contributor Author

@fperez, I think this is related to something I was worried about, but which I forgot to bring up here, namely that InteractiveShell seems to be a singleton. This assumption doesn't work so well for the single-process model, in which it is perfectly reasonable to have multiple kernels, each with their own interactive shell. At least, that has been my mental model and it's something that people will expect to work.

Here's the code which is surely problematic:

https://github.com/epatters/ipython/blob/d32bdb0b1a8916079540dda4e798272e45c41b4a/IPython/zmq/ipkernel.py#L143

I know very little about the motivation and uses for the singleton interactive shell, so you are probably better placed than I am to decide what to do about this. What do you recommend?

@ellisonbg
Copy link
Member

There are two layers to the singleton stuff:

  • One is that Python has various hooks (excepthook, displayhook, sys.stdout
    and friends) that are process wide globals. IPython hooks into those to
    carry out various tasks. I don't exactly recall, but I think we try to
    set/restore these each time code is run, but we may not be doing they in a
    fully robust manner yet.
  • We have various parts of the code that need to find the currently active
    interpreter and the typical pattern is to call InteractiveShell.instance.
    This is used in parts of the code where there is not an easily accessible
    .shell attribute.
  • Much of the singleton-ness is historical and not fundamental.

I think we could move away from this assumption, but it would probably take
some pretty careful work. If we got rid of the assumption we would need
some sort of multi-shell API that allows us to manage which instance is
active and get references to it. Mostly just an issue of someone diving in.

On Wed, Sep 26, 2012 at 1:32 PM, Evan Patterson notifications@github.comwrote:

@fperez https://github.com/fperez, I think this is related to something
I was worried about, but which I forgot to bring up here, namely that
InteractiveShell seems to be a singleton. This assumption doesn't work so
well for the single-process model, in which perfectly reasonable to have
multiple kernels, each with their own interactive shell. At least, that has
been my mental model and it's something that people will expect to work.

Here's the code which is surely problematic:

https://github.com/epatters/ipython/blob/d32bdb0b1a8916079540dda4e798272e45c41b4a/IPython/zmq/ipkernel.py#L143

I know very little about the motivation and uses for the singleton
interactive shell, so you are probably better placed than I am to decide
what to do about this. What do you recommend?


Reply to this email directly or view it on GitHubhttps://github.com//pull/2397#issuecomment-8904199.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@epatters
Copy link
Contributor Author

Thanks for the information, Brian.

What do you recommend we do right now? I certainly can't undertake any serious project-wide refactor.

@ellisonbg
Copy link
Member

Hmm, that is going to be a tough one. I haven't followed the discussions
about the architecture of the single process kernel, so I don't know how
everything works. Are you using the standard QT console and just spawning
in process kernels, but talking to them over the usual zeromq channels?
Let me assume you are doing that for now.

You need only a few things:

  • You need separate namespaces.
  • You need to keep track of which namespace is active for purposes of
    handling various messages.

What about creating a single kernel that all qtconsoles connect to and just
swaping out the namespaces to adjust for which is the active one. You
could build a class that manages these namespaces and use that to build the
logic needed to hook the kernel up to the currently active
namespace+qtconsole.

Might be a bit ugly, but would avoid having to dive into some complex
issues with the ipython core.

On Wed, Sep 26, 2012 at 2:38 PM, Evan Patterson notifications@github.comwrote:

Thanks for the information, Brian.

What do you recommend we do right now? I certainly can't undertake any
serious project-wide refactor.


Reply to this email directly or view it on GitHubhttps://github.com//pull/2397#issuecomment-8907384.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@fperez
Copy link
Member

fperez commented Sep 26, 2012

@epatters, I just made a single-commit PR against your branch that fixes the problem for now. The long-term solution is to cleanly rework our assumptions about where we truly need singletons, but that's indeed far too much of a refactor to undertake in the context of this PR.

Now, because of these issues, you are likely only going to be able to use one kernel at a time per-process, but that's still progress. And with these tests in-place, we can then gradually refactor things out until we confine our singleton assumptions only to where they make sense (at the application level, which is where they match the OS singleton - the process).

…eton.

Since the in-process group makes its own shells, it should avoid
creating the global singleton.
@epatters
Copy link
Contributor Author

Thanks, @fperez. I cherry-picked the commit.

I can confirm that iptest IPython.inprocess works, but I get the singleton errors when I run iptest on the whole project. Is this the behavior you expected?

@fperez
Copy link
Member

fperez commented Sep 27, 2012

Mmh, it works for fine for me whether I run it on the whole project or part of it... That's very strange...

@fperez
Copy link
Member

fperez commented Sep 27, 2012

BTW, the error reported by the Travis build is b/c your pylab test isn't protected by a decorator to skip it if matplotlib isn't present. See this for an example on how to do it.

@epatters
Copy link
Contributor Author

Thanks. Hopefully the tests start passing on the build bot now.

@fperez
Copy link
Member

fperez commented Sep 27, 2012

Did you sort out the problem on your machine? I don't understand what's going on for you...

I added this line:

print(sys.argv[1:]); sys.exit(0)  # dbg

at line 502 of iptest.py, right before the if statement. That showed me that indeed, during the full run, IPython.inprocess is passed to sys.argv and things behave as expected.

Why don't you try debugging it there until we sort it out... What platform are you on?

@epatters
Copy link
Contributor Author

@fperez, I will look at this first thing tomorrow. Unfortunately, I have a Friday deadline for some unrelated work and will be offline for the rest of the day.

@epatters
Copy link
Contributor Author

Oh, and my work machine is OS X.

@fperez
Copy link
Member

fperez commented Sep 27, 2012

OK; @minrk, @ellisonbg if you guys could run test_pr on this one from your OSX boxes, it would help us to have an extra data point, as it's passing fine for me on linux.

@epatters, the current failure on Travis looks like a legitimate issue on 3.2 only (the 2.x builds are now passing). Could you look into that? And that log shows one thing we need to fix: the in-process kernel should be initialized with tracebacks in no-color mode so that we can read them without all the ANSI gunk on the screen.

@minrk
Copy link
Member

minrk commented Sep 27, 2012

passed on 2.6/7, failed on 3.2.

@fperez
Copy link
Member

fperez commented Sep 27, 2012

Thanks @minrk. @epatters that does indeed look like a legitimate 3.2 failure, I see it on linux too; I hadn't tested 3.2 earlier when I reported success.

@bfroehle
Copy link
Contributor

I believe the failure is coming because raw_input was renamed to input in Python 3. So the test needs to either call a compatibility function like IPython.utils.py3compat.input() or you'll need to do something like:

km.shell_channel.execute('try:\n    x = raw_input()\nexcept NameError:\n   x = input()')

or maybe

if py3compat.PY3:
    km.shell_channel.execute('x = input()')
else:
    km.shell_channel.execute('x = raw_input()')

Edit: hmf, maybe not. I should try these suggestions out first. Anyway, I second @fperez's suggestion to turn off the colorization (how?) so the traceback is readable.

@hsyed
Copy link

hsyed commented Oct 2, 2012

Hello again, I'm wondering if there is a way of getting the widget to get keyboard focus when I click on it ? I have my ipython widget in a tab layout and when I click on the tab I have to click again into the widget, it would be nice if the currsor would move to its position when the widget is activated.

Also, do you know how I would configure the embedded shell to have --pylab=inline functionality ?

@takluyver
Copy link
Member

@epatters I'm just checking the pull request queue. Will you have time to sort out the input/raw_input issue any time soon? Thanks.

@tomcraw00
Copy link

Any update on this? I've been messing around with putting this into a project but I don't want to get left behind by the main trunk of ipython.

@pberkes
Copy link
Contributor

pberkes commented Dec 24, 2012

Hi, I just wanted to bump this pull request: using an in-process shell for application scripting is a scenario that I see quite frequently and it would be great to have it in IPython.

What is left to be done for the PR to be merged? I may be able to spend some time on it.

@jdmarch
Copy link

jdmarch commented Dec 27, 2012

Closing because superseded by PR #2724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet