LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions | Variables
lsst.ctrl.pool.parallel Namespace Reference

Classes

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

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.

409def 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.

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.

47def 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.

42def 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.

27def 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.