[IPython-dev] Using the IPython API to configure profiles

Matthias BUSSONNIER bussonniermatthias at gmail.com
Tue Feb 25 08:27:23 EST 2014


Hi, 

Le 25 févr. 2014 à 13:55, Doug Blank a écrit :

> On Tue, Feb 25, 2014 at 7:35 AM, Clare Sloggett <claresloggett at gmail.com> wrote:
> Hi all,
> 
> I'm new to this list so please let me know if it's not a good right place for this question, etc.
> 
> I'm wondering if it's possible to use the IPython API to generate ipython profile configuration files, and if so, where I can find some guidance on doing this. 
> 
> The motivation is: I'm using python to automate some setup of ipython notebook. I can use python to call the shell with "ipython profile create nbserver" and then to edit the resulting ipython_config.py file. However since I'm in python already, this seems roundabout - is it possible to just use the IPython API directly to do these things?
> 
> I've found the API reference at http://ipython.org/ipython-doc/stable/api/index.html .
> 
> I haven't found any tutorials or guides on using the IPython API, so I'm just hunting through the reference, and maybe this is why I'm having trouble working out the right way to approach this task. Is creating an ipython profile, and configuring it, a sensible thing to do using the API, and if so, can anyone give me some pointers? 
> 
> So far I have found a way (maybe not the best way?) to create a new profile directory using IPython.core.profiledir.ProfileDir.create_profile_dir_by_name(), but I haven't discovered any good way to handle configuration.
> 
> Thanks in advance!
> 
> As a new user of IPython, I can't answer your question. But we just did this same task with our non-Python, external kernel. Here is what we are doing: we added a flag to our program (calico --create-profile) that will create an IPython profile. The main iprofile_config.py only needed a couple of options (c.KernelManager.kernel_cmd) and so we create that file directly. We also recursively copy from a setup directory to the ($ipython locate)/profile_calico/   directory, so that if we ever want to have custom files, we can just drop them into our setup directory, and they'll get copied over when you --create-profile.


We are working on that. 

IPython 2.0 will allow you to create config file in json which will be easier to modify for non-python app and/or to automatize.
Right now the logic loop through all the possible configurable is not pretty and use print in lots of places (like for --help-all). 
So we could refactor it, but this will most-likely be for 3.0 or later. 

We plan on having a API to edit config at some point, but it is not in motion yet.
-- 
M



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140225/973bcbc2/attachment.html>


More information about the IPython-dev mailing list