CMS 3D CMS Logo

MatrixToProcess.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
4 from __future__ import print_function
6 
7  def __init__(self,what='standard',strict=True):
8  from Configuration.PyReleaseValidation.MatrixReader import MatrixReader
9  self.mrd = MatrixReader(what,noRun=True)
10  self.mrd.prepare('all','',None)
12  self.processes={}
13  self.strict=strict
14  def getKey(self,wfNumber,step):
15  return str(wfNumber)+':'+str(step)
16 
17  def getProcess(self,wfNumber,step):
18  key=self.getKey(wfNumber,step)
19  if not key in self.configBuilders:
20  self.load(wfNumber,step)
21  if not key in self.configBuilders:
22  return None
23  return self.configBuilders[key].process
24 
25  def load(self,wfNumber,step):
26  from Configuration.Applications.ConfigBuilder import ConfigBuilder
27  from Configuration.Applications.cmsDriverOptions import OptionsFromCommand
28  import copy
29 
30  if len(self.configBuilders)!=0 and self.strict:
31  raise Exception('one should never be loading more than one process at a time due to python loading/altering feature')
32  key=self.getKey(wfNumber,step)
33  if key in self.configBuilders:
34  return True
35 
36  for wf in self.mrd.workFlows:
37  if float(wf.numId)!=wfNumber: continue
38 
39  if not hasattr(wf,'cmdStep%d'%(step)): continue
40  if not getattr(wf,'cmdStep%d'%(step)): continue
41 
42  command=getattr(wf,'cmdStep%d'%(step))
43  opt=OptionsFromCommand(command)
44  if opt:
45  cb = ConfigBuilder(opt,with_input=True,with_output=True)
46  cb.prepare()
47  self.configBuilders[key]=copy.copy(cb)
48  return True
49  print("could not satisfy the request for step",step,"of workflow",wfNumber)
50  return False
51 
52  def getConfig(self,wfNumber,step):
53  key=self.getKey(wfNumber,step)
54  if not key in self.configBuilders: self.getProcess(wfNumber,step)
55  if not key in self.configBuilders: return None
56  return self.configBuilders[key].pythonCfgCode
57 
58  def identityTest(self,wfNumber,step):
59  self.getProcess(wfNumber,step)
60  key=self.getKey(wfNumber,step)
61  if not key in self.configBuilders: return None
62 
63  cb=self.configBuilders[key]
64  #need to compare those two for identity
65  cb.process
66  cd.pythonCfgCode
67 
68 
69  def listAll(self):
70  for wf in self.mrd.workFlows:
71  step=1
72  print('---------------------')
73  print('process workflow',wf.numId)
74  print()
75  while self.load(float(wf.numId),step):
76  p=self.getProcess(float(wf.numId),step)
77  print(', '.join(s.label() for s in p.schedule))
78  #print p.outputModules()
79  step+=1
80 
MatrixReader
Definition: MatrixReader.py:1
MatrixToProcess.MatrixToProcess.mrd
mrd
Definition: MatrixToProcess.py:9
MatrixToProcess.MatrixToProcess.getProcess
def getProcess(self, wfNumber, step)
Definition: MatrixToProcess.py:17
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
MatrixToProcess.MatrixToProcess.strict
strict
Definition: MatrixToProcess.py:13
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
cmsDriverOptions
MatrixToProcess.MatrixToProcess.processes
processes
Definition: MatrixToProcess.py:12
ConfigBuilder
Definition: ConfigBuilder.py:1
MatrixToProcess.MatrixToProcess.getConfig
def getConfig(self, wfNumber, step)
Definition: MatrixToProcess.py:52
MatrixToProcess.MatrixToProcess.load
def load(self, wfNumber, step)
Definition: MatrixToProcess.py:25
str
#define str(s)
Definition: TestProcessor.cc:52
MatrixToProcess.MatrixToProcess.getKey
def getKey(self, wfNumber, step)
Definition: MatrixToProcess.py:14
MatrixToProcess.MatrixToProcess.identityTest
def identityTest(self, wfNumber, step)
Definition: MatrixToProcess.py:58
MatrixToProcess.MatrixToProcess.__init__
def __init__(self, what='standard', strict=True)
Definition: MatrixToProcess.py:7
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
MatrixToProcess.MatrixToProcess.listAll
def listAll(self)
Definition: MatrixToProcess.py:69
Exception
cmsDriverOptions.OptionsFromCommand
def OptionsFromCommand(command)
Definition: cmsDriverOptions.py:25
MatrixToProcess.MatrixToProcess
Definition: MatrixToProcess.py:5
MatrixToProcess.MatrixToProcess.configBuilders
configBuilders
Definition: MatrixToProcess.py:11