Skip to content

Commit

Permalink
Merge branch 'newapp-parallel' into newapp
Browse files Browse the repository at this point in the history
closes #486
  • Loading branch information
minrk committed Jun 10, 2011
2 parents f243974 + e08aa54 commit c5d26d9
Show file tree
Hide file tree
Showing 35 changed files with 1,807 additions and 2,271 deletions.
43 changes: 22 additions & 21 deletions IPython/config/profile/default/ipcluster_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@
# - 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
# - MPIExecEngineSetLauncher
# - 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()


#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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'
Expand Down
25 changes: 13 additions & 12 deletions IPython/config/profile/default/ipcontroller_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 11 additions & 10 deletions IPython/config/profile/default/ipengine_config.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
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
# 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
# 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
Expand Down Expand Up @@ -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'



Expand Down
24 changes: 15 additions & 9 deletions IPython/extensions/parallelmagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Loading

0 comments on commit c5d26d9

Please sign in to comment.