Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

set auto_create flag for notebook apps #1253

Merged
merged 1 commit into from

3 participants

@ivanov
Owner

This is one way to fix the recent mailing list report.

$ rm -fr  ~/.ipython/profile_sympy/
$ ipython notebook --profile=sympy
[NotebookApp] Profile u'sympy' not found.

whereas

 $ ipython --profile=sympy

works fine, and ipython notebook --profile=sympy will work thereafter. In this PR, I added set the auto_create flag for notebook apps to True, which makes the top code block work just fine.

An alternative would be to make auto_create = True for the base application. I'm not sure which one should be done, but would be happy to change this pull request to the alternative, which would look like this:

diff --git a/IPython/core/application.py b/IPython/core/application.py
index 4b49a94..cf099bb 100644
--- a/IPython/core/application.py
+++ b/IPython/core/application.py
@@ -124,7 +124,7 @@ class BaseIPythonApplication(Application):

     overwrite = Bool(False, config=True,
         help="""Whether to overwrite existing config files when copying""")
-    auto_create = Bool(False, config=True,
+    auto_create = Bool(True, config=True,
         help="""Whether to create profile dir if it doesn't exist""")
@minrk
Owner

Nice - the reason it's not on by default is that some apps should only load config, so if you specify a profile that doesn't exist it should raise (e.g. ipengine). That said, those that should not create profiles seem to be the minority, so switching the default may make sense. That would mean adding auto_create=Bool(False) override to any apps that do not currently have the auto_create=Bool(True) override now.

@ivanov
Owner

right, in that case, maybe it makes sense to leave the default, for the benefit of other folks that are depending on the current default.

@minrk
Owner

Makes sense. It is also the more conservative value, and the right choice for potential new apps that do less. In that case, setting profile to one of those that is bundled should probably imply auto_create=True.

@ivanov
Owner

sorry if I'm confused - but I was talking about leaving the default for BaseIPythonApplication, and changing it for NotebookApp, as per this PR. I realized as I reread your comment that mine could have been read as "leaving the default for the NotebookApp as auto_create=False" - but that's not what I meant.

@takluyver
Owner

I would side with making the BaseIPythonApplication default True, because if people build other frontends using that class, they'll expect them to behave in the same way as regular IPython applications.

@minrk
Owner

@ivanov - I understood what you meant, but even so, I don't think the profile doesn't exist error shouldn't raise if you request a bundled profile for the first time, even for an app where auto_create=False. But auto_create should certainly be True in the NotebookApp as you have done. This need not be addressed in this PR, as I suppose it's a separate issue.

@takluyver - That would also be addressed by making ShellApp set auto_create=True, and the NotebookApp should be a subclass of ShellApp, just like everything else that starts IPython shells, and this is what third-party apps should inherit from anyway. It was a mistake to write it as we did, by copying/pasting a bunch of code, which has allowed it to fall out of sync as the original code was updated an improved.

The case for leaving the default as False is that apps for which False is the right default are ones that do less.

Some background:

Originally, profiles had to be created with ipython profile create, but we realized that when you start an IPython shell, you should be able to simply ask for a profile, and it will be created without staging any config files (or only those that are bundled). This is not the case in general, and in particular is not the case for things that must load some config (ipengine, iplogger, ipcluster subcommands other than start), where no pre-existing config does mean there's definitely an error. Since it has turned out that these are a minority of entry points, it may make sense to switch the default to True, which would require adding overrides to all apps that currently inherit the default, just as shell-starting apps and ipcontroller have overrides in the opposite direction now.

@minrk
Owner

Since this code actually fixes an important bug and is perfectly consistent with the rest of the existing logic, I'm going to merge it, and we can decide what to do about rearranging the default auto_create in another Issue.

@minrk minrk merged commit 9bb4034 into ipython:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 11, 2012
  1. @ivanov
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  IPython/frontend/html/notebook/notebookapp.py
View
3  IPython/frontend/html/notebook/notebookapp.py
@@ -215,6 +215,9 @@ class NotebookApp(BaseIPythonApplication):
config=True,
help="Set the log level by value or name.")
+ # create requested profiles by default, if they don't exist:
+ auto_create = Bool(True)
+
# Network related information.
ip = Unicode(LOCALHOST, config=True,
Something went wrong with that request. Please try again.