[IPython-User] Is there a way to upgrade IPython configuration files?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[IPython-User] Is there a way to upgrade IPython configuration files?

Damien Garaud
Hi there,

I'm trying to manage my IPython configuration & profiles in a Git repo at
this configuration on any computer (at home, at work, on a VM, etc.).

I know that:

   ipython profile create jazz

creates a few IPython configuration files at ~/.ipython/profile_jazz.

For now, I've three files generated by IPython:

- ipython_config.py
- ipython_notebook_config.py
- ipython_qtconsole_config.py

which are the same for my all profiles.

I wonder if there is a way to upgrade a IPython configuration file when there is
a new IPython version. I slightly modified the default IPy config files and I
would like to easily merge my future modifications with a new version of these
files.

Thanks,
Damien G.


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to upgrade IPython configuration files?

Matthias Bussonnier

Le 5 août 2014 à 17:48, Damien Garaud <[hidden email]> a écrit :

Hi there,

I'm trying to manage my IPython configuration & profiles in a Git repo at
this configuration on any computer (at home, at work, on a VM, etc.).

I know that:

   ipython profile create jazz

creates a few IPython configuration files at ~/.ipython/profile_jazz.

For now, I've three files generated by IPython:

- ipython_config.py
- ipython_notebook_config.py
- ipython_qtconsole_config.py

which are the same for my all profiles.

Default configuration files are completely commented, the comments are just here
as information for users. 


I wonder if there is a way to upgrade a IPython configuration file when there is
a new IPython version. I slightly modified the default IPy config files and I
would like to easily merge my future modifications with a new version of these
files.

You can keep only the relevant lines and append them to the new config file,
this should be enough. 
Somehthing like 

cat ~/.ipython/profile_default/ipython_config.py | grep -v -e '^#' | grep -v -e '^$' | grep -v get_config 

Should give you all the line relevant line of your config.
— 
M


Thanks,
Damien G.

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to upgrade IPython configuration files?

Damien Garaud
2014-08-05 19:44 GMT+02:00 Matthias Bussonnier <[hidden email]>:

>
>
> Le 5 août 2014 à 17:48, Damien Garaud <[hidden email]> a écrit :
>
> Hi there,
>
> I'm trying to manage my IPython configuration & profiles in a Git repo at
> https://github.com/garaud/foggycowinn/tree/master/ipython in order to deploy
> this configuration on any computer (at home, at work, on a VM, etc.).
>
> I know that:
>
>    ipython profile create jazz
>
> creates a few IPython configuration files at ~/.ipython/profile_jazz.
>
> For now, I've three files generated by IPython:
>
> - ipython_config.py
> - ipython_notebook_config.py
> - ipython_qtconsole_config.py
>
> which are the same for my all profiles.
>
>
> Default configuration files are completely commented, the comments are just here
> as information for users.
>
>
> I wonder if there is a way to upgrade a IPython configuration file when there is
> a new IPython version. I slightly modified the default IPy config files and I
> would like to easily merge my future modifications with a new version of these
> files.
>
>
> You can keep only the relevant lines and append them to the new config file,
> this should be enough.
> Somehthing like
>
> cat ~/.ipython/profile_default/ipython_config.py | grep -v -e '^#' | grep -v -e '^$' | grep -v get_config
>
>
> Should give you all the line relevant line of your config.


Thanks for this useful tips ! I think I would use it.

I'm trying to better explain my question. As a Doxygen user, when Doxygen is
upgraded and a option becomes obsolete in my configuration file, the Doxygen
CLI tells me something like "hey, you have some obsolete options in your
config, maybe you should launch 'doxygen -U' to update your file.". Then,
Doxygen modifies my config file, remove old options and can insert new ones
with a default value.

I don't find an easy way to compare the generated config files between two
versions of IPython, even if there are several commented lines. A response as
"keep an eye on the changelog and the release note in order to know the
old/new options" is fine for me. I wondered if there is more automatic/smarter
way to "upgrade" my config files (append new options, in comment, in my
current config for instance).

By the way, reading the IPython config and ProfileDir code (and the different
xxxapp.py modules), I don't find a way to generate the default configuration
content with a few lines of Python (in a string for instance). I don't get the
entry point of profile creation, when the configuration files are added to the
profile directory. I would like to retrieve this content as a str if it's
possible. Do you know how I can do that?

Thanks,
Damien

>
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to upgrade IPython configuration files?

Matthias Bussonnier

> Thanks for this useful tips ! I think I would use it.
>
> I'm trying to better explain my question. As a Doxygen user, when Doxygen is
> upgraded and a option becomes obsolete in my configuration file, the Doxygen
> CLI tells me something like "hey, you have some obsolete options in your
> config, maybe you should launch 'doxygen -U' to update your file.". Then,
> Doxygen modifies my config file, remove old options and can insert new ones
> with a default value.
>
> I don't find an easy way to compare the generated config files between two
> versions of IPython, even if there are several commented lines. A response as
> "keep an eye on the changelog and the release note in order to know the
> old/new options" is fine for me. I wondered if there is more automatic/smarter
> way to "upgrade" my config files (append new options, in comment, in my
> current config for instance).


That would not make sense for IPython, you cannot say that a config option does not exist.
If you create an IPython externsion « Frobulate » that has an option to « rejotrope » which is a set
having
c.Frobulator.rejotrope = {4,8,15,16,23,42}
should not fail or warn as the extension might be loaded later.

IPython configuration file are « just » python script that create a dict-like « c » object.
So updating a config file would be relatively difficult.

Note that since 2.0, you can store your config as <samename>.json  which should work for most
basic config.

We can also add that configuration can be nester, i.e.,

