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

Finish up embed_kernel #1640

Merged
merged 13 commits into from Apr 23, 2012
Merged

Finish up embed_kernel #1640

merged 13 commits into from Apr 23, 2012

Conversation

minrk
Copy link
Member

@minrk minrk commented Apr 21, 2012

This is just a few more commits on top of PR #1357, addressing the pending review on that one.

Changes, per review in #1357:

  • fix inheritance of user_module/ns (IPKernelApp never has them)
  • remove unnecessarily specific extract_module_locals_above
  • super basic tests
  • note in docs
  • docstrings

Extra edit, to better match IPython.embed():

  • embed_kernel takes **kwargs to allow configuration of the kernel

scottt and others added 13 commits January 31, 2012 08:27
This patch adds IPython.embed_kernel() as a public API.
Embedding an IPython kernel in an application is useful when you want to
use IPython.embed() but don't have a terminal attached on stdin and stdout.

My use case is a modern gdb with Python API support
 #!/usr/bin/gdb --python
 import IPython; IPython.embed_kernel()
this way I get to use ipython to explore the GDB API without
the readline librarry in gdb and ipython fighting over the terminal settings.

A Google search revealed that other people were interetsted in this use
case as well:
http://mail.scipy.org/pipermail/ipython-dev/2011-July/007928.html
https://github.com/ipython/ipython/pull/1357/files#r400153
Stop embed_kernel() from parsing sys.argv since to support being called from
a environments with their own command line args.
* `**kwargs` are passed to KernelApp for config
* add docstring
* IPython.zmq.ipapp.embed_kernel is now fully functional
* allow re-entry to kernel
@fperez
Copy link
Member

fperez commented Apr 23, 2012

This looks great, @minrk, thanks! Your new commits pretty much finish up the job. The only thing I can think of is that I remembered we have these two examples (both of which depend on this file of kernel embedding.

It would be great to update those examples to these cleaner APIs. But if you're swamped, I can do that in a separate PR, just let me know. In that case we'll merge this one and I'll do that later.

@minrk
Copy link
Member Author

minrk commented Apr 23, 2012

Sure, I'll do that tomorrow.

-MinRK

On Apr 22, 2012, at 20:15, Fernando Perezreply@reply.github.com wrote:

This looks great, @minrk, thanks! Your new commits pretty much finish up the job. The only thing I can think of is that I remembered we have these two examples (both of which depend on this file of kernel embedding.

It would be great to update those examples to these cleaner APIs. But if you're swamped, I can do that in a separate PR, just let me know. In that case we'll merge this one and I'll do that later.


Reply to this email directly or view it on GitHub:
#1640 (comment)

@fperez
Copy link
Member

fperez commented Apr 23, 2012

On Sun, Apr 22, 2012 at 11:04 PM, Min RK
reply@reply.github.com
wrote:

Sure, I'll do that tomorrow.

Awesome, thanks!

@minrk
Copy link
Member Author

minrk commented Apr 23, 2012

Hm, those examples integrate a kernel, but don't seem to actually embed one (they aren't invoked into a specific namespace). I'm not sure how they would benefit from using embed_kernel.

@fperez
Copy link
Member

fperez commented Apr 23, 2012

Right, but that's b/c when I first wrote them I had trouble making them a regular embedded example... Actually never mind: it's easier for me to clean these guys up once we merge this PR rather than asking you to read my mind :) Ignore those guys, and I'll clean them up as soon as I have a minute.

With that aside, this looks good to go! Anything in your mind that we should hold for?

@minrk
Copy link
Member Author

minrk commented Apr 23, 2012

Okay, I'll let you look into those, then.

This seems good to me, then.

fperez added a commit that referenced this pull request Apr 23, 2012
Add IPython.embed_kernel() as a public API.

Embedding an IPython kernel in an application is useful when you want to use IPython.embed() but don't have a terminal attached on stdin and stdout.
@fperez fperez merged commit 14dcd99 into ipython:master Apr 23, 2012
@fperez
Copy link
Member

fperez commented Apr 23, 2012

thanks everyone, this is great work! @scottt: we really appreciate your patience pushing this through multiple PRs. This particular feature is very important, so I'm thrilled to see it in.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Add IPython.embed_kernel() as a public API.

Embedding an IPython kernel in an application is useful when you want to use IPython.embed() but don't have a terminal attached on stdin and stdout.
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

3 participants