-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
add ability to bind to a ruby kernel #2643
Conversation
this (for now) need the iruby patch of my branch, and to modify a hardcoded path in IPython/zmq/rubykernel.py Launch with ipython notebook --MappingKernelManager.kernel_manager_class='IPython.zmq.rubykernel.RubyKernelManager' need zmq, uuid and hmac gem, and ruby 1.9.3
The other kernels should be separate repos/projects under the ipython org. I think we should try to make these "packages" in whatever language they are written. So for the ruby kernel, we should be able to easily create a gem and install it like any other ruby package. |
@@ -28,6 +28,7 @@ | |||
|
|||
from IPython.config.configurable import LoggingConfigurable | |||
from IPython.utils.importstring import import_item | |||
from IPython.zmq.rubykernel import RubyKernelManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really need to be imported here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you're right.
So, we need to build a 'PopenKernelManager' I guess with a configurable command line.... This should handle pretty much every basic things that are not python... |
does this look better ? I just have to add this in my config to run the ruby kernel : [.ipython/profile_ruby/ipython_notebook_config.py]
and start notebook with I think it should be able to run pretty much anything... |
The existing kernel manager already starts a subprocess, and the launch command could already be customized (via passing launch). For instance, the iruby project which you reference didn't need to touch IPython at all to work. It seems this subclass just adds one configurable as an easier way to do what was already possible. Why not just add this configurable to the base KernelManager class? |
I didn't looked deep enough in kernelmanager and missed the configurability. And actually the original iruby added another kernel launcher to launch the ruby kernel. I'll try to see if I can do what you suggest. |
Yes, I wrote it :) - but the important thing is that IPython itself did not need to be modified - the kernel launch args were not configurable, but the launch function was, so it needed a subclass assigned via the KMClass configurable. But that subclass is totally unnecessary if the launch command is configurable in the base class. There is a benefit to adding the configurable to the base class rather than a subclass, because that also means it is inherited by other subclasses (Qt, Blocking, etc.). The reason it isn't there is probably just that the base KM is not a Configurable, but that's just a historical artifact since it was written before the Config stuff - it absolutely should be a Configurable. |
Question to @minrk, Making Would it make more sens to make The reason would be that then, the different kernel wouldn't have to deal with writing/installing any python files/module. I might be missing something in the way this works though... |
Ah, I forgot about the remnants still in entry_point. That means a little bit more needs to change than I thought. But no, don't make |
a bit more: base_launch_kernel does two things:
It should be split so those are separate actions, and a custom Popen command skips the whole command assembly step. |
I just had a look at the following modules in
At least from a first glance, they are all sort of a rats nest of functions and classes that call each other. It is tempting to start refactoring this in a clean way, but I worry that it is actually quite subtle because of the different ways that kernels are used. But I also remember that this code grew in a very organic way and hasn't been cleaned up since the beginning. @minrk do you have a sense of why things are such a mess - is that needed? Is part of this the complexity of IPython.parallel also using the same kernel? |
It is totally appropriate to clean this up, but do note that |
Forgot to mention: No, there shouldn't be anything related to IPython.parallel in the complexity here. The last major step of merging the two kernels is to make IPEngineApp a minimal subclass of IPKernelApp. |
Thanks Min that really helps. I guess with #2724 I will just wait. I can accomplish everything I need to with the current design, it is just a bit messy.
In what way is |
If you want to start a kernel and customize it in any way whatsoever, you must make this import. It is equivalent to the embedded classes -
Sensible
The main reason was to separate IPython-shell-specific startup from just 'generic interpreter startup'. Again, the reason being that we used to have a pure Python Kernel. I think the main argument against merging them is that we may again, but that's not a particularly strong one. I would maybe just put IPKernelApp as-is after KernelApp in zmq.kernelapp, but merging the two is fine as well. |
OK great, I will try to help review #2724 and keep my eye on these things On Thu, Jan 10, 2013 at 9:58 PM, Min RK notifications@github.com wrote:
Brian E. Granger |
I cleaned up the kernel manager code a lot in #2775 but didn't really change how the custom launcher is specified. Bu tin either case, I don't think the approach in this branch is the way to do. In the long run, I think we will want to build an additional argument into MultiKernelManager.start_kernel, namely, the name of the kernel to start: ipython, ruby, etc. This list should be where the configuration happens, Each kernel name should be associated with the required launcher. For now can we just get by with what we have until we really get to thinking about multi-kernel support an what that will look like? |
@ellisonbg that approach doesn't get users anywhere without updates to IPython itself. I think the point here is that we should have a configurable for launching custom kernels, either with A) a custom launch_kernel function, as a DottedObjectName Now, maybe this should be a mapping by kernel-name, but in any case, we should expose the fact that the KernelManager as it already is can launch custom kernels. It's just not exposed to config. It should be straightforward to add one or both of these, particularly now that KernelManager itself is Configurable, as it always should have been. |
I wasn't very clear in my description. I agree that these things should On Wed, Jan 16, 2013 at 10:18 PM, Min RK notifications@github.com wrote:
Brian E. Granger |
FYI, perl kernel : |
Actually you did, just not here. I was going to submit a new PR with the changes discussed here (split base_launch_kernel into its two separate actions, and expose Popen command as KM config, avoiding the need for subclass), and suggest closing this when I submit that, rather than closing without having a replacement to point to. |
Hehe, if I actually were old I could make some joke about my memory going On Wed, Jan 23, 2013 at 1:06 PM, Min RK notifications@github.com wrote:
Brian E. Granger |
replaced by #2854 |
This need the iruby kernel of my repo, (https://github.com/Carreau/iruby)
And to be modified as ruby interpreter and zmq-kernel path in IPython/zmq/rubykernel.py
Launch with (for example)
ipython notebook
--MappingKernelManager.kernel_manager_class='IPython.zmq.rubykernel.RubyKernelManager'
need zmq, uuid and hmac gem, and ruby 1.9.3
I would love to change the ruby interpreter path to
ruby1.9.3
but Even with latest ruby installed, it is not in my path, so I don't know how what the ruby way is.Also any idea of how we want to managed external kernel ? Do we put them in main IPython repo ? keep them separate ?