Penantrop.Ferantopior.Frobulator.rejotrope = ‘uuddlrlrba’

will set the option only to Frobulator that are **created** by Ferantopior, themselves children of Penantrop (whatever this is)

Which make guessing configuration updates, pretty tough, except catching some explicitly deprecated
options at runtime.



>
> By the way, reading the IPython config and ProfileDir code (and the different
> xxxapp.py modules), I don't find a way to generate the default configuration
> content with a few lines of Python (in a string for instance).

you can do an `$ ipython profile create` but each configuration file is generated by each of
the sub app  by dynamically looking up all the `Configurable` classes and getting the default values for traitlets.

> I don't get the
> entry point of profile creation, when the configuration files are added to the
> profile directory. I would like to retrieve this content as a str if it's
> possible. Do you know how I can do that?


This is mostly what $ ipython [notebook|qtconsole|console] —help-all does :

import IPython.html.notebookapp
app = IPython.html.notebookapp.NotebookApp()
app.print_help()

The app.generate_config_files() could give you something close to config files, you might nned to ‘\n’/join() it.

IMHO, this part could greatly be improved by having the classes not print directly their help
but returning string that are handled at the top hierarchy.

Also you should think of addressing all question to IPtyhon-dev, as we try to deprecate IPython-user

M
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to upgrade IPython configuration files?

Damien Garaud
2014-08-05 23:43 GMT+02:00 Matthias Bussonnier <[hidden email]>:

>
>> Thanks for this useful tips ! I think I would use it.
>>
>> I'm trying to better explain my question. As a Doxygen user, when Doxygen is
>> upgraded and a option becomes obsolete in my configuration file, the Doxygen
>> CLI tells me something like "hey, you have some obsolete options in your
>> config, maybe you should launch 'doxygen -U' to update your file.". Then,
>> Doxygen modifies my config file, remove old options and can insert new ones
>> with a default value.
>>
>> I don't find an easy way to compare the generated config files between two
>> versions of IPython, even if there are several commented lines. A response as
>> "keep an eye on the changelog and the release note in order to know the
>> old/new options" is fine for me. I wondered if there is more automatic/smarter
>> way to "upgrade" my config files (append new options, in comment, in my
>> current config for instance).
>
>
> That would not make sense for IPython, you cannot say that a config option does not exist.
> If you create an IPython externsion « Frobulate » that has an option to « rejotrope » which is a set
> having
> c.Frobulator.rejotrope = {4,8,15,16,23,42}
> should not fail or warn as the extension might be loaded later.
>
> IPython configuration file are « just » python script that create a dict-like « c » object.
> So updating a config file would be relatively difficult.
>
> Note that since 2.0, you can store your config as <samename>.json  which should work for most
> basic config.
>
> We can also add that configuration can be nester, i.e.,
>
> Penantrop.Ferantopior.Frobulator.rejotrope = ‘uuddlrlrba’
>
> will set the option only to Frobulator that are **created** by Ferantopior, themselves children of Penantrop (whatever this is)
>
> Which make guessing configuration updates, pretty tough, except catching some explicitly deprecated
> options at runtime.

OK. I didn't aware of this. I now better understand.


>> By the way, reading the IPython config and ProfileDir code (and the different
>> xxxapp.py modules), I don't find a way to generate the default configuration
>> content with a few lines of Python (in a string for instance).
>
> you can do an `$ ipython profile create` but each configuration file is generated by each of
> the sub app  by dynamically looking up all the `Configurable` classes and getting the default values for traitlets.
>
>> I don't get the
>> entry point of profile creation, when the configuration files are added to the
>> profile directory. I would like to retrieve this content as a str if it's
>> possible. Do you know how I can do that?
>
>
> This is mostly what $ ipython [notebook|qtconsole|console] —help-all does :
>
> import IPython.html.notebookapp
> app = IPython.html.notebookapp.NotebookApp()
> app.print_help()
>
> The app.generate_config_files() could give you something close to config files, you might nned to ‘\n’/join() it.
>
> IMHO, this part could greatly be improved by having the classes not print directly their help
> but returning string that are handled at the top hierarchy.

I knew that this wasn't difficult and it's quite simple and pretty
clear (my first step in the
IPython code and IPython API. I'm firstly an end-user but I think that
you can improve
your daily work if you understand your tools and can hack it).


> Also you should think of addressing all question to IPtyhon-dev, as we try to deprecate IPython-user
Good to know. I'll do that.

Thanks for your time and your clear explanations !

SeeYa'

Damien
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to upgrade IPython configuration files?

Matthias Bussonnier

>> Which make guessing configuration updates, pretty tough, except catching some explicitly deprecated
>> options at runtime.
>
> OK. I didn't aware of this. I now better understand.


>> IMHO, this part could greatly be improved by having the classes not print directly their help
>> but returning string that are handled at the top hierarchy.
>
> I knew that this wasn't difficult and it's quite simple and pretty
> clear (my first step in the
> IPython code and IPython API. I'm firstly an end-user but I think that
> you can improve
> your daily work if you understand your tools and can hack it).

We try not to make distinction between users and developer.
And seeing how far you have already dived, you can really consider yourself
a dev.

We all started by just trying to understand/ paths IPython at some point in the past.
I've cut my teeth quite a bit on IPython configuration system, and it is far from easy to grasp,
but pretty self-contained.

If you hack on it, feel free to ask question or open Pull-Request.


>> Also you should think of addressing all question to IPtyhon-dev, as we try to deprecate IPython-user
> Good to know. I'll do that.


Se you there then.
>
> Thanks for your time and your clear explanations !

Thanks for your questions.
--
M
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user