From 384322eb31e19561f767d5b6f1ce84b2c5c985ca Mon Sep 17 00:00:00 2001 From: Lars Rickard Stroem Date: Mon, 5 Oct 2020 21:31:49 +0200 Subject: [PATCH 1/4] Adding support for pathresolver in top-xaod to allow unpacking of configuration files on the grid, corresponding modifications to grid.py to avoid crashes during submit --- .../xAOD/TopAnalysis/util/top-xaod.cxx | 15 ++++++--- .../TopPhys/xAOD/TopExamples/python/grid.py | 33 +++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx index 412c99619b2..ce6a218776c 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx @@ -108,12 +108,17 @@ int main(int argc, char** argv) { StatusCode::enableFailure(); xAOD::TStore store; - - std::string settingsFilename = std::string(argv[1]); + + ATH_MSG_INFO("INPUT: Configuration file (argv[1]) = " + << argv[1] << "\n"); + std::string settingsFilename = PathResolverFindCalibFile(argv[1]); + ATH_MSG_INFO("LOCATED (using PathResolver): Configuration file = " + << settingsFilename << "\n"); + ATH_MSG_INFO("Configuration Files:\n" - << settingsFilename << "\n" - << std::string(argv[2]) << "\n"); - + << settingsFilename << "\n" + << argv[2] << "\n"); + //load the settings from the input file auto* const settings = top::ConfigurationSettings::get(); settings->loadFromFile(settingsFilename); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py b/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py index bdc2967f435..29bad60187d 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py +++ b/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py @@ -104,7 +104,7 @@ class Config: txt = '(' iconfigFile=0 for configFile in self.settingsFile.split(','): - cutsFileIsARealFile = checkForFile(configFile) + cutsFileIsARealFile = checkForFile(ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch)) if cutsFileIsARealFile: txt += 'exists' else: @@ -217,18 +217,19 @@ def submit(config, allSamples): #Check for cuts file for configFile in config.settingsFile.split(','): - if not checkForFile(configFile): - print logger.FAIL + " Error - %s does not exist in this directory "%(configFile) + logger.ENDC + settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + + if not checkForFile(settingsFilePath): + print logger.FAIL + " Error - %s does not exist in this directory "%(settingsFilePath) + logger.ENDC print logger.WARNING + " - Attempt to find this file in a sensible location... " + logger.ENDC - settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) if settingsFilePath == "": print logger.FAIL + "DANGER DANGER. HIGH VOLTAGE" + logger.ENDC - print '%s does not exist in this directory and cannot be found' % configFile + print '%s does not exist in this directory and cannot be found' % settingsFilePath print 'Please make it before submitting' sys.exit(1) else: print logger.WARNING + " - Found an appropriate file " + logger.ENDC - print logger.WARNING + " - Will copy " + logger.ENDC + configFile + logger.WARNING + " from " + logger.ENDC + settingsFilePath + print logger.WARNING + " - Will copy " + logger.ENDC + settingsFilePath + logger.WARNING + " from " + logger.ENDC + settingsFilePath print logger.WARNING + " - Confirm this is okay before continuing " + logger.ENDC user_check = raw_input(logger.OKBLUE + "Type yes/y/Y in order to proceed ...: " + logger.ENDC) if(user_check != "yes" and user_check != "y" and user_check != "Y"): @@ -239,9 +240,11 @@ def submit(config, allSamples): outputFiles = [] for configFile in config.settingsFile.split(','): + settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + #Look in the cuts file for the output filename outputFilename = 'EMPTY' - for l in open(configFile): + for l in open(settingsFilePath, "r"): #ignore text after comments if l.find('#') > -1: l = l.split('#')[0] @@ -249,7 +252,7 @@ def submit(config, allSamples): if l.find('OutputFilename') > -1: outputFilename = l.replace('OutputFilename', '').strip() if outputFilename == 'EMPTY': - print logger.FAIL + 'OutputFilename not found in ' + configFile + logger.ENDC + print logger.FAIL + 'OutputFilename not found in ' + settingsFilePath + logger.ENDC sys.exit(1) else: outputFiles.append(outputFilename) @@ -448,9 +451,10 @@ if __name__ == '__main__': def checkForShowerAlgorithm(Samples, cutfile): + settingsFilePath = ROOT.PathResolver.find_file(cutfile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) noShowerDatasets = [] customTDPFile = None - tmp = open(cutfile, "r") + tmp = open(settingsFilePath, "r") for line in tmp.readlines(): if "TDPPath" not in line: continue @@ -481,7 +485,7 @@ def checkForShowerAlgorithm(Samples, cutfile): noShowerDatasets += [dsid] if len(noShowerDatasets) > 0: - print 'TopDataPreparation .data file specified in '+cutfile+' was checked.' + print 'TopDataPreparation .data file specified in '+settingsFilePath+' was checked.' print 'The following datasets do not have a showering algorithm defined in TopDataPreparation and will fail on the grid. Please ask for this to be fixed in TopDataPreparation!' for ds in set(noShowerDatasets): print ds @@ -509,8 +513,9 @@ def checkPRWFile(Samples, cutfile): # We need to find the PRW files being used and make use of the checkPRW # checkPRW.py --inDsTxt=my.datasets.txt path/to/prwConfigs/*.root # First, find the PRW names from cutfile - print logger.OKBLUE + " - Processing checks for PRWConfig in " + cutfile + logger.ENDC - tmp = open(cutfile, "r") + settingsFilePath = ROOT.PathResolver.find_file(cutfile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + print logger.OKBLUE + " - Processing checks for PRWConfig in " + settingsFilePath + logger.ENDC + tmp = open(settingsFilePath, "r") PRWConfig = None PRWConfig_FS = None PRWConfig_AF = None @@ -530,10 +535,10 @@ def checkPRWFile(Samples, cutfile): PRWConfig.extend( [ ROOT.PathResolver.find_file( x, "PATH", ROOT.PathResolver.RecursiveSearch ) for x in line.split()[1:] ] ) if PRWConfig and PRWConfig_AF: - print logger.FAIL + " - Problem in cutfile " + cutfile + ": PRWConfigFiles is inconsistent with usage of PRWConfigFiles_AF" + logger.ENDC + print logger.FAIL + " - Problem in cutfile " + settingsFilePath + ": PRWConfigFiles is inconsistent with usage of PRWConfigFiles_AF" + logger.ENDC return elif PRWConfig and PRWConfig_FS: - print logger.FAIL + " - Problem in cutfile " + cutfile + ": PRWConfigFiles is inconsistent with usage of PRWConfigFiles_FS" + logger.ENDC + print logger.FAIL + " - Problem in cutfile " + settingsFilePath + ": PRWConfigFiles is inconsistent with usage of PRWConfigFiles_FS" + logger.ENDC return elif PRWConfig and not PRWConfig_FS and not PRWConfig_AF: PRWConfig_FS = PRWConfig -- GitLab From 0ad0d945af8834002b332710d333311839ffbe31 Mon Sep 17 00:00:00 2001 From: Lars Rickard Strom Date: Tue, 6 Oct 2020 19:16:34 +0200 Subject: [PATCH 2/4] Updating grid submission helper to be compatible with PathResolver fix --- .../TopPhys/xAOD/TopExamples/python/grid.py | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py b/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py index 29bad60187d..5c09fb8042e 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py +++ b/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py @@ -217,26 +217,16 @@ def submit(config, allSamples): #Check for cuts file for configFile in config.settingsFile.split(','): - settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) - - if not checkForFile(settingsFilePath): - print logger.FAIL + " Error - %s does not exist in this directory "%(settingsFilePath) + logger.ENDC - print logger.WARNING + " - Attempt to find this file in a sensible location... " + logger.ENDC + if not checkForFile(configFile): + print logger.WARNING + " WARNING - Did not find config file %s in this dir "%(configFile) + logger.ENDC + print logger.WARNING + " - Attempt to find this file in a sensible location using PathResolver... " + logger.ENDC + settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) if settingsFilePath == "": - print logger.FAIL + "DANGER DANGER. HIGH VOLTAGE" + logger.ENDC - print '%s does not exist in this directory and cannot be found' % settingsFilePath - print 'Please make it before submitting' - sys.exit(1) + print logger.FAIL + "DANGER DANGER. HIGH VOLTAGE" + logger.ENDC + print '%s does not exist in this directory and cannot be found using PathResolver, exiting!' % configFile + sys.exit(1) else: - print logger.WARNING + " - Found an appropriate file " + logger.ENDC - print logger.WARNING + " - Will copy " + logger.ENDC + settingsFilePath + logger.WARNING + " from " + logger.ENDC + settingsFilePath - print logger.WARNING + " - Confirm this is okay before continuing " + logger.ENDC - user_check = raw_input(logger.OKBLUE + "Type yes/y/Y in order to proceed ...: " + logger.ENDC) - if(user_check != "yes" and user_check != "y" and user_check != "Y"): - print logger.FAIL + " Exiting submission " + logger.ENDC - sys.exit(2) - print logger.OKGREEN + " - Confirmed " + logger.ENDC - os.system("cp %s %s"%(settingsFilePath,"./")) + print logger.WARNING + " - Found an appropriate file %s "%(settingsFilePath) + logger.ENDC outputFiles = [] for configFile in config.settingsFile.split(','): @@ -248,7 +238,6 @@ def submit(config, allSamples): #ignore text after comments if l.find('#') > -1: l = l.split('#')[0] - if l.find('OutputFilename') > -1: outputFilename = l.replace('OutputFilename', '').strip() if outputFilename == 'EMPTY': -- GitLab From ecfdeedc71b9ca03671d825466dcaba09e487a7a Mon Sep 17 00:00:00 2001 From: Lars Rickard Strom Date: Mon, 12 Oct 2020 21:58:52 +0200 Subject: [PATCH 3/4] Switching from PathResolverFindCalibFile to PathResolver::find_file in top-xaod executable --- PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx index ce6a218776c..ba4df049995 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx @@ -111,8 +111,9 @@ int main(int argc, char** argv) { ATH_MSG_INFO("INPUT: Configuration file (argv[1]) = " << argv[1] << "\n"); - std::string settingsFilename = PathResolverFindCalibFile(argv[1]); - ATH_MSG_INFO("LOCATED (using PathResolver): Configuration file = " + std::string settingsFilename = PathResolver::find_file(argv[1],"DATAPATH"); + + ATH_MSG_INFO("LOCATED (using PathResolverFindFile ): Configuration file = " << settingsFilename << "\n"); ATH_MSG_INFO("Configuration Files:\n" -- GitLab From ce808057271002d9a775a4ee56d3106590ae5d6b Mon Sep 17 00:00:00 2001 From: Lars Rickard Strom Date: Tue, 13 Oct 2020 14:30:34 +0200 Subject: [PATCH 4/4] Implementing LocalSearch instead of RecursiveSearch for config file in grid.py and explicitly writing local for top-xaod executable --- .../TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx | 2 +- .../TopPhys/xAOD/TopExamples/python/grid.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx index ba4df049995..a8811ebb771 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx @@ -111,7 +111,7 @@ int main(int argc, char** argv) { ATH_MSG_INFO("INPUT: Configuration file (argv[1]) = " << argv[1] << "\n"); - std::string settingsFilename = PathResolver::find_file(argv[1],"DATAPATH"); + std::string settingsFilename = PathResolver::find_file(argv[1],"DATAPATH",PathResolver::LocalSearch); ATH_MSG_INFO("LOCATED (using PathResolverFindFile ): Configuration file = " << settingsFilename << "\n"); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py b/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py index 5c09fb8042e..b8c4eef5586 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py +++ b/PhysicsAnalysis/TopPhys/xAOD/TopExamples/python/grid.py @@ -104,7 +104,7 @@ class Config: txt = '(' iconfigFile=0 for configFile in self.settingsFile.split(','): - cutsFileIsARealFile = checkForFile(ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch)) + cutsFileIsARealFile = checkForFile(ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.LocalSearch)) if cutsFileIsARealFile: txt += 'exists' else: @@ -220,7 +220,7 @@ def submit(config, allSamples): if not checkForFile(configFile): print logger.WARNING + " WARNING - Did not find config file %s in this dir "%(configFile) + logger.ENDC print logger.WARNING + " - Attempt to find this file in a sensible location using PathResolver... " + logger.ENDC - settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.LocalSearch) if settingsFilePath == "": print logger.FAIL + "DANGER DANGER. HIGH VOLTAGE" + logger.ENDC print '%s does not exist in this directory and cannot be found using PathResolver, exiting!' % configFile @@ -230,7 +230,7 @@ def submit(config, allSamples): outputFiles = [] for configFile in config.settingsFile.split(','): - settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + settingsFilePath = ROOT.PathResolver.find_file(configFile, "DATAPATH", ROOT.PathResolver.LocalSearch) #Look in the cuts file for the output filename outputFilename = 'EMPTY' @@ -440,7 +440,7 @@ if __name__ == '__main__': def checkForShowerAlgorithm(Samples, cutfile): - settingsFilePath = ROOT.PathResolver.find_file(cutfile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + settingsFilePath = ROOT.PathResolver.find_file(cutfile, "DATAPATH", ROOT.PathResolver.LocalSearch) noShowerDatasets = [] customTDPFile = None tmp = open(settingsFilePath, "r") @@ -502,7 +502,7 @@ def checkPRWFile(Samples, cutfile): # We need to find the PRW files being used and make use of the checkPRW # checkPRW.py --inDsTxt=my.datasets.txt path/to/prwConfigs/*.root # First, find the PRW names from cutfile - settingsFilePath = ROOT.PathResolver.find_file(cutfile, "DATAPATH", ROOT.PathResolver.RecursiveSearch) + settingsFilePath = ROOT.PathResolver.find_file(cutfile, "DATAPATH", ROOT.PathResolver.LocalSearch) print logger.OKBLUE + " - Processing checks for PRWConfig in " + settingsFilePath + logger.ENDC tmp = open(settingsFilePath, "r") PRWConfig = None -- GitLab