Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use newapp in parallel code #486

Closed
wants to merge 41 commits into from

2 participants

@minrk
Owner

parallel scripts have been rewritten with newapp.

Docs have been updated accordingly.

minrk and others added some commits
@minrk minrk Terminal IPython working with newapp b1f3e46
@minrk minrk update config files to match new namespace. 3f13a3c
@minrk minrk remove old default config files 57b7e0b
@minrk minrk update docs with new cl-arguments f6a7377
@minrk minrk minor helpstring cleanup per review. 11d91eb
@minrk minrk Split generic part of terminal frontend/terminal/ipapp into core/shel…
…lapp

Now there's a class for IPKernel to inherit from in the qt code
bba8a52
@minrk minrk use App.instance() in launch_new_instance
This way later calls to App.instance() will return the running
application, whereas calling App() would create an isolated
Application object.
abf93be
@minrk minrk zmq kernels now started via newapp 0fda148
@minrk minrk QtConsole now uses newapp 6011408
@minrk minrk qt font family/size configurable 2a72ea4
@minrk minrk add InlineBackendConfig
The inline backend now has preliminary config support for rc and figure format.
a3fc5dc
@minrk minrk cleanup channel names to match function not socket
closes gh-178
7940e2f
@minrk minrk use Monospace as default font on Linux c932bca
@minrk minrk update docs/default config for qtconsole 424da74
@minrk minrk expand default_editor message to include configurable
Also set the default editor to notepad on Windows.
0efe944
@minrk minrk update QtConfig section of ipython_config to match actual defaults d10edbe
@minrk minrk IPKernelApp now based on InteractiveShellApp 2eb73ea
@minrk minrk use App.instance() in kernel launchers
This way later calls to App.instance() will return the running
application, whereas calling App() would create an isolated
Application object.
14a4f02
@minrk minrk use logging instead of `print >>` in pykernel 9c14773
@minrk minrk add qtconsole as subapp of terminal ipapp
Now 'ipython qtconsole' will behave the same as 'ipython-qtconsole'
f744a3c
@minrk minrk add confirm_exit option to qtconsole to suppress exit dialog fffc83f
@minrk minrk merge #492 newapp-qt f6b7029
@minrk minrk all ipcluster scripts in some degree of working order with new config 1940df6
@minrk minrk ipcluster implemented with new subcommands ad7f39d
@minrk minrk restore auto_create behavior a618140
@minrk minrk cleanup parallel traits
* eliminate use of CUnicode
* eliminate use of Str
* all remaining CStr will become CBytes
c29759d
@minrk minrk re-enable log forwarding and iplogger 4b57636
@minrk minrk parallel docs, tests, default config updated to newconfig 3776732
@minrk minrk use BaseIPythonApp.load_config, not Application.load_config 6fa4c3f
@minrk minrk update parallel apps to use ProfileDir 5f11451
@minrk minrk rename clusterdir to more descriptive baseapp
since the 'clusterdir' part is now in the base newapplication, and not cluster-specific.
b11fa90
@minrk minrk remove uneccesary Config objects from flags. 00e2265
@minrk minrk update default config files with new app namespace ffe0399
@minrk minrk cleanup Hub/Scheduler to prevent '%s'%<nonascii> errors 2676dc3
@minrk minrk fix %px magic output for single target
parallelmagic._maybe_display expects result.stdout to be a list,
but did not handle the single-result case where it is the stdout string
itself, thus printing the first character rather than the whole string.

test included
ee1d9ce
@minrk minrk use HMAC digest to sign messages instead of cleartext key
also some cleanup of Session code

security doc updated as well.

Buffers do not get digested, so large (non-copying) messages should not
cause performance to suffer too greatly.
ca299a7
@minrk minrk use Context.instance() for default in SessionFactory a6c14a6
@minrk minrk use App.instance() in launch_new_instance (parallel apps)
This way later calls to App.instance() will return the running
application, whereas calling App() would create an isolated
Application object.
fbeaaef
@minrk minrk don't pass profile_dir as kwarg in ipclusterapp
also fix PBS->SGE typo from copy/paste
739a5cd
@minrk minrk fix SGE jobarray regex 7521650
@takluyver takluyver Replace Itpl with str.format in parallel launcher.
Signed-off-by: MinRK <benjaminrk@gmail.com>
e08aa54
@minrk minrk closed this in c5d26d9
@damianavila damianavila referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 10, 2011
  1. @minrk
  2. @minrk
  3. @minrk

    remove old default config files

    minrk authored
  4. @minrk
  5. @minrk
  6. @minrk

    Split generic part of terminal frontend/terminal/ipapp into core/shel…

    minrk authored
    …lapp
    
    Now there's a class for IPKernel to inherit from in the qt code
  7. @minrk

    use App.instance() in launch_new_instance

    minrk authored
    This way later calls to App.instance() will return the running
    application, whereas calling App() would create an isolated
    Application object.
  8. @minrk
  9. @minrk

    QtConsole now uses newapp

    minrk authored
  10. @minrk
  11. @minrk

    add InlineBackendConfig

    minrk authored
    The inline backend now has preliminary config support for rc and figure format.
  12. @minrk
  13. @minrk
  14. @minrk
  15. @minrk

    expand default_editor message to include configurable

    minrk authored
    Also set the default editor to notepad on Windows.
  16. @minrk
  17. @minrk
  18. @minrk

    use App.instance() in kernel launchers

    minrk authored
    This way later calls to App.instance() will return the running
    application, whereas calling App() would create an isolated
    Application object.
  19. @minrk
  20. @minrk

    add qtconsole as subapp of terminal ipapp

    minrk authored
    Now 'ipython qtconsole' will behave the same as 'ipython-qtconsole'
  21. @minrk
  22. @minrk

    merge #492 newapp-qt

    minrk authored
  23. @minrk
  24. @minrk
  25. @minrk

    restore auto_create behavior

    minrk authored
  26. @minrk

    cleanup parallel traits

    minrk authored
    * eliminate use of CUnicode
    * eliminate use of Str
    * all remaining CStr will become CBytes
  27. @minrk
  28. @minrk
  29. @minrk
  30. @minrk
  31. @minrk

    rename clusterdir to more descriptive baseapp

    minrk authored
    since the 'clusterdir' part is now in the base newapplication, and not cluster-specific.
  32. @minrk
  33. @minrk
  34. @minrk
  35. @minrk

    fix %px magic output for single target

    minrk authored
    parallelmagic._maybe_display expects result.stdout to be a list,
    but did not handle the single-result case where it is the stdout string
    itself, thus printing the first character rather than the whole string.
    
    test included
  36. @minrk

    use HMAC digest to sign messages instead of cleartext key

    minrk authored
    also some cleanup of Session code
    
    security doc updated as well.
    
    Buffers do not get digested, so large (non-copying) messages should not
    cause performance to suffer too greatly.
  37. @minrk
  38. @minrk

    use App.instance() in launch_new_instance (parallel apps)

    minrk authored
    This way later calls to App.instance() will return the running
    application, whereas calling App() would create an isolated
    Application object.
  39. @minrk

    don't pass profile_dir as kwarg in ipclusterapp

    minrk authored
    also fix PBS->SGE typo from copy/paste
  40. @minrk

    fix SGE jobarray regex

    minrk authored
  41. @takluyver @minrk

    Replace Itpl with str.format in parallel launcher.

    takluyver authored minrk committed
    Signed-off-by: MinRK <benjaminrk@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 3,597 additions and 4,506 deletions.
  1. 0  IPython/config/default/__init__.py
  2. +0 −241 IPython/config/default/ipcluster_config.py
  3. +0 −180 IPython/config/default/ipcontroller_config.py
  4. +0 −85 IPython/config/default/ipengine_config.py
  5. +0 −165 IPython/config/default/ipython_config.py
  6. +10 −8 IPython/config/profile/cluster/ipython_config.py
  7. +22 −21 IPython/config/profile/default/ipcluster_config.py
  8. +13 −12 IPython/config/profile/default/ipcontroller_config.py
  9. +11 −10 IPython/config/profile/default/ipengine_config.py
  10. +36 −11 IPython/config/profile/default/ipython_config.py
  11. +0 −24 IPython/config/profile/ipython_config_cluster.py
  12. +0 −19 IPython/config/profile/ipython_config_math.py
  13. +0 −20 IPython/config/profile/ipython_config_numeric.py
  14. +0 −22 IPython/config/profile/ipython_config_pylab.py
  15. +0 −29 IPython/config/profile/ipython_config_pysh.py
  16. +0 −29 IPython/config/profile/ipython_config_sympy.py
  17. +7 −4 IPython/config/profile/math/ipython_config.py
  18. +8 −6 IPython/config/profile/pylab/ipython_config.py
  19. +6 −4 IPython/config/profile/pysh/ipython_config.py
  20. +9 −7 IPython/config/profile/sympy/ipython_config.py
  21. +3 −6 IPython/core/history.py
  22. +22 −11 IPython/core/interactiveshell.py
  23. +14 −28 IPython/core/magic.py
  24. +243 −0 IPython/core/shellapp.py
  25. +15 −9 IPython/extensions/parallelmagic.py
  26. +4 −4 IPython/frontend/qt/base_frontend_mixin.py
  27. +63 −33 IPython/frontend/qt/console/console_widget.py
  28. +6 −5 IPython/frontend/qt/console/frontend_widget.py
  29. +51 −33 IPython/frontend/qt/console/ipython_widget.py
  30. +250 −125 IPython/frontend/qt/console/ipythonqt.py
  31. +16 −16 IPython/frontend/qt/kernelmanager.py
  32. +38 −12 IPython/frontend/terminal/interactiveshell.py
  33. +202 −503 IPython/frontend/terminal/ipapp.py
  34. +1 −3 IPython/lib/irunner.py
  35. +46 −32 IPython/lib/pylabtools.py
  36. +257 −0 IPython/parallel/apps/baseapp.py
  37. +0 −566 IPython/parallel/apps/clusterdir.py
  38. +355 −451 IPython/parallel/apps/ipclusterapp.py
  39. +235 −266 IPython/parallel/apps/ipcontrollerapp.py
  40. +130 −163 IPython/parallel/apps/ipengineapp.py
  41. +28 −64 IPython/parallel/apps/iploggerapp.py
  42. +242 −171 IPython/parallel/apps/launcher.py
  43. +19 −9 IPython/parallel/apps/logwatcher.py
  44. +37 −37 IPython/parallel/apps/winhpcjob.py
  45. +14 −14 IPython/parallel/client/client.py
  46. +0 −116 IPython/parallel/controller/controller.py
  47. +2 −2 IPython/parallel/controller/dictdb.py
  48. +6 −4 IPython/parallel/controller/heartmonitor.py
  49. +94 −99 IPython/parallel/controller/hub.py
  50. +15 −4 IPython/parallel/controller/mongodb.py
  51. +42 −20 IPython/parallel/controller/scheduler.py
  52. +20 −7 IPython/parallel/controller/sqlitedb.py
  53. +18 −9 IPython/parallel/engine/engine.py
  54. +6 −4 IPython/parallel/engine/streamkernel.py
  55. +21 −74 IPython/parallel/factory.py
  56. +139 −75 IPython/parallel/streamsession.py
  57. +2 −2 IPython/parallel/tests/__init__.py
  58. +3 −3 IPython/parallel/tests/test_streamsession.py
  59. +1 −0  IPython/parallel/tests/test_view.py
  60. +3 −3 IPython/testing/tools.py
  61. +8 −8 IPython/zmq/blockingkernelmanager.py
  62. +29 −168 IPython/zmq/entry_point.py
  63. +147 −163 IPython/zmq/ipkernel.py
  64. +214 −0 IPython/zmq/kernelapp.py
  65. +46 −46 IPython/zmq/kernelmanager.py
  66. +13 −0 IPython/zmq/logtopics.rst
  67. +45 −83 IPython/zmq/pykernel.py
  68. +47 −11 IPython/zmq/pylab/backend_inline.py
  69. +2 −2 IPython/zmq/tests/test_message_spec.py
  70. +111 −0 IPython/zmq/tests/test_session.py
  71. +12 −12 docs/source/config/ipython.txt
  72. +6 −6 docs/source/config/overview.txt
  73. +23 −20 docs/source/interactive/qtconsole.txt
  74. +48 −47 docs/source/interactive/reference.txt
  75. +1 −1  docs/source/interactive/tutorial.txt
  76. +1 −1  docs/source/parallel/parallel_intro.txt
  77. +5 −5 docs/source/parallel/parallel_mpi.txt
  78. +1 −1  docs/source/parallel/parallel_multiengine.txt
  79. +20 −19 docs/source/parallel/parallel_process.txt
  80. +23 −23 docs/source/parallel/parallel_security.txt
  81. +5 −5 docs/source/parallel/parallel_task.txt
  82. +5 −5 docs/source/parallel/parallel_winhpc.txt
