CMS 3D CMS Logo

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