From 4512e66dcefb79e33ab8a5b911894f7cc1efe569 2011-06-20 23:40:21 From: MinRK Date: 2011-06-20 23:40:21 Subject: [PATCH] move ipcluster create|list to `ipython profile create|list` * give ProfileDir its own file (core.profiledir) * add core.profileapp for new subcommand parallel docs updated to match --- diff --git a/IPython/core/application.py b/IPython/core/application.py index 84cbb69..21f9aba 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -14,12 +14,10 @@ Authors: * Fernando Perez * Min RK -Notes ------ """ #----------------------------------------------------------------------------- -# Copyright (C) 2008-2009 The IPython Development Team +# Copyright (C) 2008-2011 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. @@ -38,7 +36,8 @@ from IPython.config.application import Application from IPython.config.configurable import Configurable from IPython.config.loader import Config from IPython.core import release, crashhandler -from IPython.utils.path import get_ipython_dir, get_ipython_package_dir, expand_path +from IPython.core.profiledir import ProfileDir, ProfileDirError +from IPython.utils.path import get_ipython_dir, get_ipython_package_dir from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict #----------------------------------------------------------------------------- @@ -47,175 +46,6 @@ from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict #----------------------------------------------------------------------------- -# Module errors -#----------------------------------------------------------------------------- - -class ProfileDirError(Exception): - pass - - -#----------------------------------------------------------------------------- -# Class for managing profile directories -#----------------------------------------------------------------------------- - -class ProfileDir(Configurable): - """An object to manage the profile directory and its resources. - - The profile directory is used by all IPython applications, to manage - configuration, logging and security. - - This object knows how to find, create and manage these directories. This - should be used by any code that wants to handle profiles. - """ - - security_dir_name = Unicode('security') - log_dir_name = Unicode('log') - pid_dir_name = Unicode('pid') - security_dir = Unicode(u'') - log_dir = Unicode(u'') - pid_dir = Unicode(u'') - - location = Unicode(u'', config=True, - help="""Set the profile location directly. This overrides the logic used by the - `profile` option.""", - ) - - _location_isset = Bool(False) # flag for detecting multiply set location - - def _location_changed(self, name, old, new): - if self._location_isset: - raise RuntimeError("Cannot set profile location more than once.") - self._location_isset = True - if not os.path.isdir(new): - os.makedirs(new) - - # ensure config files exist: - self.security_dir = os.path.join(new, self.security_dir_name) - self.log_dir = os.path.join(new, self.log_dir_name) - self.pid_dir = os.path.join(new, self.pid_dir_name) - self.check_dirs() - - def _log_dir_changed(self, name, old, new): - self.check_log_dir() - - def check_log_dir(self): - if not os.path.isdir(self.log_dir): - os.mkdir(self.log_dir) - - def _security_dir_changed(self, name, old, new): - self.check_security_dir() - - def check_security_dir(self): - if not os.path.isdir(self.security_dir): - os.mkdir(self.security_dir, 0700) - else: - os.chmod(self.security_dir, 0700) - - def _pid_dir_changed(self, name, old, new): - self.check_pid_dir() - - def check_pid_dir(self): - if not os.path.isdir(self.pid_dir): - os.mkdir(self.pid_dir, 0700) - else: - os.chmod(self.pid_dir, 0700) - - def check_dirs(self): - self.check_security_dir() - self.check_log_dir() - self.check_pid_dir() - - def copy_config_file(self, config_file, path=None, overwrite=False): - """Copy a default config file into the active profile directory. - - Default configuration files are kept in :mod:`IPython.config.default`. - This function moves these from that location to the working profile - directory. - """ - dst = os.path.join(self.location, config_file) - if os.path.isfile(dst) and not overwrite: - return - if path is None: - path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default') - src = os.path.join(path, config_file) - shutil.copy(src, dst) - - @classmethod - def create_profile_dir(cls, profile_dir, config=None): - """Create a new profile directory given a full path. - - Parameters - ---------- - profile_dir : str - The full path to the profile directory. If it does exist, it will - be used. If not, it will be created. - """ - return cls(location=profile_dir, config=config) - - @classmethod - def create_profile_dir_by_name(cls, path, name=u'default', config=None): - """Create a profile dir by profile name and path. - - Parameters - ---------- - path : unicode - The path (directory) to put the profile directory in. - name : unicode - The name of the profile. The name of the profile directory will - be "profile_". - """ - if not os.path.isdir(path): - raise ProfileDirError('Directory not found: %s' % path) - profile_dir = os.path.join(path, u'profile_' + name) - return cls(location=profile_dir, config=config) - - @classmethod - def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None): - """Find an existing profile dir by profile name, return its ProfileDir. - - This searches through a sequence of paths for a profile dir. If it - is not found, a :class:`ProfileDirError` exception will be raised. - - The search path algorithm is: - 1. ``os.getcwd()`` - 2. ``ipython_dir`` - - Parameters - ---------- - ipython_dir : unicode or str - The IPython directory to use. - name : unicode or str - The name of the profile. The name of the profile directory - will be "profile_". - """ - dirname = u'profile_' + name - paths = [os.getcwdu(), ipython_dir] - for p in paths: - profile_dir = os.path.join(p, dirname) - if os.path.isdir(profile_dir): - return cls(location=profile_dir, config=config) - else: - raise ProfileDirError('Profile directory not found in paths: %s' % dirname) - - @classmethod - def find_profile_dir(cls, profile_dir, config=None): - """Find/create a profile dir and return its ProfileDir. - - This will create the profile directory if it doesn't exist. - - Parameters - ---------- - profile_dir : unicode or str - The path of the profile directory. This is expanded using - :func:`IPython.utils.genutils.expand_path`. - """ - profile_dir = expand_path(profile_dir) - if not os.path.isdir(profile_dir): - raise ProfileDirError('Profile directory not found: %s' % profile_dir) - return cls(location=profile_dir, config=config) - - -#----------------------------------------------------------------------------- # Base Application Class #----------------------------------------------------------------------------- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index fc3ae68..bf0856b 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -54,10 +54,10 @@ from IPython.core.inputsplitter import IPythonInputSplitter from IPython.core.logger import Logger from IPython.core.macro import Macro from IPython.core.magic import Magic -from IPython.core.application import ProfileDir from IPython.core.payload import PayloadManager from IPython.core.plugin import PluginManager from IPython.core.prefilter import PrefilterManager, ESC_MAGIC +from IPython.core.profiledir import ProfileDir from IPython.external.Itpl import ItplNS from IPython.utils import PyColorize from IPython.utils import io diff --git a/IPython/core/magic.py b/IPython/core/magic.py index a1292a7..368b72d 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -46,7 +46,7 @@ from IPython.core import debugger, oinspect from IPython.core.error import TryNext from IPython.core.error import UsageError from IPython.core.fakemodule import FakeModule -from IPython.core.application import ProfileDir +from IPython.core.profiledir import ProfileDir from IPython.core.macro import Macro from IPython.core import page from IPython.core.prefilter import ESC_MAGIC diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py new file mode 100644 index 0000000..9155025 --- /dev/null +++ b/IPython/core/profileapp.py @@ -0,0 +1,174 @@ +# encoding: utf-8 +""" +An application for managing IPython profiles. + +To be invoked as the `ipython profile` subcommand. + +Authors: + +* Min RK + +""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2008-2011 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +import logging +import os + +from IPython.config.application import Application, boolean_flag +from IPython.core.application import ( + BaseIPythonApplication, base_flags, base_aliases +) +from IPython.core.profiledir import ProfileDir +from IPython.utils.path import get_ipython_dir +from IPython.utils.traitlets import Unicode, Bool, Dict + +#----------------------------------------------------------------------------- +# Constants +#----------------------------------------------------------------------------- + +create_help = """Create an ipcluster profile by name + +Create an ipython profile directory by its name or +profile directory path. Profile directories contain +configuration, log and security related files and are named +using the convention 'profile_'. By default they are +located in your ipython directory. Once created, you will +can edit the configuration files in the profile +directory to configure IPython. Most users will create a +cluster directory by profile name, +`ipython profile create myprofile`, which will put the directory +in `/profile_myprofile`. +""" +list_help = """List available IPython profiles + +List all available profiles, by profile location, that can +be found in the current working directly or in the ipython +directory. Profile directories are named using the convention +'profile_'. +""" +profile_help = """Manage IPython profiles + +Profile directories contain +configuration, log and security related files and are named +using the convention 'profile_'. By default they are +located in your ipython directory. You can create profiles +with `ipython profile create `, or see the profiles you +already have with `ipython profile list` + +To get started configuring IPython, simply do: + +$> ipython profile create + +and IPython will create the default profile in /profile_default, +where you can edit ipython_config.py to start configuring IPython. + +""" + +#----------------------------------------------------------------------------- +# Profile Application Class (for `ipython profile` subcommand) +#----------------------------------------------------------------------------- + + + +class ProfileList(Application): + name = u'ipython-profile' + description = list_help + + aliases = Dict(dict( + ipython_dir = 'ProfileList.ipython_dir', + log_level = 'Application.log_level', + )) + flags = Dict(dict( + debug = ({'Application' : {'log_level' : 0}}, + "Set log_level to 0, maximizing log output." + ) + )) + ipython_dir = Unicode(get_ipython_dir(), config=True, + help=""" + The name of the IPython directory. This directory is used for logging + configuration (through profiles), history storage, etc. The default + is usually $HOME/.ipython. This options can also be specified through + the environment variable IPYTHON_DIR. + """ + ) + + def list_profile_dirs(self): + # Find the search paths + paths = [os.getcwdu(), self.ipython_dir] + + self.log.warn('Searching for IPython profiles in paths: %r' % paths) + for path in paths: + files = os.listdir(path) + for f in files: + full_path = os.path.join(path, f) + if os.path.isdir(full_path) and f.startswith('profile_'): + profile = f.split('_',1)[-1] + start_cmd = 'ipython profile=%s' % profile + print start_cmd + " ==> " + full_path + + def start(self): + self.list_profile_dirs() + + +create_flags = {} +create_flags.update(base_flags) +create_flags.update(boolean_flag('reset', 'ProfileCreate.overwrite', + "reset config files to defaults", "leave existing config files")) +create_flags.update(boolean_flag('cluster', 'ProfileCreate.cluster', + "Include parallel computing config files", + "Don't include parallel computing config files")) + +class ProfileCreate(BaseIPythonApplication): + name = u'ipython-profile' + description = create_help + auto_create = Bool(True, config=False) + + def _copy_config_files_default(self): + return True + + cluster = Bool(False, config=True, + help="whether to include parallel computing config files") + def _cluster_changed(self, name, old, new): + cluster_files = [ 'ipcontroller_config.py', + 'ipengine_config.py', + 'ipcluster_config.py' + ] + if new: + for cf in cluster_files: + self.config_files.append(cf) + else: + for cf in cluster_files: + if cf in self.config_files: + self.config_files.remove(cf) + + def parse_command_line(self, argv): + super(ProfileCreate, self).parse_command_line(argv) + # accept positional arg as profile name + if self.extra_args: + self.profile = self.extra_args[0] + + flags = Dict(create_flags) + + aliases = Dict(dict(profile='BaseIPythonApplication.profile')) + + classes = [ProfileDir] + +class ProfileApp(Application): + name = u'ipython-profile' + description = profile_help + + subcommands = Dict(dict( + create = (ProfileCreate, "Create a new profile dir with default config files"), + list = (ProfileList, "List existing profiles") + )) + diff --git a/IPython/core/profiledir.py b/IPython/core/profiledir.py new file mode 100644 index 0000000..2668325 --- /dev/null +++ b/IPython/core/profiledir.py @@ -0,0 +1,206 @@ +# encoding: utf-8 +""" +An object for managing IPython profile directories. + +Authors: + +* Brian Granger +* Fernando Perez +* Min RK + +""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2008-2011 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +import os +import shutil +import sys + +from IPython.config.configurable import Configurable +from IPython.config.loader import Config +from IPython.utils.path import get_ipython_package_dir, expand_path +from IPython.utils.traitlets import List, Unicode, Bool + +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------- +# Module errors +#----------------------------------------------------------------------------- + +class ProfileDirError(Exception): + pass + + +#----------------------------------------------------------------------------- +# Class for managing profile directories +#----------------------------------------------------------------------------- + +class ProfileDir(Configurable): + """An object to manage the profile directory and its resources. + + The profile directory is used by all IPython applications, to manage + configuration, logging and security. + + This object knows how to find, create and manage these directories. This + should be used by any code that wants to handle profiles. + """ + + security_dir_name = Unicode('security') + log_dir_name = Unicode('log') + pid_dir_name = Unicode('pid') + security_dir = Unicode(u'') + log_dir = Unicode(u'') + pid_dir = Unicode(u'') + + location = Unicode(u'', config=True, + help="""Set the profile location directly. This overrides the logic used by the + `profile` option.""", + ) + + _location_isset = Bool(False) # flag for detecting multiply set location + + def _location_changed(self, name, old, new): + if self._location_isset: + raise RuntimeError("Cannot set profile location more than once.") + self._location_isset = True + if not os.path.isdir(new): + os.makedirs(new) + + # ensure config files exist: + self.security_dir = os.path.join(new, self.security_dir_name) + self.log_dir = os.path.join(new, self.log_dir_name) + self.pid_dir = os.path.join(new, self.pid_dir_name) + self.check_dirs() + + def _log_dir_changed(self, name, old, new): + self.check_log_dir() + + def check_log_dir(self): + if not os.path.isdir(self.log_dir): + os.mkdir(self.log_dir) + + def _security_dir_changed(self, name, old, new): + self.check_security_dir() + + def check_security_dir(self): + if not os.path.isdir(self.security_dir): + os.mkdir(self.security_dir, 0700) + else: + os.chmod(self.security_dir, 0700) + + def _pid_dir_changed(self, name, old, new): + self.check_pid_dir() + + def check_pid_dir(self): + if not os.path.isdir(self.pid_dir): + os.mkdir(self.pid_dir, 0700) + else: + os.chmod(self.pid_dir, 0700) + + def check_dirs(self): + self.check_security_dir() + self.check_log_dir() + self.check_pid_dir() + + def copy_config_file(self, config_file, path=None, overwrite=False): + """Copy a default config file into the active profile directory. + + Default configuration files are kept in :mod:`IPython.config.default`. + This function moves these from that location to the working profile + directory. + """ + dst = os.path.join(self.location, config_file) + if os.path.isfile(dst) and not overwrite: + return + if path is None: + path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default') + src = os.path.join(path, config_file) + shutil.copy(src, dst) + + @classmethod + def create_profile_dir(cls, profile_dir, config=None): + """Create a new profile directory given a full path. + + Parameters + ---------- + profile_dir : str + The full path to the profile directory. If it does exist, it will + be used. If not, it will be created. + """ + return cls(location=profile_dir, config=config) + + @classmethod + def create_profile_dir_by_name(cls, path, name=u'default', config=None): + """Create a profile dir by profile name and path. + + Parameters + ---------- + path : unicode + The path (directory) to put the profile directory in. + name : unicode + The name of the profile. The name of the profile directory will + be "profile_". + """ + if not os.path.isdir(path): + raise ProfileDirError('Directory not found: %s' % path) + profile_dir = os.path.join(path, u'profile_' + name) + return cls(location=profile_dir, config=config) + + @classmethod + def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None): + """Find an existing profile dir by profile name, return its ProfileDir. + + This searches through a sequence of paths for a profile dir. If it + is not found, a :class:`ProfileDirError` exception will be raised. + + The search path algorithm is: + 1. ``os.getcwd()`` + 2. ``ipython_dir`` + + Parameters + ---------- + ipython_dir : unicode or str + The IPython directory to use. + name : unicode or str + The name of the profile. The name of the profile directory + will be "profile_". + """ + dirname = u'profile_' + name + paths = [os.getcwdu(), ipython_dir] + for p in paths: + profile_dir = os.path.join(p, dirname) + if os.path.isdir(profile_dir): + return cls(location=profile_dir, config=config) + else: + raise ProfileDirError('Profile directory not found in paths: %s' % dirname) + + @classmethod + def find_profile_dir(cls, profile_dir, config=None): + """Find/create a profile dir and return its ProfileDir. + + This will create the profile directory if it doesn't exist. + + Parameters + ---------- + profile_dir : unicode or str + The path of the profile directory. This is expanded using + :func:`IPython.utils.genutils.expand_path`. + """ + profile_dir = expand_path(profile_dir) + if not os.path.isdir(profile_dir): + raise ProfileDirError('Profile directory not found: %s' % profile_dir) + return cls(location=profile_dir, config=config) + + diff --git a/IPython/frontend/qt/console/qtconsoleapp.py b/IPython/frontend/qt/console/qtconsoleapp.py index 3ca0850..126bd78 100644 --- a/IPython/frontend/qt/console/qtconsoleapp.py +++ b/IPython/frontend/qt/console/qtconsoleapp.py @@ -27,7 +27,8 @@ from pygments.styles import get_all_styles # Local imports from IPython.config.application import boolean_flag -from IPython.core.application import ProfileDir, BaseIPythonApplication +from IPython.core.application import BaseIPythonApplication +from IPython.core.profiledir import ProfileDir from IPython.frontend.qt.console.frontend_widget import FrontendWidget from IPython.frontend.qt.console.ipython_widget import IPythonWidget from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget diff --git a/IPython/frontend/terminal/ipapp.py b/IPython/frontend/terminal/ipapp.py index 45099aa..8d68708 100755 --- a/IPython/frontend/terminal/ipapp.py +++ b/IPython/frontend/terminal/ipapp.py @@ -203,7 +203,9 @@ class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp): subcommands = Dict(dict( qtconsole=('IPython.frontend.qt.console.qtconsoleapp.IPythonQtConsoleApp', """Launch the IPython Qt Console.""" - ) + ), + profile = ("IPython.core.profileapp.ProfileApp", + "Create and manage IPython profiles.") )) # *do* autocreate requested profile diff --git a/IPython/parallel/apps/ipclusterapp.py b/IPython/parallel/apps/ipclusterapp.py index 26b1606..93c081c 100755 --- a/IPython/parallel/apps/ipclusterapp.py +++ b/IPython/parallel/apps/ipclusterapp.py @@ -33,7 +33,8 @@ from zmq.eventloop import ioloop from IPython.config.application import Application, boolean_flag from IPython.config.loader import Config -from IPython.core.application import BaseIPythonApplication, ProfileDir +from IPython.core.application import BaseIPythonApplication +from IPython.core.profiledir import ProfileDir from IPython.utils.daemonize import daemonize from IPython.utils.importstring import import_item from IPython.utils.traitlets import Int, Unicode, Bool, CFloat, Dict, List @@ -89,7 +90,7 @@ start_help = """Start an IPython cluster for parallel computing Start an ipython cluster by its profile name or cluster directory. Cluster directories contain configuration, log and security related files and are named using the convention -'cluster_' and should be creating using the 'start' +'profile_' and should be creating using the 'start' subcommand of 'ipcluster'. If your cluster directory is in the cwd or the ipython directory, you can simply refer to it using its profile name, 'ipcluster start n=4 profile=`, @@ -99,7 +100,7 @@ stop_help = """Stop a running IPython cluster Stop a running ipython cluster by its profile name or cluster directory. Cluster directories are named using the convention -'cluster_'. If your cluster directory is in +'profile_'. If your cluster directory is in the cwd or the ipython directory, you can simply refer to it using its profile name, 'ipcluster stop profile=`, otherwise use the 'profile_dir' option. @@ -110,93 +111,12 @@ Start one or more engines to connect to an existing Cluster by profile name or cluster directory. Cluster directories contain configuration, log and security related files and are named using the convention -'cluster_' and should be creating using the 'start' +'profile_' and should be creating using the 'start' subcommand of 'ipcluster'. If your cluster directory is in the cwd or the ipython directory, you can simply refer to it using its profile name, 'ipcluster engines n=4 profile=`, otherwise use the 'profile_dir' option. """ -create_help = """Create an ipcluster profile by name - -Create an ipython cluster directory by its profile name or -cluster directory path. Cluster directories contain -configuration, log and security related files and are named -using the convention 'cluster_'. By default they are -located in your ipython directory. Once created, you will -probably need to edit the configuration files in the cluster -directory to configure your cluster. Most users will create a -cluster directory by profile name, -`ipcluster create profile=mycluster`, which will put the directory -in `/cluster_mycluster`. -""" -list_help = """List available cluster profiles - -List all available clusters, by cluster directory, that can -be found in the current working directly or in the ipython -directory. Cluster directories are named using the convention -'cluster_'. -""" - - -class IPClusterList(BaseIPythonApplication): - name = u'ipcluster-list' - description = list_help - - # empty aliases - aliases=Dict() - flags = Dict(base_flags) - - def _log_level_default(self): - return 20 - - def list_profile_dirs(self): - # Find the search paths - profile_dir_paths = os.environ.get('IPYTHON_PROFILE_PATH','') - if profile_dir_paths: - profile_dir_paths = profile_dir_paths.split(':') - else: - profile_dir_paths = [] - - ipython_dir = self.ipython_dir - - paths = [os.getcwd(), ipython_dir] + profile_dir_paths - paths = list(set(paths)) - - self.log.info('Searching for cluster profiles in paths: %r' % paths) - for path in paths: - files = os.listdir(path) - for f in files: - full_path = os.path.join(path, f) - if os.path.isdir(full_path) and f.startswith('profile_') and \ - os.path.isfile(os.path.join(full_path, 'ipcontroller_config.py')): - profile = f.split('_')[-1] - start_cmd = 'ipcluster start profile=%s n=4' % profile - print start_cmd + " ==> " + full_path - - def start(self): - self.list_profile_dirs() - - -# `ipcluster create` will be deprecated when `ipython profile create` or equivalent exists - -create_flags = {} -create_flags.update(base_flags) -create_flags.update(boolean_flag('reset', 'IPClusterCreate.overwrite', - "reset config files to defaults", "leave existing config files")) - -class IPClusterCreate(BaseParallelApplication): - name = u'ipcluster-create' - description = create_help - auto_create = Bool(True) - config_file_name = Unicode(default_config_file_name) - - flags = Dict(create_flags) - - aliases = Dict(dict(profile='BaseIPythonApplication.profile')) - - classes = [ProfileDir] - - stop_aliases = dict( signal='IPClusterStop.signal', profile='BaseIPythonApplication.profile', diff --git a/IPython/parallel/apps/ipcontrollerapp.py b/IPython/parallel/apps/ipcontrollerapp.py index b386560..ae64327 100755 --- a/IPython/parallel/apps/ipcontrollerapp.py +++ b/IPython/parallel/apps/ipcontrollerapp.py @@ -37,7 +37,7 @@ from zmq.log.handlers import PUBHandler from zmq.utils import jsonapi as json from IPython.config.application import boolean_flag -from IPython.core.application import ProfileDir +from IPython.core.profiledir import ProfileDir from IPython.parallel.apps.baseapp import ( BaseParallelApplication, @@ -80,7 +80,7 @@ The IPython controller provides a gateway between the IPython engines and clients. The controller needs to be started before the engines and can be configured using command line options or using a cluster directory. Cluster directories contain config, log and security files and are usually located in -your ipython directory and named as "cluster_". See the `profile` +your ipython directory and named as "profile_name". See the `profile` and `profile_dir` options for details. """ diff --git a/IPython/parallel/apps/ipengineapp.py b/IPython/parallel/apps/ipengineapp.py index 9e02093..baf4507 100755 --- a/IPython/parallel/apps/ipengineapp.py +++ b/IPython/parallel/apps/ipengineapp.py @@ -28,7 +28,7 @@ import sys import zmq from zmq.eventloop import ioloop -from IPython.core.application import ProfileDir +from IPython.core.profiledir import ProfileDir from IPython.parallel.apps.baseapp import BaseParallelApplication from IPython.zmq.log import EnginePUBHandler @@ -55,7 +55,7 @@ IPython engines run in parallel and perform computations on behalf of a client and controller. A controller needs to be started before the engines. The engine can be configured using command line options or using a cluster directory. Cluster directories contain config, log and security files and are -usually located in your ipython directory and named as "cluster_". +usually located in your ipython directory and named as "profile_name". See the `profile` and `profile_dir` options for details. """ diff --git a/IPython/parallel/apps/iploggerapp.py b/IPython/parallel/apps/iploggerapp.py index 99f7ac0..8fbb8f5 100755 --- a/IPython/parallel/apps/iploggerapp.py +++ b/IPython/parallel/apps/iploggerapp.py @@ -25,7 +25,7 @@ import sys import zmq -from IPython.core.application import ProfileDir +from IPython.core.profiledir import ProfileDir from IPython.utils.traitlets import Bool, Dict, Unicode from IPython.parallel.apps.baseapp import ( @@ -47,7 +47,7 @@ IPython controllers and engines (and your own processes) can broadcast log messa by registering a `zmq.log.handlers.PUBHandler` with the `logging` module. The logger can be configured using command line options or using a cluster directory. Cluster directories contain config, log and security files and are -usually located in your ipython directory and named as "cluster_". +usually located in your ipython directory and named as "profile_name". See the `profile` and `profile_dir` options for details. """ diff --git a/IPython/parallel/client/client.py b/IPython/parallel/client/client.py index 1c58008..197036c 100644 --- a/IPython/parallel/client/client.py +++ b/IPython/parallel/client/client.py @@ -40,7 +40,7 @@ from IPython.parallel import util from IPython.zmq.session import Session, Message from .asyncresult import AsyncResult, AsyncHubResult -from IPython.core.application import ProfileDir, ProfileDirError +from IPython.core.profiledir import ProfileDir, ProfileDirError from .view import DirectView, LoadBalancedView #-------------------------------------------------------------------------- diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 5972503..4d8bae3 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -413,13 +413,13 @@ def check_for_old_config(ipython_dir=None): if ipython_dir is None: ipython_dir = get_ipython_dir() - old_configs = ['ipy_user_conf.py', 'ipythonrc'] + old_configs = ['ipy_user_conf.py', 'ipythonrc', 'ipython_config.py'] for cfg in old_configs: f = os.path.join(ipython_dir, cfg) if os.path.exists(f): warn.warn("""Found old IPython config file %r. The IPython configuration system has changed as of 0.11, and this file will be ignored. See http://ipython.github.com/ipython-doc/dev/config for details on the new config system. - The current default config file is 'ipython_config.py', where you can suppress these - warnings with `Global.ignore_old_config = True`."""%f) + To start configuring IPython, do `ipython profile create`, and edit `ipython_config.py` in + /profile_default."""%f) diff --git a/docs/source/parallel/parallel_process.txt b/docs/source/parallel/parallel_process.txt index 382102a..de6a72f 100644 --- a/docs/source/parallel/parallel_process.txt +++ b/docs/source/parallel/parallel_process.txt @@ -68,7 +68,7 @@ controller and engines in the following situations: .. note:: Currently :command:`ipcluster` requires that the - :file:`~/.ipython/cluster_/security` directory live on a shared filesystem that is + :file:`~/.ipython/profile_/security` directory live on a shared filesystem that is seen by both the controller and engines. If you don't have a shared file system you will need to use :command:`ipcontroller` and :command:`ipengine` directly. @@ -92,7 +92,7 @@ Configuring an IPython cluster Cluster configurations are stored as `profiles`. You can create a new profile with:: - $ ipcluster create profile=myprofile + $ ipython profile create --cluster profile=myprofile This will create the directory :file:`IPYTHONDIR/cluster_myprofile`, and populate it with the default configuration files for the three IPython cluster commands. Once @@ -133,7 +133,7 @@ The mpiexec/mpirun mode is useful if you: If these are satisfied, you can create a new profile:: - $ ipcluster create profile=mpi + $ ipython profile create --cluster profile=mpi and edit the file :file:`IPYTHONDIR/cluster_mpi/ipcluster_config.py`. @@ -190,7 +190,7 @@ The PBS mode uses the Portable Batch System [PBS]_ to start the engines. As usual, we will start by creating a fresh profile:: - $ ipcluster create profile=pbs + $ ipython profile create --cluster profile=pbs And in :file:`ipcluster_config.py`, we will select the PBS launchers for the controller and engines: @@ -310,7 +310,7 @@ nodes and :command:`ipcontroller` can be run remotely as well, or on localhost. As usual, we start by creating a clean profile:: - $ ipcluster create profile=ssh + $ ipython profile create --cluster profile=ssh To use this mode, select the SSH launchers in :file:`ipcluster_config.py`: @@ -417,7 +417,7 @@ When the controller and engines are running on different hosts, things are slightly more complicated, but the underlying ideas are the same: 1. Start the controller on a host using :command:`ipcontroller`. -2. Copy :file:`ipcontroller-engine.json` from :file:`~/.ipython/cluster_/security` on +2. Copy :file:`ipcontroller-engine.json` from :file:`~/.ipython/profile_/security` on the controller's host to the host where the engines will run. 3. Use :command:`ipengine` on the engine's hosts to start the engines. @@ -425,7 +425,7 @@ The only thing you have to be careful of is to tell :command:`ipengine` where the :file:`ipcontroller-engine.json` file is located. There are two ways you can do this: -* Put :file:`ipcontroller-engine.json` in the :file:`~/.ipython/cluster_/security` +* Put :file:`ipcontroller-engine.json` in the :file:`~/.ipython/profile_/security` directory on the engine's host, where it will be found automatically. * Call :command:`ipengine` with the ``--file=full_path_to_the_file`` flag. @@ -437,7 +437,7 @@ The ``--file`` flag works like this:: .. note:: If the controller's and engine's hosts all have a shared file system - (:file:`~/.ipython/cluster_/security` is the same on all of them), then things + (:file:`~/.ipython/profile_/security` is the same on all of them), then things will just work! Make JSON files persistent @@ -472,7 +472,7 @@ Log files All of the components of IPython have log files associated with them. These log files can be extremely useful in debugging problems with -IPython and can be found in the directory :file:`~/.ipython/cluster_/log`. +IPython and can be found in the directory :file:`~/.ipython/profile_/log`. Sending the log files to us will often help us to debug any problems. diff --git a/docs/source/parallel/parallel_winhpc.txt b/docs/source/parallel/parallel_winhpc.txt index 2b0238d..1eccff0 100644 --- a/docs/source/parallel/parallel_winhpc.txt +++ b/docs/source/parallel/parallel_winhpc.txt @@ -179,7 +179,7 @@ describe how to configure and run an IPython cluster on an actual compute cluster running Windows HPC Server 2008. Here is an outline of the needed steps: -1. Create a cluster profile using: ``ipcluster create profile=mycluster`` +1. Create a cluster profile using: ``ipython profile create --cluster profile=mycluster`` 2. Edit configuration files in the directory :file:`.ipython\\cluster_mycluster` @@ -198,13 +198,13 @@ directory is a specially named directory (typically located in the :file:`.ipython` subdirectory of your home directory) that contains the configuration files for a particular cluster profile, as well as log files and security keys. The naming convention for cluster directories is: -:file:`cluster_`. Thus, the cluster directory for a profile named +:file:`profile_`. Thus, the cluster directory for a profile named "foo" would be :file:`.ipython\\cluster_foo`. To create a new cluster profile (named "mycluster") and the associated cluster directory, type the following command at the Windows Command Prompt:: - ipcluster create profile=mycluster + ipython profile create --cluster profile=mycluster The output of this command is shown in the screenshot below. Notice how :command:`ipcluster` prints out the location of the newly created cluster