Skip to content

Commit 2e3c187

Browse files
committed
Check for inputs and recycling inputs
1 parent 5530fdb commit 2e3c187

File tree

6 files changed

+86
-21
lines changed

6 files changed

+86
-21
lines changed

Configuration/PyReleaseValidation/python/MatrixReader.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from Configuration.PyReleaseValidation.WorkFlow import WorkFlow
44
from Configuration.PyReleaseValidation.MatrixUtil import InputInfo
5-
5+
from Configuration.PyReleaseValidation.upgradeWorkflowComponents import defaultDataSets,undefInput
66
# ================================================================================
77

88
class MatrixException(Exception):
@@ -25,8 +25,9 @@ def __init__(self, opt):
2525
self.apply=opt.apply
2626
self.commandLineWf=opt.workflow
2727
self.overWrite=opt.overWrite
28-
28+
2929
self.noRun = opt.noRun
30+
self.checkInputs = opt.checkInputs
3031
return
3132

3233
def reset(self, what='all'):
@@ -127,6 +128,21 @@ def makeStep(self,step,overrides):
127128
else:
128129
return step
129130

131+
def verifyDefaultInputs(self):
132+
for wf in self.workFlowSteps.values():
133+
undefs = [driver for driver in wf[2] if isinstance(driver,str) and undefInput in driver ]
134+
if len(undefs)>0:
135+
raise ValueError("""in MatrixReader.py:{0}
136+
=============================================================================
137+
For wf {1}(*) the default dataset not defined in defaultDataSets dictionary.
138+
With --checkInputs option this throws an error.
139+
140+
(*)
141+
{2}
142+
143+
=============================================================================
144+
""".format(sys._getframe(1).f_lineno - 1,wf[0],wf))
145+
130146
def readMatrix(self, fileNameIn, useInput=None, refRel=None, fromScratch=None):
131147

