LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions | Variables
lsst.ctrl.pool.parallel Namespace Reference

Classes

class  Batch
 
class  PbsBatch
 
class  SlurmBatch
 
class  SmpBatch
 
class  BatchArgumentParser
 
class  BatchCmdLineTask
 
class  BatchPoolTask
 
class  BatchTaskRunner
 
class  BatchParallelTask
 

Functions

def shQuote (arg)
 
def shCommandFromArgs (args)
 
def processStats ()
 
def printProcessStats ()
 
def exportEnv ()
 

Variables

int UMASK = 0o002
 
dictionary BATCH_TYPES
 

Function Documentation

◆ exportEnv()

def lsst.ctrl.pool.parallel.exportEnv ( )
Generate bash script to regenerate the current environment

Definition at line 409 of file parallel.py.

409 def exportEnv():
410  """Generate bash script to regenerate the current environment"""
411  output = ""
412  for key, val in os.environ.items():
413  if key in ("DISPLAY",):
414  continue
415  if val.startswith("() {"):
416  # This is a function.
417  # "Two parentheses, a single space, and a brace"
418  # is exactly the same criterion as bash uses.
419 
420  # From 2014-09-25, the function name is prefixed by 'BASH_FUNC_'
421  # and suffixed by '()', which we have to remove.
422  if key.startswith("BASH_FUNC_") and key.endswith("()"):
423  key = key[10:-2]
424 
425  output += "{key} {val}\nexport -f {key}\n".format(key=key, val=val)
426  else:
427  # This is a variable.
428  output += "export {key}='{val}'\n".format(key=key, val=val.replace("'", "'\"'\"'"))
429  return output
430 
431 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ printProcessStats()

def lsst.ctrl.pool.parallel.printProcessStats ( )
Print the process statistics to the log

Definition at line 61 of file parallel.py.

61 def printProcessStats():
62  """Print the process statistics to the log"""
63  from lsst.log import Log
64  log = Log.getDefaultLogger()
65  log.info("Process stats for %s: %s" % (NODE, processStats()))
66 
67 
Definition: Log.h:717

◆ processStats()

def lsst.ctrl.pool.parallel.processStats ( )
Collect Linux-specific process statistics

Parses the /proc/self/status file (N.B. Linux-specific!) into a dict
which is returned.

Definition at line 47 of file parallel.py.

47 def processStats():
48  """Collect Linux-specific process statistics
49 
50  Parses the /proc/self/status file (N.B. Linux-specific!) into a dict
51  which is returned.
52  """
53  result = {}
54  with open("/proc/self/status") as f:
55  for line in f:
56  key, _, value = line.partition(":")
57  result[key] = value.strip()
58  return result
59 
60 

◆ shCommandFromArgs()

def lsst.ctrl.pool.parallel.shCommandFromArgs (   args)
Convert a list of shell arguments to a shell command-line

Definition at line 42 of file parallel.py.

42 def shCommandFromArgs(args):
43  """Convert a list of shell arguments to a shell command-line"""
44  return ' '.join([shQuote(a) for a in args])
45 
46 
def shCommandFromArgs(args)
Definition: parallel.py:42

◆ shQuote()

def lsst.ctrl.pool.parallel.shQuote (   arg)
Quote the argument for the shell.

>>> quote('\t')
'\\\t'
>>> quote('foo bar')
'foo\\ bar'

Definition at line 27 of file parallel.py.

27 def shQuote(arg):
28  r"""Quote the argument for the shell.
29 
30  >>> quote('\t')
31  '\\\t'
32  >>> quote('foo bar')
33  'foo\\ bar'
34  """
35  # This is the logic emacs uses
36  if arg:
37  return _quote_pos.sub('\\\\', arg).replace('\n', "'\n'")
38  else:
39  return "''"
40 
41 

Variable Documentation

◆ BATCH_TYPES

dictionary lsst.ctrl.pool.parallel.BATCH_TYPES
Initial value:
1 = {'none': None,
2  'None': None,
3  'pbs': PbsBatch,
4  'slurm': SlurmBatch,
5  'smp': SmpBatch,
6  }

Definition at line 290 of file parallel.py.

◆ UMASK

int lsst.ctrl.pool.parallel.UMASK = 0o002

Definition at line 20 of file parallel.py.