Skip to content

Commit

Permalink
refactor DAG creation and submission. Fix dmwm#8892
Browse files Browse the repository at this point in the history
  • Loading branch information
belforte committed Jan 27, 2025
1 parent c54b1bd commit b4657d5
Show file tree
Hide file tree
Showing 6 changed files with 463 additions and 559 deletions.
41 changes: 6 additions & 35 deletions scripts/CMSRunAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,8 @@ def parseArgs():
parser = PassThroughOptionParser()
parser.add_option('--jobId', dest='jobId', type='string')
parser.add_option('--json', dest='jsonArgFile', type='string')
parser.add_option('-a', dest='archiveJob', type='string')
parser.add_option('-o', dest='outFiles', type='string')
parser.add_option('--inputFile', dest='inputFile', type='string')
parser.add_option('--sourceURL', dest='sourceURL', type='string')
parser.add_option('--userSandbox', dest='userSandbox', type='string')
parser.add_option('--inputFileList', dest='inputFileList', type='string')
parser.add_option('--jobNumber', dest='jobNumber', type='string')
parser.add_option('--cmsswVersion', dest='cmsswVersion', type='string')
parser.add_option('--scramArch', dest='scramArch', type='string')
Expand Down Expand Up @@ -334,19 +332,6 @@ def parseArgs():
for key, value in arguments.items():
setattr(opts, key, value)

# remap key in input_args.json to the argument names required by CMSRunAnalysis.py
# use as : value_of_argument_name = inputArgs[argMap[argument_name]]
# to ease transition to cleaner code the new key are only added if missing
argMap = {
'archiveJob': 'CRAB_Archive', 'outFiles': 'CRAB_AdditionalOutputFiles',
'sourceURL': 'CRAB_ISB', 'cmsswVersion': 'CRAB_JobSW',
'scramArch': 'CRAB_JobArch', 'runAndLumis': 'runAndLumiMask',
'inputFile' : 'inputFiles', 'lheInputFiles': 'lheInputFiles'
}
for key, value in argMap.items():
if not getattr(opts, key, None):
setattr(opts, key, arguments[value]) # assign to our variables

# allow for most input arguments to be passed via a (job specific) JSON file
if getattr(opts, 'jsonArgFile', None):
arguments = {}
Expand All @@ -366,13 +351,11 @@ def parseArgs():

try:
print(f"==== Parameters Dump at {UTCNow()} ===")
print("archiveJob: ", opts.archiveJob)
print("sourceURL: ", opts.sourceURL)
print("userSandbox: ", opts.userSandbox)
print("jobNumber: ", opts.jobNumber)
print("cmsswVersion: ", opts.cmsswVersion)
print("scramArch: ", opts.scramArch)
print("inputFile ", opts.inputFile)
print("outFiles: ", opts.outFiles)
print("inputFileList ", opts.inputFileList)
print("runAndLumis: ", opts.runAndLumis)
print("lheInputFiles: ", opts.lheInputFiles)
print("firstEvent: ", opts.firstEvent)
Expand Down Expand Up @@ -697,7 +680,7 @@ def compareBrachListWithReference(branchList, tier):
print(f"==== SCRAM Obj INITIALIZED at {UTCNow()} ====")

print("==== Extract user sandbox in top and CMSSW directory ====")
extractUserSandbox(options.archiveJob)
extractUserSandbox(options.userSandbox)

#Multi-microarch env: Setting cmssw env after extracting the sandbox
print(f"==== SCRAM runtime environment CREATED at {UTCNow()} ====")
Expand Down Expand Up @@ -901,19 +884,7 @@ def compareBrachListWithReference(branchList, tier):
mintime()
sys.exit(EC_ReportHandlingErr)

# rename output files. Doing this after checksums otherwise outfile is not found.
if jobExitCode == 0:
try:
oldName = 'UNKNOWN'
newName = 'UNKNOWN'
for oldName, newName in literal_eval(options.outFiles).items():
os.rename(oldName, newName)
except Exception as ex: # pylint: disable=broad-except
handleException("FAILED", EC_MoveOutErr, f"Exception while renaming file {oldName} to {newName}.")
mintime()
sys.exit(EC_MoveOutErr)
else:
mintime()
mintime()

print(f"==== CMSRunAnalysis.py FINISHED at {UTCNow()} ====")
print(f"Local time : {time.ctime()}")
Expand Down
4 changes: 2 additions & 2 deletions scripts/TweakPSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def createScriptLines(opts, pklIn):
if opts.runAndLumis:
runAndLumis = readFileFromTarball(opts.runAndLumis, 'run_and_lumis.tar.gz')
inputFiles = {}
if opts.inputFile:
inputFiles = readFileFromTarball(opts.inputFile, 'input_files.tar.gz')
if opts.inputFileList:
inputFiles = readFileFromTarball(opts.inputFileList, 'input_files.tar.gz')

# build a tweak object with the needed changes to be applied to PSet
tweak = PSetTweak()
Expand Down
Loading

0 comments on commit b4657d5

Please sign in to comment.