132148
prefix = self.filesPrefMap[fileNameIn]
@@ -332,6 +348,8 @@ def showRaw(self, useInput, refRel=None, fromScratch=None, what='all',step1Only=
332348

333349
try:
334350
self.readMatrix(matrixFile, useInput, refRel, fromScratch)
351+
if self.checkInputs:
352+
self.verifyDefaultInputs()
335353
except Exception as e:
336354
print("ERROR reading file:", matrixFile, str(e))
337355
raise
@@ -507,6 +525,8 @@ def prepare(self, useInput=None, refRel='', fromScratch=None):
507525

508526
try:
509527
self.readMatrix(matrixFile, useInput, refRel, fromScratch)
528+
if self.checkInputs:
529+
self.verifyDefaultInputs()
510530
except Exception as e:
511531
print("ERROR reading file:", matrixFile, str(e))
512532
raise

Configuration/PyReleaseValidation/python/MatrixRunner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def runTests(self, opt):
5858

5959
print('\nPreparing to run %s %s' % (wf.numId, item))
6060
sys.stdout.flush()
61-
current = WorkFlowRunner(wf,noRun,dryRun,cafVeto, opt.dasOptions, opt.jobReports, opt.nThreads, opt.nStreams, opt.maxSteps, opt.nEvents)
61+
current = WorkFlowRunner(wf,opt,noRun,dryRun,cafVeto)
6262
self.threadList.append(current)
6363
current.start()
6464
if not dryRun:

Configuration/PyReleaseValidation/python/WorkFlowRunner.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,26 @@
77
from datetime import datetime
88

99
class WorkFlowRunner(Thread):
10-
def __init__(self, wf, noRun=False,dryRun=False,cafVeto=True,dasOptions="",jobReport=False, nThreads=1, nStreams=0, maxSteps=9999, nEvents=0):
10+
def __init__(self, wf, opt, noRun=False, dryRun=False, cafVeto=True):
1111
Thread.__init__(self)
1212
self.wf = wf
1313

14-
self.status=-1
15-
self.report=''
16-
self.nfail=0
17-
self.npass=0
18-
self.noRun=noRun
19-
self.dryRun=dryRun
20-
self.cafVeto=cafVeto
21-
self.dasOptions=dasOptions
22-
self.jobReport=jobReport
23-
self.nThreads=nThreads
24-
self.nStreams=nStreams
25-
self.maxSteps=maxSteps
26-
self.nEvents=nEvents
27-
self.recoOutput=''
14+
self.status = -1
15+
self.report =''
16+
self.nfail = 0
17+
self.npass = 0
18+
self.noRun = noRun
19+
self.dryRun = dryRun
20+
self.cafVeto = cafVeto
21+
self.dasOptions = opt.dasOptions
22+
self.jobReport = opt.jobReports
23+
self.nThreads = opt.nThreads
24+
self.nStreams = opt.nStreams
25+
self.maxSteps = opt.maxSteps
26+
self.nEvents = opt.nEvents
27+
self.recoOutput = ''
28+
self.startFrom = opt.startFrom
29+
self.recycle = opt.recycle
2830

2931
self.wfDir=str(self.wf.numId)+'_'+self.wf.nameId
3032
return
@@ -98,6 +100,9 @@ def closeCmd(i,ID):
98100
self.stat.append('NOTRUN')
99101
continue
100102
if not isinstance(com,str):
103+
if self.recycle:
104+
inFile = self.recycle
105+
continue
101106
if self.cafVeto and (com.location == 'CAF' and not onCAF):
102107
print("You need to be no CAF to run",self.wf.numId)
103108
self.npass.append(0)
@@ -147,6 +152,15 @@ def closeCmd(i,ID):
147152
else:
148153
#chaining IO , which should be done in WF object already and not using stepX.root but <stepName>.root
149154
cmd += com
155+
156+
if self.startFrom:
157+
steps = cmd.split("-s ")[1].split(" ")[0]
158+
if self.startFrom not in steps:
159+
continue
160+
else:
161+
self.startFrom = False
162+
inFile = self.recycle
163+
150164
if self.noRun:
151165
cmd +=' --no_exec'
152166
# in case previous step used DAS query (either filelist of das:)
@@ -191,6 +205,7 @@ def closeCmd(i,ID):
191205
cmd = split[0] + event_token + '%s ' % self.nEvents + pos_cmd
192206
cmd+=closeCmd(istep,self.wf.nameId)
193207
retStep = 0
208+
194209
if istep>self.maxSteps:
195210
wf_stats = open("%s/wf_steps.txt" % self.wfDir,"a")
196211
wf_stats.write('step%s:%s\n' % (istep, cmd))

Configuration/PyReleaseValidation/python/relval_steps.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import sys
2+
13
from .MatrixUtil import *
24

35
from Configuration.HLT.autoHLT import autoHLT
46
from Configuration.AlCa.autoPCL import autoPCL
57
from Configuration.Skimming.autoSkim import autoSkim
6-
from .upgradeWorkflowComponents import step3_trackingOnly
8+
from Configuration.PyReleaseValidation.upgradeWorkflowComponents import step3_trackingOnly,undefInput
79

810
# step1 gensim: for run1
911
step1Defaults = {'--relval' : None, # need to be explicitly set
@@ -4595,13 +4597,17 @@ def gen2024HiMix(fragment,howMuch):
45954597
for gen in upgradeFragments:
45964598
for ds in defaultDataSets:
45974599
key=gen[:-4]+'_'+ds
4598-
version='1'
4600+
version = "1"
4601+
if defaultDataSets[ds] == '' or ds =='Run4D98':
4602+
version = undefInput
45994603
if key in versionOverrides:
46004604
version = versionOverrides[key]
46014605
baseDataSetReleaseBetter[key]=defaultDataSets[ds]+version
46024606

46034607
PUDataSets={}
46044608
for ds in defaultDataSets:
4609+
if "GenOnly" in ds:
4610+
continue
46054611
key='MinBias_14TeV_pythia8_TuneCP5'+'_'+ds
46064612
name=baseDataSetReleaseBetter[key]
46074613
if '2017' in ds:
@@ -4621,7 +4627,6 @@ def gen2024HiMix(fragment,howMuch):
46214627
#PUDataSets[ds]={'-n':10,'--pileup':'AVE_50_BX_25ns','--pileup_input':'das:/RelValMinBias_13/%s/GEN-SIM'%(name,)}
46224628
#PUDataSets[ds]={'-n':10,'--pileup':'AVE_70_BX_25ns','--pileup_input':'das:/RelValMinBias_13/%s/GEN-SIM'%(name,)}
46234629

4624-
46254630
upgradeStepDict={}
46264631
for specialType,specialWF in upgradeWFs.items():
46274632
specialWF.init(upgradeStepDict)

Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from .MatrixUtil import merge, Kby, Mby, check_dups
44
import re
55

6+
undefInput = "UNDEF"
7+
68
U2000by1={'--relval': '2000,1'}
79

810
# DON'T CHANGE THE ORDER, only append new keys. Otherwise the numbering for the runTheMatrix tests will change.
@@ -3120,6 +3122,8 @@ def condition(self, fragment, stepList, key, hasHarvest):
31203122

31213123
# standard PU sequences
31223124
for key in list(upgradeProperties[2017].keys()):
3125+
if "GenOnly" in key:
3126+
continue
31233127
upgradeProperties[2017][key+'PU'] = deepcopy(upgradeProperties[2017][key])
31243128
if 'FS' not in key:
31253129
# update ScenToRun list
@@ -3355,6 +3359,8 @@ def condition(self, fragment, stepList, key, hasHarvest):
33553359

33563360
# standard PU sequences
33573361
for key in list(upgradeProperties['Run4'].keys()):
3362+
if "GenOnly" in key:
3363+
continue
33583364
upgradeProperties['Run4'][key+'PU'] = deepcopy(upgradeProperties['Run4'][key])
33593365
upgradeProperties['Run4'][key+'PU']['ScenToRun'] = ['GenSimHLBeamSpot','DigiTriggerPU','RecoGlobalPU', 'HARVESTGlobalPU']
33603366

Configuration/PyReleaseValidation/scripts/runTheMatrix.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,20 @@ def runSelected(opt):
173173
dest='memoryOffset',
174174
type=int,
175175
default=3000)
176+
177+
parser.add_argument('--startFrom',
178+
help='Start from a specific step (e.g. GEN,SIM,DIGI,RECO)',
179+
dest='startFrom',
180+
type=str,
181+
default=None)
176182

183+
parser.add_argument('--recycle',
184+
help='Input file to recycle. To be used if the first step is an input step or togehter with --startFrom. '
185+
'N.B.: runTheMatrix.py will create its own workdirectory so if yo use a relative path, be careful.',
186+
dest='recycle',
187+
type=str,
188+
default=None)
189+
177190
parser.add_argument('--addMemPerCore',
178191
help='increase of memory per each n > 1 core: memory(n_core) = memoryOffset + (n_core-1) * memPerCore',
179192
dest='memPerCore',
@@ -216,6 +229,12 @@ def runSelected(opt):
216229
default=False,
217230
action='store_true')
218231

232+
parser.add_argument('-c','--checkInputs',
233+
help='Check if the default inputs are well defined. To be used with --show',
234+
dest='checkInputs',
235+
default=False,
236+
action='store_true')
237+
219238
parser.add_argument('-e','--extended',
220239
help='Show details of workflows, used with --show',
221240
dest='extended',

0 commit comments

Comments
 (0)