View
0  IPython/config/default/__init__.py
No changes.
View
241 IPython/config/default/ipcluster_config.py
@@ -1,241 +0,0 @@
-import os
-
-c = get_config()
-
-#-----------------------------------------------------------------------------
-# Select which launchers to use
-#-----------------------------------------------------------------------------
-
-# This allows you to control what method is used to start the controller
-# and engines. The following methods are currently supported:
-# - Start as a regular process on localhost.
-# - Start using mpiexec.
-# - Start using the Windows HPC Server 2008 scheduler
-# - Start using PBS/SGE
-# - Start using SSH
-
-
-# The selected launchers can be configured below.
-
-# Options are:
-# - LocalControllerLauncher
-# - MPIExecControllerLauncher
-# - PBSControllerLauncher
-# - SGEControllerLauncher
-# - WindowsHPCControllerLauncher
-# c.Global.controller_launcher = 'IPython.parallel.apps.launcher.LocalControllerLauncher'
-# c.Global.controller_launcher = 'IPython.parallel.apps.launcher.PBSControllerLauncher'
-
-# Options are:
-# - LocalEngineSetLauncher
-# - MPIExecEngineSetLauncher
-# - PBSEngineSetLauncher
-# - SGEEngineSetLauncher
-# - WindowsHPCEngineSetLauncher
-# c.Global.engine_launcher = 'IPython.parallel.apps.launcher.LocalEngineSetLauncher'
-
-#-----------------------------------------------------------------------------
-# Global configuration
-#-----------------------------------------------------------------------------
-
-# The default number of engines that will be started. This is overridden by
-# the -n command line option: "ipcluster start -n 4"
-# c.Global.n = 2
-
-# Log to a file in cluster_dir/log, otherwise just log to sys.stdout.
-# c.Global.log_to_file = False
-
-# Remove old logs from cluster_dir/log before starting.
-# c.Global.clean_logs = True
-
-# The working directory for the process. The application will use os.chdir
-# to change to this directory before starting.
-# c.Global.work_dir = os.getcwd()
-
-
-#-----------------------------------------------------------------------------
-# Local process launchers
-#-----------------------------------------------------------------------------
-
-# The command line arguments to call the controller with.
-# c.LocalControllerLauncher.controller_args = \
-# ['--log-to-file','--log-level', '40']
-
-# The working directory for the controller
-# c.LocalEngineSetLauncher.work_dir = u''
-
-# Command line argument passed to the engines.
-# c.LocalEngineSetLauncher.engine_args = ['--log-to-file','--log-level', '40']
-
-#-----------------------------------------------------------------------------
-# MPIExec launchers
-#-----------------------------------------------------------------------------
-
-# The mpiexec/mpirun command to use in both the controller and engines.
-# c.MPIExecLauncher.mpi_cmd = ['mpiexec']
-
-# Additional arguments to pass to the actual mpiexec command.
-# c.MPIExecLauncher.mpi_args = []
-
-# The mpiexec/mpirun command and args can be overridden if they should be different
-# for controller and engines.
-# c.MPIExecControllerLauncher.mpi_cmd = ['mpiexec']
-# c.MPIExecControllerLauncher.mpi_args = []
-# c.MPIExecEngineSetLauncher.mpi_cmd = ['mpiexec']
-# c.MPIExecEngineSetLauncher.mpi_args = []
-
-# The command line argument to call the controller with.
-# c.MPIExecControllerLauncher.controller_args = \
-# ['--log-to-file','--log-level', '40']
-
-# Command line argument passed to the engines.
-# c.MPIExecEngineSetLauncher.engine_args = ['--log-to-file','--log-level', '40']
-
-# The default number of engines to start if not given elsewhere.
-# c.MPIExecEngineSetLauncher.n = 1
-
-#-----------------------------------------------------------------------------
-# SSH launchers
-#-----------------------------------------------------------------------------
-
-# ipclusterz can be used to launch controller and engines remotely via ssh.
-# Note that currently ipclusterz does not do any file distribution, so if
-# machines are not on a shared filesystem, config and json files must be
-# distributed. For this reason, the reuse_files defaults to True on an
-# ssh-launched Controller. This flag can be overridded by the program_args
-# attribute of c.SSHControllerLauncher.
-
-# set the ssh cmd for launching remote commands. The default is ['ssh']
-# c.SSHLauncher.ssh_cmd = ['ssh']
-
-# set the ssh cmd for launching remote commands. The default is ['ssh']
-# c.SSHLauncher.ssh_args = ['tt']
-
-# Set the user and hostname for the controller
-# c.SSHControllerLauncher.hostname = 'controller.example.com'
-# c.SSHControllerLauncher.user = os.environ.get('USER','username')
-
-# Set the arguments to be passed to ipcontrollerz
-# note that remotely launched ipcontrollerz will not get the contents of
-# the local ipcontrollerz_config.py unless it resides on the *remote host*
-# in the location specified by the --cluster_dir argument.
-# c.SSHControllerLauncher.program_args = ['-r', '-ip', '0.0.0.0', '--cluster_dir', '/path/to/cd']
-
-# Set the default args passed to ipenginez for SSH launched engines
-# c.SSHEngineSetLauncher.engine_args = ['--mpi', 'mpi4py']
-
-# SSH engines are launched as a dict of locations/n-engines.
-# if a value is a tuple instead of an int, it is assumed to be of the form
-# (n, [args]), setting the arguments to passed to ipenginez on `host`.
-# otherwise, c.SSHEngineSetLauncher.engine_args will be used as the default.
-
-# In this case, there will be 3 engines at my.example.com, and
-# 2 at you@ipython.scipy.org with a special json connector location.
-# c.SSHEngineSetLauncher.engines = {'my.example.com' : 3,
-# 'you@ipython.scipy.org' : (2, ['-f', '/path/to/ipcontroller-engine.json']}
-# }
-
-#-----------------------------------------------------------------------------
-# Unix batch (PBS) schedulers launchers
-#-----------------------------------------------------------------------------
-
-# SGE and PBS are very similar. All configurables in this section called 'PBS*'
-# also exist as 'SGE*'.
-
-# The command line program to use to submit a PBS job.
-# c.PBSLauncher.submit_command = ['qsub']
-
-# The command line program to use to delete a PBS job.
-# c.PBSLauncher.delete_command = ['qdel']
-
-# The PBS queue in which the job should run
-# c.PBSLauncher.queue = 'myqueue'
-
-# A regular expression that takes the output of qsub and find the job id.
-# c.PBSLauncher.job_id_regexp = r'\d+'
-
-# If for some reason the Controller and Engines have different options above, they
-# can be set as c.PBSControllerLauncher.<option> etc.
-
-# PBS and SGE have default templates, but you can specify your own, either as strings
-# or from files, as described here:
-
-# The batch submission script used to start the controller. This is where
-# environment variables would be setup, etc. This string is interpreted using
-# the Itpl module in IPython.external. Basically, you can use ${n} for the
-# number of engine and ${cluster_dir} for the cluster_dir.
-# c.PBSControllerLauncher.batch_template = """
-# #PBS -N ipcontroller
-# #PBS -q $queue
-#
-# ipcontrollerz --cluster-dir $cluster_dir
-# """
-
-# You can also load this template from a file
-# c.PBSControllerLauncher.batch_template_file = u"/path/to/my/template.sh"
-
-# The name of the instantiated batch script that will actually be used to
-# submit the job. This will be written to the cluster directory.
-# c.PBSControllerLauncher.batch_file_name = u'pbs_controller'
-
-# The batch submission script used to start the engines. This is where
-# environment variables would be setup, etc. This string is interpreted using
-# the Itpl module in IPython.external. Basically, you can use ${n} for the
-# number of engine and ${cluster_dir} for the cluster_dir.
-# c.PBSEngineSetLauncher.batch_template = """
-# #PBS -N ipcontroller
-# #PBS -l nprocs=$n
-#
-# ipenginez --cluster-dir $cluster_dir$s
-# """
-
-# You can also load this template from a file
-# c.PBSControllerLauncher.batch_template_file = u"/path/to/my/template.sh"
-
-# The name of the instantiated batch script that will actually be used to
-# submit the job. This will be written to the cluster directory.
-# c.PBSEngineSetLauncher.batch_file_name = u'pbs_engines'
-
-
-
-#-----------------------------------------------------------------------------
-# Windows HPC Server 2008 launcher configuration
-#-----------------------------------------------------------------------------
-
-# c.IPControllerJob.job_name = 'IPController'
-# c.IPControllerJob.is_exclusive = False
-# c.IPControllerJob.username = r'USERDOMAIN\USERNAME'
-# c.IPControllerJob.priority = 'Highest'
-# c.IPControllerJob.requested_nodes = ''
-# c.IPControllerJob.project = 'MyProject'
-
-# c.IPControllerTask.task_name = 'IPController'
-# c.IPControllerTask.controller_cmd = [u'ipcontroller.exe']
-# c.IPControllerTask.controller_args = ['--log-to-file', '--log-level', '40']
-# c.IPControllerTask.environment_variables = {}
-
-# c.WindowsHPCControllerLauncher.scheduler = 'HEADNODE'
-# c.WindowsHPCControllerLauncher.job_file_name = u'ipcontroller_job.xml'
-
-
-# c.IPEngineSetJob.job_name = 'IPEngineSet'
-# c.IPEngineSetJob.is_exclusive = False
-# c.IPEngineSetJob.username = r'USERDOMAIN\USERNAME'
-# c.IPEngineSetJob.priority = 'Highest'
-# c.IPEngineSetJob.requested_nodes = ''
-# c.IPEngineSetJob.project = 'MyProject'
-
-# c.IPEngineTask.task_name = 'IPEngine'
-# c.IPEngineTask.engine_cmd = [u'ipengine.exe']
-# c.IPEngineTask.engine_args = ['--log-to-file', '--log-level', '40']
-# c.IPEngineTask.environment_variables = {}
-
-# c.WindowsHPCEngineSetLauncher.scheduler = 'HEADNODE'
-# c.WindowsHPCEngineSetLauncher.job_file_name = u'ipengineset_job.xml'
-
-
-
-
-
-
-
View
180 IPython/config/default/ipcontroller_config.py
@@ -1,180 +0,0 @@
-from IPython.config.loader import Config
-
-c = get_config()
-
-#-----------------------------------------------------------------------------
-# Global configuration
-#-----------------------------------------------------------------------------
-
-# Basic Global config attributes
-
-# Start up messages are logged to stdout using the logging module.
-# These all happen before the twisted reactor is started and are
-# useful for debugging purposes. Can be (10=DEBUG,20=INFO,30=WARN,40=CRITICAL)
-# and smaller is more verbose.
-# c.Global.log_level = 20
-
-# Log to a file in cluster_dir/log, otherwise just log to sys.stdout.
-# c.Global.log_to_file = False
-
-# Remove old logs from cluster_dir/log before starting.
-# c.Global.clean_logs = True
-
-# A list of Python statements that will be run before starting the
-# controller. This is provided because occasionally certain things need to
-# be imported in the controller for pickling to work.
-# c.Global.import_statements = ['import math']
-
-# Reuse the controller's JSON files. If False, JSON files are regenerated
-# each time the controller is run. If True, they will be reused, *but*, you
-# also must set the network ports by hand. If set, this will override the
-# values set for the client and engine connections below.
-# c.Global.reuse_files = True
-
-# Enable exec_key authentication on all messages. Default is True
-# c.Global.secure = True
-
-# The working directory for the process. The application will use os.chdir
-# to change to this directory before starting.
-# c.Global.work_dir = os.getcwd()
-
-# The log url for logging to an `iploggerz` application. This will override
-# log-to-file.
-# c.Global.log_url = 'tcp://127.0.0.1:20202'
-
-# The specific external IP that is used to disambiguate multi-interface URLs.
-# The default behavior is to guess from external IPs gleaned from `socket`.
-# c.Global.location = '192.168.1.123'
-
-# The ssh server remote clients should use to connect to this controller.
-# It must be a machine that can see the interface specified in client_ip.
-# The default for client_ip is localhost, in which case the sshserver must
-# be an external IP of the controller machine.
-# c.Global.sshserver = 'controller.example.com'
-
-# the url to use for registration. If set, this overrides engine-ip,
-# engine-transport client-ip,client-transport, and regport.
-# c.RegistrationFactory.url = 'tcp://*:12345'
-
-# the port to use for registration. Clients and Engines both use this
-# port for registration.
-# c.RegistrationFactory.regport = 10101
-
-#-----------------------------------------------------------------------------
-# Configure the Task Scheduler
-#-----------------------------------------------------------------------------
-
-# The routing scheme. 'pure' will use the pure-ZMQ scheduler. Any other
-# value will use a Python scheduler with various routing schemes.
-# python schemes are: lru, weighted, random, twobin. Default is 'weighted'.
-# Note that the pure ZMQ scheduler does not support many features, such as
-# dying engines, dependencies, or engine-subset load-balancing.
-# c.ControllerFactory.scheme = 'pure'
-
-# The Python scheduler can limit the number of outstanding tasks per engine
-# by using an HWM option. This allows engines with long-running tasks
-# to not steal too many tasks from other engines. The default is 0, which
-# means agressively distribute messages, never waiting for them to finish.
-# c.TaskScheduler.hwm = 0
-
-# Whether to use Threads or Processes to start the Schedulers. Threads will
-# use less resources, but potentially reduce throughput. Default is to
-# use processes. Note that the a Python scheduler will always be in a Process.
-# c.ControllerFactory.usethreads
-
-#-----------------------------------------------------------------------------
-# Configure the Hub
-#-----------------------------------------------------------------------------
-
-# Which class to use for the db backend. Currently supported are DictDB (the
-# default), and MongoDB. Uncomment this line to enable MongoDB, which will
-# slow-down the Hub's responsiveness, but also reduce its memory footprint.
-# c.HubFactory.db_class = 'IPython.parallel.controller.mongodb.MongoDB'
-
-# The heartbeat ping frequency. This is the frequency (in ms) at which the
-# Hub pings engines for heartbeats. This determines how quickly the Hub
-# will react to engines coming and going. A lower number means faster response
-# time, but more network activity. The default is 100ms
-# c.HubFactory.ping = 100
-
-# HubFactory queue port pairs, to set by name: mux, iopub, control, task. Set
-# each as a tuple of length 2 of ints. The default is to find random
-# available ports
-# c.HubFactory.mux = (10102,10112)
-
-#-----------------------------------------------------------------------------
-# Configure the client connections
-#-----------------------------------------------------------------------------
-
-# Basic client connection config attributes
-
-# The network interface the controller will listen on for client connections.
-# This should be an IP address or interface on the controller. An asterisk
-# means listen on all interfaces. The transport can be any transport
-# supported by zeromq (tcp,epgm,pgm,ib,ipc):
-# c.HubFactory.client_ip = '*'
-# c.HubFactory.client_transport = 'tcp'
-
-# individual client ports to configure by name: query_port, notifier_port
-# c.HubFactory.query_port = 12345
-
-#-----------------------------------------------------------------------------
-# Configure the engine connections
-#-----------------------------------------------------------------------------
-
-# Basic config attributes for the engine connections.
-
-# The network interface the controller will listen on for engine connections.
-# This should be an IP address or interface on the controller. An asterisk
-# means listen on all interfaces. The transport can be any transport
-# supported by zeromq (tcp,epgm,pgm,ib,ipc):
-# c.HubFactory.engine_ip = '*'
-# c.HubFactory.engine_transport = 'tcp'
-
-# set the engine heartbeat ports to use:
-# c.HubFactory.hb = (10303,10313)
-
-#-----------------------------------------------------------------------------
-# Configure the TaskRecord database backend
-#-----------------------------------------------------------------------------
-
-# For memory/persistance reasons, tasks can be stored out-of-memory in a database.
-# Currently, only sqlite and mongodb are supported as backends, but the interface
-# is fairly simple, so advanced developers could write their own backend.
-
-# ----- in-memory configuration --------
-# this line restores the default behavior: in-memory storage of all results.
-# c.HubFactory.db_class = 'IPython.parallel.controller.dictdb.DictDB'
-
-# ----- sqlite configuration --------
-# use this line to activate sqlite:
-# c.HubFactory.db_class = 'IPython.parallel.controller.sqlitedb.SQLiteDB'
-
-# You can specify the name of the db-file. By default, this will be located
-# in the active cluster_dir, e.g. ~/.ipython/clusterz_default/tasks.db
-# c.SQLiteDB.filename = 'tasks.db'
-
-# You can also specify the location of the db-file, if you want it to be somewhere
-# other than the cluster_dir.
-# c.SQLiteDB.location = '/scratch/'
-
-# This will specify the name of the table for the controller to use. The default
-# behavior is to use the session ID of the SessionFactory object (a uuid). Overriding
-# this will result in results persisting for multiple sessions.
-# c.SQLiteDB.table = 'results'
-
-# ----- mongodb configuration --------
-# use this line to activate mongodb:
-# c.HubFactory.db_class = 'IPython.parallel.controller.mongodb.MongoDB'
-
-# You can specify the args and kwargs pymongo will use when creating the Connection.
-# For more information on what these options might be, see pymongo documentation.
-# c.MongoDB.connection_kwargs = {}
-# c.MongoDB.connection_args = []
-
-# This will specify the name of the mongo database for the controller to use. The default
-# behavior is to use the session ID of the SessionFactory object (a uuid). Overriding
-# this will result in task results persisting through multiple sessions.
-# c.MongoDB.database = 'ipythondb'
-
-
View
85 IPython/config/default/ipengine_config.py
@@ -1,85 +0,0 @@
-c = get_config()
-
-#-----------------------------------------------------------------------------
-# Global configuration
-#-----------------------------------------------------------------------------
-
-# Start up messages are logged to stdout using the logging module.
-# These all happen before the twisted reactor is started and are
-# useful for debugging purposes. Can be (10=DEBUG,20=INFO,30=WARN,40=CRITICAL)
-# and smaller is more verbose.
-# c.Global.log_level = 20
-
-# Log to a file in cluster_dir/log, otherwise just log to sys.stdout.
-# c.Global.log_to_file = False
-
-# Remove old logs from cluster_dir/log before starting.
-# c.Global.clean_logs = True
-
-# A list of strings that will be executed in the users namespace on the engine
-# before it connects to the controller.
-# c.Global.exec_lines = ['import numpy']
-
-# The engine will try to connect to the controller multiple times, to allow
-# the controller time to startup and write its FURL file. These parameters
-# control the number of retries (connect_max_tries) and the initial delay
-# (connect_delay) between attemps. The actual delay between attempts gets
-# longer each time by a factor of 1.5 (delay[i] = 1.5*delay[i-1])
-# those attemps.
-# c.Global.connect_delay = 0.1
-# c.Global.connect_max_tries = 15
-
-# By default, the engine will look for the controller's JSON file in its own
-# cluster directory. Sometimes, the JSON file will be elsewhere and this
-# attribute can be set to the full path of the JSON file.
-# c.Global.url_file = u'/path/to/my/ipcontroller-engine.json'
-
-# The working directory for the process. The application will use os.chdir
-# to change to this directory before starting.
-# c.Global.work_dir = os.getcwd()
-
-#-----------------------------------------------------------------------------
-# MPI configuration
-#-----------------------------------------------------------------------------
-
-# Upon starting the engine can be configured to call MPI_Init. This section
-# configures that.
-
-# Select which MPI section to execute to setup MPI. The value of this
-# attribute must match the name of another attribute in the MPI config
-# section (mpi4py, pytrilinos, etc.). This can also be set by the --mpi
-# command line option.
-# c.MPI.use = ''
-
-# Initialize MPI using mpi4py. To use this, set c.MPI.use = 'mpi4py' to use
-# --mpi=mpi4py at the command line.
-# c.MPI.mpi4py = """from mpi4py import MPI as mpi
-# mpi.size = mpi.COMM_WORLD.Get_size()
-# mpi.rank = mpi.COMM_WORLD.Get_rank()
-# """
-
-# Initialize MPI using pytrilinos. To use this, set c.MPI.use = 'pytrilinos'
-# to use --mpi=pytrilinos at the command line.
-# c.MPI.pytrilinos = """from PyTrilinos import Epetra
-# class SimpleStruct:
-# pass
-# mpi = SimpleStruct()
-# mpi.rank = 0
-# mpi.size = 0
-# """
-
-#-----------------------------------------------------------------------------
-# Developer level configuration attributes
-#-----------------------------------------------------------------------------
-
-# You shouldn't have to modify anything in this section. These attributes
-# are more for developers who want to change the behavior of the controller
-# at a fundamental level.
-
-# You should not have to change these attributes.
-
-# c.Global.url_file_name = u'ipcontroller-engine.furl'
-
-
-
-
View
165 IPython/config/default/ipython_config.py
@@ -1,165 +0,0 @@
-# Get the config being loaded so we can set attributes on it
-c = get_config()
-
-#-----------------------------------------------------------------------------
-# Global options
-#-----------------------------------------------------------------------------
-
-# c.Global.display_banner = True
-
-# c.Global.classic = False
-
-# c.Global.nosep = True
-
-# If you still use multiple versions of IPytho on the same machine,
-# set this to True to suppress warnings about old configuration files
-# c.Global.ignore_old_config = False
-
-# Set this to determine the detail of what is logged at startup.
-# The default is 30 and possible values are 0,10,20,30,40,50.
-# c.Global.log_level = 20
-
-# This should be a list of importable Python modules that have an
-# load_ipython_extension(ip) method. This method gets called when the extension
-# is loaded. You can put your extensions anywhere they can be imported
-# but we add the extensions subdir of the ipython directory to sys.path
-# during extension loading, so you can put them there as well.
-# c.Global.extensions = [
-# 'myextension'
-# ]
-
-# These lines are run in IPython in the user's namespace after extensions
-# are loaded. They can contain full IPython syntax with magics etc.
-# c.Global.exec_lines = [
-# 'import numpy',
-# 'a = 10; b = 20',
-# '1/0'
-# ]
-
-# These files are run in IPython in the user's namespace. Files with a .py
-# extension need to be pure Python. Files with a .ipy extension can have
-# custom IPython syntax (like magics, etc.).
-# These files need to be in the cwd, the ipython_dir or be absolute paths.
-# c.Global.exec_files = [
-# 'mycode.py',
-# 'fancy.ipy'
-# ]
-
-#-----------------------------------------------------------------------------
-# InteractiveShell options
-#-----------------------------------------------------------------------------
-
-# c.InteractiveShell.autocall = 1
-
-# c.TerminalInteractiveShell.autoedit_syntax = False
-
-# c.InteractiveShell.autoindent = True
-
-# c.InteractiveShell.automagic = False
-
-# c.TerminalTerminalInteractiveShell.banner1 = 'This if for overriding the default IPython banner'
-
-# c.TerminalTerminalInteractiveShell.banner2 = "This is for extra banner text"
-
-# c.InteractiveShell.cache_size = 1000
-
-# c.InteractiveShell.colors = 'LightBG'
-
-# c.InteractiveShell.color_info = True
-
-# c.TerminalInteractiveShell.confirm_exit = True
-
-# c.InteractiveShell.deep_reload = False
-
-# c.TerminalInteractiveShell.editor = 'nano'
-
-# c.InteractiveShell.logstart = True
-
-# c.InteractiveShell.logfile = u'ipython_log.py'
-
-# c.InteractiveShell.logappend = u'mylog.py'
-
-# c.InteractiveShell.object_info_string_level = 0
-
-# c.TerminalInteractiveShell.pager = 'less'
-
-# c.InteractiveShell.pdb = False
-
-# c.InteractiveShell.prompt_in1 = 'In [\#]: '
-# c.InteractiveShell.prompt_in2 = ' .\D.: '
-# c.InteractiveShell.prompt_out = 'Out[\#]: '
-# c.InteractiveShell.prompts_pad_left = True
-
-# c.InteractiveShell.quiet = False
-
-# c.InteractiveShell.history_length = 10000
-
-# Readline
-# c.InteractiveShell.readline_use = True
-
-# be careful with meta-key ('\M-<x>') bindings, because
-# they conflict with 8-bit encodings (e.g. UTF8)
-
-# c.InteractiveShell.readline_parse_and_bind = [
-# 'tab: complete',
-# '"\C-l": possible-completions',
-# 'set show-all-if-ambiguous on',
-# '"\C-o": tab-insert',
-# '"\C-r": reverse-search-history',
-# '"\C-s": forward-search-history',
-# '"\C-p": history-search-backward',
-# '"\C-n": history-search-forward',
-# '"\e[A": history-search-backward',
-# '"\e[B": history-search-forward',
-# '"\C-k": kill-line',
-# '"\C-u": unix-line-discard',
-# ]
-# c.InteractiveShell.readline_remove_delims = '-/~'
-# c.InteractiveShell.readline_merge_completions = True
-# c.InteractiveShell.readline_omit__names = 0
-
-# c.TerminalInteractiveShell.screen_length = 0
-
-# c.InteractiveShell.separate_in = '\n'
-# c.InteractiveShell.separate_out = ''
-# c.InteractiveShell.separate_out2 = ''
-
-# c.TerminalInteractiveShell.term_title = False
-
-# c.InteractiveShell.wildcards_case_sensitive = True
-
-# c.InteractiveShell.xmode = 'Context'
-
-#-----------------------------------------------------------------------------
-# Formatter and display options
-#-----------------------------------------------------------------------------
-
-# c.PlainTextFormatter.pprint = True
-
-#-----------------------------------------------------------------------------
-# PrefilterManager options
-#-----------------------------------------------------------------------------
-
-# c.PrefilterManager.multi_line_specials = True
-
-#-----------------------------------------------------------------------------
-# AliasManager options
-#-----------------------------------------------------------------------------
-
-# Do this to disable all defaults
-# c.AliasManager.default_aliases = []
-
-# c.AliasManager.user_aliases = [
-# ('foo', 'echo Hi')
-# ]
-
-#-----------------------------------------------------------------------------
-# HistoryManager options
-#-----------------------------------------------------------------------------
-
-# Enable logging output as well as input to the database.
-# c.HistoryManager.db_log_output = False
-
-# Only write to the database every n commands - this can save disk
-# access (and hence power) over the default of writing on every command.
-# c.HistoryManager.db_cache_size = 0
View
18 IPython/config/profile/cluster/ipython_config.py
@@ -1,24 +1,26 @@
c = get_config()
+app = c.IPythonApp
# This can be used at any point in a config file to load a sub config
# and merge it into the current one.
-load_subconfig('ipython_config.py')
+import os
+load_subconfig(os.path.join('..','profile_default', 'ipython_config.py'))
lines = """
-from IPython.kernel.client import *
+from IPython.parallel import *
"""
# You have to make sure that attributes that are containers already
# exist before using them. Simple assigning a new list will override
# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
+if hasattr(app, 'exec_lines'):
+ app.exec_lines.append(lines)
else:
- c.Global.exec_lines = [lines]
+ app.exec_lines = [lines]
# Load the parallelmagic extension to enable %result, %px, %autopx magics.
-if hasattr(c.Global, 'extensions'):
- c.Global.extensions.append('parallelmagic')
+if hasattr(app, 'extensions'):
+ app.extensions.append('parallelmagic')
else:
- c.Global.extensions = ['parallelmagic']
+ app.extensions = ['parallelmagic']
View
43 IPython/config/profile/default/ipcluster_config.py
@@ -23,8 +23,8 @@
# - PBSControllerLauncher
# - SGEControllerLauncher
# - WindowsHPCControllerLauncher
-# c.Global.controller_launcher = 'IPython.parallel.apps.launcher.LocalControllerLauncher'
-# c.Global.controller_launcher = 'IPython.parallel.apps.launcher.PBSControllerLauncher'
+# c.IPClusterStartApp.controller_launcher = 'IPython.parallel.apps.launcher.LocalControllerLauncher'
+# c.IPClusterStartApp.controller_launcher = 'IPython.parallel.apps.launcher.PBSControllerLauncher'
# Options are:
# - LocalEngineSetLauncher
@@ -32,25 +32,25 @@
# - PBSEngineSetLauncher
# - SGEEngineSetLauncher
# - WindowsHPCEngineSetLauncher
-# c.Global.engine_launcher = 'IPython.parallel.apps.launcher.LocalEngineSetLauncher'
+# c.IPClusterEnginesApp.engine_launcher = 'IPython.parallel.apps.launcher.LocalEngineSetLauncher'
#-----------------------------------------------------------------------------
-# Global configuration
+# Application configuration
#-----------------------------------------------------------------------------
# The default number of engines that will be started. This is overridden by
# the -n command line option: "ipcluster start -n 4"
-# c.Global.n = 2
+# c.IPClusterEnginesApp.n = 2
# Log to a file in cluster_dir/log, otherwise just log to sys.stdout.
-# c.Global.log_to_file = False
+# c.BaseParallelApp.log_to_file = False
# Remove old logs from cluster_dir/log before starting.
-# c.Global.clean_logs = True
+# c.BaseParallelApp.clean_logs = True
# The working directory for the process. The application will use os.chdir
# to change to this directory before starting.
-# c.Global.work_dir = os.getcwd()
+# c.BaseParallelApp.work_dir = os.getcwd()
#-----------------------------------------------------------------------------
@@ -121,12 +121,12 @@
# in the location specified by the --cluster_dir argument.
# c.SSHControllerLauncher.program_args = ['-r', '-ip', '0.0.0.0', '--cluster_dir', '/path/to/cd']
-# Set the default args passed to ipenginez for SSH launched engines
+# Set the default args passed to ipengine for SSH launched engines
# c.SSHEngineSetLauncher.engine_args = ['--mpi', 'mpi4py']
# SSH engines are launched as a dict of locations/n-engines.
# if a value is a tuple instead of an int, it is assumed to be of the form
-# (n, [args]), setting the arguments to passed to ipenginez on `host`.
+# (n, [args]), setting the arguments to passed to ipengine on `host`.
# otherwise, c.SSHEngineSetLauncher.engine_args will be used as the default.
# In this case, there will be 3 engines at my.example.com, and
@@ -162,13 +162,13 @@
# The batch submission script used to start the controller. This is where
# environment variables would be setup, etc. This string is interpreted using
-# the Itpl module in IPython.external. Basically, you can use ${n} for the
-# number of engine and ${cluster_dir} for the cluster_dir.
+# Python's string formatting. Basically, you can use {queue} for the name
+# of the PBS queue, and {profile_dir} for the profile_dir.
# c.PBSControllerLauncher.batch_template = """
# #PBS -N ipcontroller
-# #PBS -q $queue
+# #PBS -q {queue}
#
-# ipcontrollerz --cluster-dir $cluster_dir
+# ipcontroller profile_dir={profile_dir}
# """
# You can also load this template from a file
@@ -180,13 +180,14 @@
# The batch submission script used to start the engines. This is where
# environment variables would be setup, etc. This string is interpreted using
-# the Itpl module in IPython.external. Basically, you can use ${n} for the
-# number of engine and ${cluster_dir} for the cluster_dir.
+# Python's string formatting. Basically, you can use {queue} for the name
+# of the PBS queue, and {profile_dir} for the profile_dir, and {n}
+# for the number of engines.
# c.PBSEngineSetLauncher.batch_template = """
-# #PBS -N ipcontroller
-# #PBS -l nprocs=$n
+# #PBS -N ipengine
+# #PBS -l nprocs={n}
#
-# ipenginez --cluster-dir $cluster_dir$s
+# ipengine profile_dir={profile_dir}
# """
# You can also load this template from a file
@@ -211,7 +212,7 @@
# c.IPControllerTask.task_name = 'IPController'
# c.IPControllerTask.controller_cmd = [u'ipcontroller.exe']
-# c.IPControllerTask.controller_args = ['--log-to-file', '--log-level', '40']
+# c.IPControllerTask.controller_args = ['--log-to-file', 'log_level=40']
# c.IPControllerTask.environment_variables = {}
# c.WindowsHPCControllerLauncher.scheduler = 'HEADNODE'
@@ -227,7 +228,7 @@
# c.IPEngineTask.task_name = 'IPEngine'
# c.IPEngineTask.engine_cmd = [u'ipengine.exe']
-# c.IPEngineTask.engine_args = ['--log-to-file', '--log-level', '40']
+# c.IPEngineTask.engine_args = ['--log-to-file', 'log_level=40']
# c.IPEngineTask.environment_variables = {}
# c.WindowsHPCEngineSetLauncher.scheduler = 'HEADNODE'
View
25 IPython/config/profile/default/ipcontroller_config.py
@@ -3,54 +3,55 @@
c = get_config()
#-----------------------------------------------------------------------------
-# Global configuration
+# Application configuration
#-----------------------------------------------------------------------------
+app = c.IPControllerApp
-# Basic Global config attributes
+# Basic Application config attributes
# Start up messages are logged to stdout using the logging module.
# These all happen before the twisted reactor is started and are
# useful for debugging purposes. Can be (10=DEBUG,20=INFO,30=WARN,40=CRITICAL)
# and smaller is more verbose.
-# c.Global.log_level = 20
+# app.log_level = 20
# Log to a file in cluster_dir/log, otherwise just log to sys.stdout.
-# c.Global.log_to_file = False
+# app.log_to_file = False
# Remove old logs from cluster_dir/log before starting.
-# c.Global.clean_logs = True
+# app.clean_logs = True
# A list of Python statements that will be run before starting the
# controller. This is provided because occasionally certain things need to
# be imported in the controller for pickling to work.
-# c.Global.import_statements = ['import math']
+# app.import_statements = ['import math']
# Reuse the controller's JSON files. If False, JSON files are regenerated
# each time the controller is run. If True, they will be reused, *but*, you
# also must set the network ports by hand. If set, this will override the
# values set for the client and engine connections below.
-# c.Global.reuse_files = True
+# app.reuse_files = True
# Enable exec_key authentication on all messages. Default is True
-# c.Global.secure = True
+# app.secure = True
# The working directory for the process. The application will use os.chdir
# to change to this directory before starting.
-# c.Global.work_dir = os.getcwd()
+# app.work_dir = os.getcwd()
# The log url for logging to an `iploggerz` application. This will override
# log-to-file.
-# c.Global.log_url = 'tcp://127.0.0.1:20202'
+# app.log_url = 'tcp://127.0.0.1:20202'
# The specific external IP that is used to disambiguate multi-interface URLs.
# The default behavior is to guess from external IPs gleaned from `socket`.
-# c.Global.location = '192.168.1.123'
+# app.location = '192.168.1.123'
# The ssh server remote clients should use to connect to this controller.
# It must be a machine that can see the interface specified in client_ip.
# The default for client_ip is localhost, in which case the sshserver must
# be an external IP of the controller machine.
-# c.Global.sshserver = 'controller.example.com'
+# app.sshserver = 'controller.example.com'
# the url to use for registration. If set, this overrides engine-ip,
# engine-transport client-ip,client-transport, and regport.
View
21 IPython/config/profile/default/ipengine_config.py
@@ -1,24 +1,25 @@
c = get_config()
#-----------------------------------------------------------------------------
-# Global configuration
+# Application configuration
#-----------------------------------------------------------------------------
+app = c.IPEngineApp
# Start up messages are logged to stdout using the logging module.
# These all happen before the twisted reactor is started and are
# useful for debugging purposes. Can be (10=DEBUG,20=INFO,30=WARN,40=CRITICAL)
# and smaller is more verbose.
-# c.Global.log_level = 20
+# app.log_level = 20
# Log to a file in cluster_dir/log, otherwise just log to sys.stdout.
-# c.Global.log_to_file = False
+# app.log_to_file = False
# Remove old logs from cluster_dir/log before starting.
-# c.Global.clean_logs = True
+# app.clean_logs = True
# A list of strings that will be executed in the users namespace on the engine
# before it connects to the controller.
-# c.Global.exec_lines = ['import numpy']
+# app.exec_lines = ['import numpy']
# The engine will try to connect to the controller multiple times, to allow
# the controller time to startup and write its FURL file. These parameters
@@ -26,17 +27,17 @@
# (connect_delay) between attemps. The actual delay between attempts gets
# longer each time by a factor of 1.5 (delay[i] = 1.5*delay[i-1])
# those attemps.
-# c.Global.connect_delay = 0.1
-# c.Global.connect_max_tries = 15
+# app.connect_delay = 0.1
+# app.connect_max_tries = 15
# By default, the engine will look for the controller's JSON file in its own
# cluster directory. Sometimes, the JSON file will be elsewhere and this
# attribute can be set to the full path of the JSON file.
-# c.Global.url_file = u'/path/to/my/ipcontroller-engine.json'
+# app.url_file = u'/path/to/my/ipcontroller-engine.json'
# The working directory for the process. The application will use os.chdir
# to change to this directory before starting.
-# c.Global.work_dir = os.getcwd()
+# app.work_dir = os.getcwd()
#-----------------------------------------------------------------------------
# MPI configuration
@@ -78,7 +79,7 @@
# You should not have to change these attributes.
-# c.Global.url_file_name = u'ipcontroller-engine.furl'
+# app.url_file_name = u'ipcontroller-engine.furl'
View
47 IPython/config/profile/default/ipython_config.py
@@ -2,35 +2,35 @@
c = get_config()
#-----------------------------------------------------------------------------
-# Global options
+# Application-level options
#-----------------------------------------------------------------------------
-# c.Global.display_banner = True
+# c.TerminalIPythonApp.display_banner = True
-# c.Global.classic = False
+# c.TerminalIPythonApp.classic = False
-# c.Global.nosep = True
+# c.TerminalIPythonApp.nosep = True
# If you still use multiple versions of IPytho on the same machine,
# set this to True to suppress warnings about old configuration files
-# c.Global.ignore_old_config = False
+# c.TerminalIPythonApp.ignore_old_config = False
# Set this to determine the detail of what is logged at startup.
# The default is 30 and possible values are 0,10,20,30,40,50.
-# c.Global.log_level = 20
+# c.Application.log_level = 20
# This should be a list of importable Python modules that have an
# load_ipython_extension(ip) method. This method gets called when the extension
# is loaded. You can put your extensions anywhere they can be imported
# but we add the extensions subdir of the ipython directory to sys.path
# during extension loading, so you can put them there as well.
-# c.Global.extensions = [
+# c.InteractiveShellApp.extensions = [
# 'myextension'
# ]
# These lines are run in IPython in the user's namespace after extensions
# are loaded. They can contain full IPython syntax with magics etc.
-# c.Global.exec_lines = [
+# c.InteractiveShellApp.exec_lines = [
# 'import numpy',
# 'a = 10; b = 20',
# '1/0'
@@ -40,7 +40,7 @@
# extension need to be pure Python. Files with a .ipy extension can have
# custom IPython syntax (like magics, etc.).
# These files need to be in the cwd, the ipython_dir or be absolute paths.
-# c.Global.exec_files = [
+# c.InteractiveShellApp.exec_files = [
# 'mycode.py',
# 'fancy.ipy'
# ]
@@ -57,9 +57,9 @@
# c.InteractiveShell.automagic = False
-# c.TerminalTerminalInteractiveShell.banner1 = 'This if for overriding the default IPython banner'
+# c.TerminalInteractiveShell.banner1 = 'This if for overriding the default IPython banner'
-# c.TerminalTerminalInteractiveShell.banner2 = "This is for extra banner text"
+# c.TerminalInteractiveShell.banner2 = "This is for extra banner text"
# c.InteractiveShell.cache_size = 1000
@@ -163,3 +163,28 @@
# Only write to the database every n commands - this can save disk
# access (and hence power) over the default of writing on every command.
# c.HistoryManager.db_cache_size = 0
+
+#-----------------------------------------------------------------------------
+# QtConsole configuration
+#-----------------------------------------------------------------------------
+
+# set the preferred typeface and font size. The default typeface is:
+# 'Consolas' on Windows (fallback to 'Courier')
+# 'Monaco' on OSX
+# 'Monospace' elsewhere
+# c.ConsoleWidget.font_family = "Consolas"
+
+# The point fontsize. Leave as zero to let Qt decide on the starting font size.
+# While running, you can change the font size with ctrl- +/-
+# c.ConsoleWidget.font_size = 0
+
+# set the pygments syntax-highlighting style:
+# c.IPythonWidget.syntax_style = 'default'
+
+# Configure the prompts:
+# c.IPythonWidget.in_prompt = 'In [<span class="in-prompt-number">%i</span>]: '
+# c.IPythonWidget.out_prompt = 'Out[<span class="out-prompt-number">%i</span>]: '
+
+# set the editor - this must be a *GUI* editor, like notepad/gedit/TextMate
+# There is no default on systems other than Windows.
+# c.IPythonWidget.editor = 'notepad'
View
24 IPython/config/profile/ipython_config_cluster.py
@@ -1,24 +0,0 @@
-c = get_config()
-
-# This can be used at any point in a config file to load a sub config
-# and merge it into the current one.
-load_subconfig('ipython_config.py')
-
-lines = """
-from IPython.kernel.client import *
-"""
-
-# You have to make sure that attributes that are containers already
-# exist before using them. Simple assigning a new list will override
-# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
-else:
- c.Global.exec_lines = [lines]
-
-# Load the parallelmagic extension to enable %result, %px, %autopx magics.
-if hasattr(c.Global, 'extensions'):
- c.Global.extensions.append('parallelmagic')
-else:
- c.Global.extensions = ['parallelmagic']
-
View
19 IPython/config/profile/ipython_config_math.py
@@ -1,19 +0,0 @@
-c = get_config()
-
-# This can be used at any point in a config file to load a sub config
-# and merge it into the current one.
-load_subconfig('ipython_config.py')
-
-lines = """
-import cmath
-from math import *
-"""
-
-# You have to make sure that attributes that are containers already
-# exist before using them. Simple assigning a new list will override
-# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
-else:
- c.Global.exec_lines = [lines]
-
View
20 IPython/config/profile/ipython_config_numeric.py
@@ -1,20 +0,0 @@
-c = get_config()
-
-# This can be used at any point in a config file to load a sub config
-# and merge it into the current one.
-load_subconfig('ipython_config.py')
-
-lines = """
-import numpy
-import scipy
-import numpy as np
-import scipy as sp
-"""
-
-# You have to make sure that attributes that are containers already
-# exist before using them. Simple assigning a new list will override
-# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
-else:
- c.Global.exec_lines = [lines]
View
22 IPython/config/profile/ipython_config_pylab.py
@@ -1,22 +0,0 @@
-c = get_config()
-
-# This can be used at any point in a config file to load a sub config
-# and merge it into the current one.
-load_subconfig('ipython_config.py')
-
-lines = """
-import matplotlib
-%gui -a wx
-matplotlib.use('wxagg')
-matplotlib.interactive(True)
-from matplotlib import pyplot as plt
-from matplotlib.pyplot import *
-"""
-
-# You have to make sure that attributes that are containers already
-# exist before using them. Simple assigning a new list will override
-# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
-else:
- c.Global.exec_lines = [lines]
View
29 IPython/config/profile/ipython_config_pysh.py
@@ -1,29 +0,0 @@
-c = get_config()
-
-# This can be used at any point in a config file to load a sub config
-# and merge it into the current one.
-load_subconfig('ipython_config.py')
-
-c.InteractiveShell.prompt_in1 = '\C_LightGreen\u@\h\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
-c.InteractiveShell.prompt_in2 = '\C_Green|\C_LightGreen\D\C_Green> '
-c.InteractiveShell.prompt_out = '<\#> '
-
-c.InteractiveShell.prompts_pad_left = True
-
-c.InteractiveShell.separate_in = ''
-c.InteractiveShell.separate_out = ''
-c.InteractiveShell.separate_out2 = ''
-
-c.PrefilterManager.multi_line_specials = True
-
-lines = """
-%rehashx
-"""
-
-# You have to make sure that attributes that are containers already
-# exist before using them. Simple assigning a new list will override
-# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
-else:
- c.Global.exec_lines = [lines]
View
29 IPython/config/profile/ipython_config_sympy.py
@@ -1,29 +0,0 @@
-c = get_config()
-
-# This can be used at any point in a config file to load a sub config
-# and merge it into the current one.
-load_subconfig('ipython_config.py')
-
-lines = """
-from __future__ import division
-from sympy import *
-x, y, z = symbols('xyz')
-k, m, n = symbols('kmn', integer=True)
-f, g, h = map(Function, 'fgh')
-"""
-
-# You have to make sure that attributes that are containers already
-# exist before using them. Simple assigning a new list will override
-# all previous values.
-
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
-else:
- c.Global.exec_lines = [lines]
-
-# Load the sympy_printing extension to enable nice printing of sympy expr's.
-if hasattr(c.Global, 'extensions'):
- c.Global.extensions.append('sympy_printing')
-else:
- c.Global.extensions = ['sympy_printing']
-
View
11 IPython/config/profile/math/ipython_config.py
@@ -1,8 +1,10 @@
c = get_config()
+app = c.IPythonApp
# This can be used at any point in a config file to load a sub config
# and merge it into the current one.
-load_subconfig('ipython_config.py')
+import os
+load_subconfig(os.path.join('..','profile_default', 'ipython_config.py'))
lines = """
import cmath
@@ -12,8 +14,9 @@
# You have to make sure that attributes that are containers already
# exist before using them. Simple assigning a new list will override
# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
+
+if hasattr(app, 'exec_lines'):
+ app.exec_lines.append(lines)
else:
- c.Global.exec_lines = [lines]
+ app.exec_lines = [lines]
View
14 IPython/config/profile/pylab/ipython_config.py
@@ -1,13 +1,15 @@
c = get_config()
+app = c.IPythonApp
# This can be used at any point in a config file to load a sub config
# and merge it into the current one.
-load_subconfig('ipython_config.py')
+import os
+load_subconfig(os.path.join('..','profile_default', 'ipython_config.py'))
lines = """
import matplotlib
-%gui -a wx
-matplotlib.use('wxagg')
+%gui qt
+matplotlib.use('qtagg')
matplotlib.interactive(True)
from matplotlib import pyplot as plt
from matplotlib.pyplot import *
@@ -16,7 +18,7 @@
# You have to make sure that attributes that are containers already
# exist before using them. Simple assigning a new list will override
# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
+if hasattr(app, 'exec_lines'):
+ app.exec_lines.append(lines)
else:
- c.Global.exec_lines = [lines]
+ app.exec_lines = [lines]
View
10 IPython/config/profile/pysh/ipython_config.py
@@ -1,8 +1,10 @@
c = get_config()
+app = c.IPythonApp
# This can be used at any point in a config file to load a sub config
# and merge it into the current one.
-load_subconfig('ipython_config.py')
+import os
+load_subconfig(os.path.join('..','profile_default', 'ipython_config.py'))
c.InteractiveShell.prompt_in1 = '\C_LightGreen\u@\h\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
c.InteractiveShell.prompt_in2 = '\C_Green|\C_LightGreen\D\C_Green> '
@@ -23,7 +25,7 @@
# You have to make sure that attributes that are containers already
# exist before using them. Simple assigning a new list will override
# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
+if hasattr(app, 'exec_lines'):
+ app.exec_lines.append(lines)
else:
- c.Global.exec_lines = [lines]
+ app.exec_lines = [lines]
View
16 IPython/config/profile/sympy/ipython_config.py
@@ -1,8 +1,10 @@
c = get_config()
+app = c.IPythonApp
# This can be used at any point in a config file to load a sub config
# and merge it into the current one.
-load_subconfig('ipython_config.py')
+import os
+load_subconfig(os.path.join('..','profile_default', 'ipython_config.py'))
lines = """
from __future__ import division
@@ -16,14 +18,14 @@
# exist before using them. Simple assigning a new list will override
# all previous values.
-if hasattr(c.Global, 'exec_lines'):
- c.Global.exec_lines.append(lines)
+if hasattr(app, 'exec_lines'):
+ app.exec_lines.append(lines)
else:
- c.Global.exec_lines = [lines]
+ app.exec_lines = [lines]
# Load the sympy_printing extension to enable nice printing of sympy expr's.
-if hasattr(c.Global, 'extensions'):
- c.Global.extensions.append('sympy_printing')
+if hasattr(app, 'extensions'):
+ app.extensions.append('sympy_printing')
else:
- c.Global.extensions = ['sympy_printing']
+ app.extensions = ['sympy_printing']
View
9 IPython/core/history.py
@@ -101,18 +101,15 @@ def __init__(self, shell, config=None, **traits):
if self.hist_file == u'':
# No one has set the hist_file, yet.
- if shell.profile:
- histfname = 'history-%s' % shell.profile
- else:
- histfname = 'history'
- self.hist_file = os.path.join(shell.ipython_dir, histfname + '.sqlite')
+ histfname = 'history'
+ self.hist_file = os.path.join(shell.profile_dir.location, histfname + '.sqlite')
try:
self.init_db()
except sqlite3.DatabaseError:
if os.path.isfile(self.hist_file):
# Try to move the file out of the way.
- newpath = os.path.join(self.shell.ipython_dir, "hist-corrupt.sqlite")
+ newpath = os.path.join(self.shell.profile_dir.location, "hist-corrupt.sqlite")
os.rename(self.hist_file, newpath)
print("ERROR! History file wasn't a valid SQLite database.",
"It was moved to %s" % newpath, "and a new file created.")
View
33 IPython/core/interactiveshell.py
@@ -54,6 +54,7 @@
from IPython.core.logger import Logger
from IPython.core.macro import Macro
from IPython.core.magic import Magic
+from IPython.core.newapplication import ProfileDir
from IPython.core.payload import PayloadManager
from IPython.core.plugin import PluginManager
from IPython.core.prefilter import PrefilterManager, ESC_MAGIC
@@ -238,7 +239,9 @@ class InteractiveShell(SingletonConfigurable, Magic):
"""
)
colors = CaselessStrEnum(('NoColor','LightBG','Linux'),
- default_value=get_default_colors(), config=True)
+ default_value=get_default_colors(), config=True,
+ help="Set the color scheme (NoColor, Linux, or LightBG)."
+ )
debug = CBool(False, config=True)
deep_reload = CBool(False, config=True, help=
"""
@@ -291,7 +294,6 @@ def _exiter_default(self):
"""
)
- profile = Unicode('', config=True)
prompt_in1 = Str('In [\\#]: ', config=True)
prompt_in2 = Str(' .\\D.: ', config=True)
prompt_out = Str('Out[\\#]: ', config=True)
@@ -342,10 +344,18 @@ def _exiter_default(self):
payload_manager = Instance('IPython.core.payload.PayloadManager')
history_manager = Instance('IPython.core.history.HistoryManager')
+ profile_dir = Instance('IPython.core.newapplication.ProfileDir')
+ @property
+ def profile(self):
+ if self.profile_dir is not None:
+ name = os.path.basename(self.profile_dir.location)
+ return name.replace('profile_','')
+
+
# Private interface
_post_execute = Instance(dict)
- def __init__(self, config=None, ipython_dir=None,
+ def __init__(self, config=None, ipython_dir=None, profile_dir=None,
user_ns=None, user_global_ns=None,
custom_exceptions=((), None)):
@@ -355,6 +365,7 @@ def __init__(self, config=None, ipython_dir=None,
# These are relatively independent and stateless
self.init_ipython_dir(ipython_dir)
+ self.init_profile_dir(profile_dir)
self.init_instance_attrs()
self.init_environment()
@@ -372,7 +383,7 @@ def __init__(self, config=None, ipython_dir=None,
# While we're trying to have each part of the code directly access what
# it needs without keeping redundant references to objects, we have too
# much legacy code that expects ip.db to exist.
- self.db = PickleShareDB(os.path.join(self.ipython_dir, 'db'))
+ self.db = PickleShareDB(os.path.join(self.profile_dir.location, 'db'))
self.init_history()
self.init_encoding()
@@ -457,16 +468,16 @@ def set_autoindent(self,value=None):
def init_ipython_dir(self, ipython_dir):
if ipython_dir is not None:
self.ipython_dir = ipython_dir
- self.config.Global.ipython_dir = self.ipython_dir
return
- if hasattr(self.config.Global, 'ipython_dir'):
- self.ipython_dir = self.config.Global.ipython_dir
- else:
- self.ipython_dir = get_ipython_dir()
+ self.ipython_dir = get_ipython_dir()
- # All children can just read this
- self.config.Global.ipython_dir = self.ipython_dir
+ def init_profile_dir(self, profile_dir):
+ if profile_dir is not None:
+ self.profile_dir = profile_dir
+ return
+ self.profile_dir =\
+ ProfileDir.create_profile_dir_by_name(self.ipython_dir, 'default')
def init_instance_attrs(self):
self.more = False
View
42 IPython/core/magic.py
@@ -46,6 +46,7 @@
from IPython.core.error import TryNext
from IPython.core.error import UsageError
from IPython.core.fakemodule import FakeModule
+from IPython.core.newapplication import ProfileDir
from IPython.core.macro import Macro
from IPython.core import page
from IPython.core.prefilter import ESC_MAGIC
@@ -533,10 +534,7 @@ def magic_page(self, parameter_s=''):
def magic_profile(self, parameter_s=''):
"""Print your currently active IPython profile."""
- if self.shell.profile:
- printpl('Current IPython profile: $self.shell.profile.')
- else:
- print 'No profile active.'
+ print self.shell.profile
def magic_pinfo(self, parameter_s='', namespaces=None):
"""Provide detailed information about an object.
@@ -3373,22 +3371,16 @@ def magic_install_profiles(self, s):
else:
overwrite = False
from IPython.config import profile
- profile_dir = os.path.split(profile.__file__)[0]
+ profile_dir = os.path.dirname(profile.__file__)
ipython_dir = self.ipython_dir
- files = os.listdir(profile_dir)
-
- to_install = []
- for f in files:
- if f.startswith('ipython_config'):
- src = os.path.join(profile_dir, f)
- dst = os.path.join(ipython_dir, f)
- if (not os.path.isfile(dst)) or overwrite:
- to_install.append((f, src, dst))
- if len(to_install)>0:
- print "Installing profiles to: ", ipython_dir
- for (f, src, dst) in to_install:
- shutil.copy(src, dst)
- print " %s" % f
+ print "Installing profiles to: %s [overwrite=%s]"%(ipython_dir,overwrite)
+ for src in os.listdir(profile_dir):
+ if src.startswith('profile_'):
+ name = src.replace('profile_', '')
+ print " %s"%name
+ pd = ProfileDir.create_profile_dir_by_name(ipython_dir, name)
+ pd.copy_config_file('ipython_config.py', path=src,
+ overwrite=overwrite)
@skip_doctest
def magic_install_default_config(self, s):
@@ -3404,15 +3396,9 @@ def magic_install_default_config(self, s):
overwrite = True
else:
overwrite = False
- from IPython.config import default
- config_dir = os.path.split(default.__file__)[0]
- ipython_dir = self.ipython_dir
- default_config_file_name = 'ipython_config.py'
- src = os.path.join(config_dir, default_config_file_name)
- dst = os.path.join(ipython_dir, default_config_file_name)
- if (not os.path.isfile(dst)) or overwrite:
- shutil.copy(src, dst)
- print "Installing default config file: %s" % dst
+ pd = self.shell.profile_dir
+ print "Installing default config file in: %s" % pd.location
+ pd.copy_config_file('ipython_config.py', overwrite=overwrite)
# Pylab support: simple wrappers that activate pylab, load gui input
# handling and modify slightly %run
View
243 IPython/core/shellapp.py
@@ -0,0 +1,243 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+A mixin for :class:`~IPython.core.newapplication.Application` classes that
+launch InteractiveShell instances, load extensions, etc.
+
+Authors
+-------
+
+* Min Ragan-Kelley
+"""
+
+#-----------------------------------------------------------------------------
+# 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
+#-----------------------------------------------------------------------------
+
+from __future__ import absolute_import
+
+import os
+import sys
+
+from IPython.config.application import boolean_flag
+from IPython.config.configurable import Configurable
+from IPython.utils.path import filefind
+from IPython.utils.traitlets import Unicode, Instance, List
+
+#-----------------------------------------------------------------------------
+# Aliases and Flags
+#-----------------------------------------------------------------------------
+
+shell_flags = {}
+
+addflag = lambda *args: shell_flags.update(boolean_flag(*args))
+addflag('autoindent', 'InteractiveShell.autoindent',
+ 'Turn on autoindenting.', 'Turn off autoindenting.'
+)
+addflag('automagic', 'InteractiveShell.automagic',
+ """Turn on the auto calling of magic commands. Type %%magic at the
+ IPython prompt for more information.""",
+ 'Turn off the auto calling of magic commands.'
+)
+addflag('pdb', 'InteractiveShell.pdb',
+ "Enable auto calling the pdb debugger after every exception.",
+ "Disable auto calling the pdb debugger after every exception."
+)
+addflag('pprint', 'PlainTextFormatter.pprint',
+ "Enable auto pretty printing of results.",
+ "Disable auto auto pretty printing of results."
+)
+addflag('color-info', 'InteractiveShell.color_info',
+ """IPython can display information about objects via a set of func-
+ tions, and optionally can use colors for this, syntax highlighting
+ source code and various other elements. However, because this
+ information is passed through a pager (like 'less') and many pagers get
+ confused with color codes, this option is off by default. You can test
+ it and turn it on permanently in your ipython_config.py file if it
+ works for you. Test it and turn it on permanently if it works with
+ your system. The magic function %%color_info allows you to toggle this
+ inter- actively for testing.""",
+ "Disable using colors for info related things."
+)
+addflag('deep-reload', 'InteractiveShell.deep_reload',
+ """Enable deep (recursive) reloading by default. IPython can use the
+ deep_reload module which reloads changes in modules recursively (it
+ replaces the reload() function, so you don't need to change anything to
+ use it). deep_reload() forces a full reload of modules whose code may
+ have changed, which the default reload() function does not. When
+ deep_reload is off, IPython will use the normal reload(), but
+ deep_reload will still be available as dreload(). This feature is off
+ by default [which means that you have both normal reload() and
+ dreload()].""",
+ "Disable deep (recursive) reloading by default."
+)
+
+# it's possible we don't want short aliases for *all* of these:
+shell_aliases = dict(
+ autocall='InteractiveShell.autocall',
+ cache_size='InteractiveShell.cache_size',
+ colors='InteractiveShell.colors',
+ logfile='InteractiveShell.logfile',
+ log_append='InteractiveShell.logappend',
+ pi1='InteractiveShell.prompt_in1',
+ pi2='InteractiveShell.prompt_in1',
+ po='InteractiveShell.prompt_out',
+ si='InteractiveShell.separate_in',
+ so='InteractiveShell.separate_out',
+ so2='InteractiveShell.separate_out2',
+ xmode='InteractiveShell.xmode',
+ c='InteractiveShellApp.code_to_run',
+ ext='InteractiveShellApp.extra_extension',
+)
+
+#-----------------------------------------------------------------------------
+# Main classes and functions
+#-----------------------------------------------------------------------------
+
+class InteractiveShellApp(Configurable):
+ """A Mixin for applications that start InteractiveShell instances.
+
+ Provides configurables for loading extensions and executing files
+ as part of configuring a Shell environment.
+
+ Provides init_extensions() and init_code() methods, to be called
+ after init_shell(), which must be implemented by subclasses.
+ """
+ extensions = List(Unicode, config=True,
+ help="A list of dotted module names of IPython extensions to load."
+ )
+ extra_extension = Unicode('', config=True,
+ help="dotted module name of an IPython extension to load."
+ )
+ def _extra_extension_changed(self, name, old, new):
+ if new:
+ # add to self.extensions
+ self.extensions.append(new)
+
+ exec_files = List(Unicode, config=True,
+ help="""List of files to run at IPython startup."""
+ )
+ file_to_run = Unicode('', config=True,
+ help="""A file to be run""")
+
+ exec_lines = List(Unicode, config=True,
+ help="""lines of code to run at IPython startup."""
+ )
+ code_to_run = Unicode('', config=True,
+ help="Execute the given command string."
+ )
+ shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
+
+ def init_shell(self):
+ raise NotImplementedError("Override in subclasses")
+
+ def init_extensions(self):
+ """Load all IPython extensions in IPythonApp.extensions.
+
+ This uses the :meth:`ExtensionManager.load_extensions` to load all
+ the extensions listed in ``self.extensions``.
+ """
+ if not self.extensions:
+ return
+ try:
+ self.log.debug("Loading IPython extensions...")
+ extensions = self.extensions
+ for ext in extensions:
+ try:
+ self.log.info("Loading IPython extension: %s" % ext)
+ self.shell.extension_manager.load_extension(ext)
+ except:
+ self.log.warn("Error in loading extension: %s" % ext)
+ self.shell.showtraceback()
+ except:
+ self.log.warn("Unknown error in loading extensions:")
+ self.shell.showtraceback()
+
+ def init_code(self):
+ """run the pre-flight code, specified via exec_lines"""
+ self._run_exec_lines()
+ self._run_exec_files()
+ self._run_cmd_line_code()
+
+ def _run_exec_lines(self):
+ """Run lines of code in IPythonApp.exec_lines in the user's namespace."""
+ if not self.exec_lines:
+ return
+ try:
+ self.log.debug("Running code from IPythonApp.exec_lines...")
+ for line in self.exec_lines:
+ try:
+ self.log.info("Running code in user namespace: %s" %
+ line)
+ self.shell.run_cell(line, store_history=False)
+ except:
+ self.log.warn("Error in executing line in user "
+ "namespace: %s" % line)
+ self.shell.showtraceback()
+ except:
+ self.log.warn("Unknown error in handling IPythonApp.exec_lines:")
+ self.shell.showtraceback()
+
+ def _exec_file(self, fname):
+ full_filename = filefind(fname, [u'.', self.ipython_dir])
+ if os.path.isfile(full_filename):
+ if full_filename.endswith(u'.py'):
+ self.log.info("Running file in user namespace: %s" %
+ full_filename)
+ # Ensure that __file__ is always defined to match Python behavior
+ self.shell.user_ns['__file__'] = fname
+ try:
+ self.shell.safe_execfile(full_filename, self.shell.user_ns)
+ finally:
+ del self.shell.user_ns['__file__']
+ elif full_filename.endswith('.ipy'):
+ self.log.info("Running file in user namespace: %s" %
+ full_filename)
+ self.shell.safe_execfile_ipy(full_filename)
+ else:
+ self.log.warn("File does not have a .py or .ipy extension: <%s>"
+ % full_filename)
+
+ def _run_exec_files(self):
+ """Run files from IPythonApp.exec_files"""
+ if not self.exec_files:
+ return
+
+ self.log.debug("Running files in IPythonApp.exec_files...")
+ try:
+ for fname in self.exec_files:
+ self._exec_file(fname)
+ except:
+ self.log.warn("Unknown error in handling IPythonApp.exec_files:")
+ self.shell.showtraceback()
+
+ def _run_cmd_line_code(self):
+ """Run code or file specified at the command-line"""
+ if self.code_to_run:
+ line = self.code_to_run
+ try:
+ self.log.info("Running code given at command line (c=): %s" %
+ line)
+ self.shell.run_cell(line, store_history=False)
+ except:
+ self.log.warn("Error in executing line in user namespace: %s" %
+ line)
+ self.shell.showtraceback()
+
+ # Like Python itself, ignore the second if the first of these is present
+ elif self.file_to_run:
+ fname = self.file_to_run
+ try:
+ self._exec_file(fname)
+ except:
+ self.log.warn("Error in executing file in user namespace: %s" %
+ fname)
+ self.shell.showtraceback()
+
View
24 IPython/extensions/parallelmagic.py
@@ -92,7 +92,7 @@ def magic_px(self, ipself, parameter_s=''):
Then you can do the following::
In [24]: %px a = 5
- Parallel execution on engines: all
+ Parallel execution on engine(s): all
Out[24]:
<Results List>
[0] In [7]: a = 5
@@ -102,7 +102,7 @@ def magic_px(self, ipself, parameter_s=''):
if self.active_view is None:
print NO_ACTIVE_VIEW
return
- print "Parallel execution on engines: %s" % self.active_view.targets
+ print "Parallel execution on engine(s): %s" % self.active_view.targets
result = self.active_view.execute(parameter_s, block=False)
if self.active_view.block:
result.get()
@@ -125,9 +125,9 @@ def magic_autopx(self, ipself, parameter_s=''):
%autopx to enabled
In [26]: a = 10
- Parallel execution on engines: [0,1,2,3]
+ Parallel execution on engine(s): [0,1,2,3]
In [27]: print a
- Parallel execution on engines: [0,1,2,3]
+ Parallel execution on engine(s): [0,1,2,3]
[stdout:0] 10
[stdout:1] 10
[stdout:2] 10
@@ -174,15 +174,21 @@ def _maybe_display_output(self, result):
If self.active_view.block is True, wait for the result
and display the result. Otherwise, this is a noop.
"""
+ if isinstance(result.stdout, basestring):
+ # single result
+ stdouts = [result.stdout.rstrip()]
+ else:
+ stdouts = [s.rstrip() for s in result.stdout]
+
targets = self.active_view.targets
if isinstance(targets, int):
targets = [targets]
- if targets == 'all':
+ elif targets == 'all':
targets = self.active_view.client.ids
- stdout = [s.rstrip() for s in result.stdout]
- if any(stdout):
- for i,eid in enumerate(targets):
- print '[stdout:%i]'%eid, stdout[i]
+
+ if any(stdouts):
+ for eid,stdout in zip(targets, stdouts):
+ print '[stdout:%i]'%eid, stdout
def pxrun_cell(self, raw_cell, store_history=True):
View
8 IPython/frontend/qt/base_frontend_mixin.py
@@ -30,8 +30,8 @@ def _set_kernel_manager(self, kernel_manager):
# Disconnect the old kernel manager's channels.
old_manager.sub_channel.message_received.disconnect(self._dispatch)
- old_manager.xreq_channel.message_received.disconnect(self._dispatch)
- old_manager.rep_channel.message_received.disconnect(self._dispatch)
+ old_manager.shell_channel.message_received.disconnect(self._dispatch)
+ old_manager.stdin_channel.message_received.disconnect(self._dispatch)
old_manager.hb_channel.kernel_died.disconnect(
self._handle_kernel_died)
@@ -50,8 +50,8 @@ def _set_kernel_manager(self, kernel_manager):
# Connect the new kernel manager's channels.
kernel_manager.sub_channel.message_received.connect(self._dispatch)
- kernel_manager.xreq_channel.message_received.connect(self._dispatch)
- kernel_manager.rep_channel.message_received.connect(self._dispatch)
+ kernel_manager.shell_channel.message_received.connect(self._dispatch)
+ kernel_manager.stdin_channel.message_received.connect(self._dispatch)
kernel_manager.hb_channel.kernel_died.connect(self._handle_kernel_died)
# Handle the case where the kernel manager started channels before
View
96 IPython/frontend/qt/console/console_widget.py
@@ -19,7 +19,7 @@
from IPython.config.configurable import Configurable
from IPython.frontend.qt.rich_text import HtmlExporter
from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font
-from IPython.utils.traitlets import Bool, Enum, Int
+from IPython.utils.traitlets import Bool, Enum, Int, Unicode
from ansi_code_processor import QtAnsiCodeProcessor
from completion_widget import CompletionWidget
from kill_ring import QtKillRing
@@ -55,33 +55,61 @@ class ConsoleWidget(Configurable, QtGui.QWidget):
#------ Configuration ------------------------------------------------------
- # Whether to process ANSI escape codes.
- ansi_codes = Bool(True, config=True)
-
- # The maximum number of lines of text before truncation. Specifying a
- # non-positive number disables text truncation (not recommended).
- buffer_size = Int(500, config=True)
-
- # Whether to use a list widget or plain text output for tab completion.
- gui_completion = Bool(False, config=True)
-
- # The type of underlying text widget to use. Valid values are 'plain', which
- # specifies a QPlainTextEdit, and 'rich', which specifies a QTextEdit.
+ ansi_codes = Bool(True, config=True,
+ help="Whether to process ANSI escape codes."
+ )
+ buffer_size = Int(500, config=True,
+ help="""
+ The maximum number of lines of text before truncation. Specifying a
+ non-positive number disables text truncation (not recommended).