ATLAS Offline Software
Loading...
Searching...
No Matches
python.trfExeStepTools Namespace Reference

Functions

 commonExecutorStepName (name)
 loadSplitConfig (config)
 getTotalExecutorSteps (executor, argdict=None)
 getExecutorStepEventCounts (executor, argdict=None)

Variables

str executorStepSuffix = 'ExecutorStep'

Function Documentation

◆ commonExecutorStepName()

python.trfExeStepTools.commonExecutorStepName ( name)
Remove executor step suffix from executor name.

Definition at line 7 of file trfExeStepTools.py.

7def commonExecutorStepName(name):
8 """Remove executor step suffix from executor name."""
9 if executorStepSuffix in name:
10 name, _sep, _tail = name.rpartition(executorStepSuffix)
11 return name
12
13

◆ getExecutorStepEventCounts()

python.trfExeStepTools.getExecutorStepEventCounts ( executor,
argdict = None )
Get executor step event counts from executor config.

Definition at line 44 of file trfExeStepTools.py.

44def getExecutorStepEventCounts(executor, argdict=None):
45 """Get executor step event counts from executor config."""
46 if not argdict:
47 argdict = executor.conf.argdict
48 if 'splitConfig' not in argdict:
49 return []
50
51 maxEvents = argdict['maxEvents'].returnMyValue(exe=executor)
52 skipEvents = argdict['skipEvents'].returnMyValue(exe=executor)
53 splitConfig = argdict['splitConfig'].returnMyValue(exe=executor)
54 if not splitConfig:
55 return []
56
57 steps, fractions = loadSplitConfig(splitConfig)
58
59 if sum(fractions) != 1:
60 raise ValueError('Event fractions should total to 1!')
61
62 counts = []
63 for i in range(len(fractions) - 1):
64 counts.append(round(maxEvents * fractions[i]))
65 counts.append(maxEvents - sum(counts))
66
67 sums = []
68 for i in range(len(fractions)):
69 sums.append(skipEvents + sum(counts[:i]))
70
71 return counts, sums

◆ getTotalExecutorSteps()

python.trfExeStepTools.getTotalExecutorSteps ( executor,
argdict = None )
Get total executor steps from executor.

Definition at line 29 of file trfExeStepTools.py.

29def getTotalExecutorSteps(executor, argdict=None):
30 """Get total executor steps from executor."""
31 if not argdict:
32 argdict = executor.conf.argdict
33 if 'splitConfig' not in argdict:
34 return 0
35
36 splitConfig = argdict['splitConfig'].returnMyValue(exe=executor)
37 if not splitConfig:
38 return 0
39
40 steps, fractions = loadSplitConfig(splitConfig)
41 return steps
42
43

◆ loadSplitConfig()

python.trfExeStepTools.loadSplitConfig ( config)
Load splitting configuration from file.

Definition at line 14 of file trfExeStepTools.py.

14def loadSplitConfig(config):
15 """Load splitting configuration from file."""
16 parts = config.split('.')
17 if len(parts) < 2:
18 raise ValueError('Splitting config should be of the form Package.Module.Function or Package.Function if defined in __init__.py')
19
20 function = parts[-1]
21 module = '.'.join(parts[:-1])
22
23 from importlib import import_module
24 loaded_module = import_module(module)
25 function_def = getattr(loaded_module, function)
26 return function_def()
27
28

Variable Documentation

◆ executorStepSuffix

str python.trfExeStepTools.executorStepSuffix = 'ExecutorStep'

Definition at line 4 of file trfExeStepTools.py.