From bc5fdd93c8ed22d2fb3c4ac9fe63126f52cda0ab Mon Sep 17 00:00:00 2001 From: ctolon Date: Fri, 16 Dec 2022 16:16:02 +0300 Subject: [PATCH] create backup for actual interface strategy to another branch before refactoring --- doc/1_ScriptsAndConfigs.md | 2 +- extramodules/configSetter.py | 41 +++++++++- extramodules/dqLibGetter.py | 79 +++++++------------ .../{stringOperations.py => utils.py} | 31 +++++++- runDQEfficiency.py | 9 +-- runDQFlow.py | 8 +- runDalitzSelection.py | 8 +- runEMEfficiency.py | 9 +-- runEMEfficiencyNotSkimmed.py | 9 +-- runFilterPP.py | 5 +- runTableMaker.py | 18 ++--- runTableMakerMC.py | 10 +-- runTableReader.py | 5 +- runV0selector.py | 9 +-- 14 files changed, 129 insertions(+), 114 deletions(-) rename extramodules/{stringOperations.py => utils.py} (69%) diff --git a/doc/1_ScriptsAndConfigs.md b/doc/1_ScriptsAndConfigs.md index d70e7ab..64f8d77 100644 --- a/doc/1_ScriptsAndConfigs.md +++ b/doc/1_ScriptsAndConfigs.md @@ -159,6 +159,6 @@ Extra Script | Desc `dqTranscations.py` | To manage dependencies and misconfigurations in the DQ workflow `helperOptions.py` | Includes Interface arguments for debug and interface mode options `pycacheRemover.py` | For automatically removing pycache files when workflow is finished -`stringOperations.py` | For managing string operations of multiple arguments in workflows +`utils.py` | For managing some basic cases as wrapper [↑ Go to the Table of Content ↑](../README.md) | [Continue to Prerequisites →](2_Prerequisites.md) \ No newline at end of file diff --git a/extramodules/configSetter.py b/extramodules/configSetter.py index 1e3d8c6..932af01 100644 --- a/extramodules/configSetter.py +++ b/extramodules/configSetter.py @@ -15,7 +15,7 @@ # This script includes setter functions for configurables (Developer package) -from .stringOperations import listToString, stringToListWithSlash +from .utils import listToString, stringToListWithSlash import logging from logging import handlers import sys @@ -163,13 +163,12 @@ def generateDescriptors(tablesToProduce: dict, tables: dict, writerConfigFileNam print(writerConfig) -def tableProducer(config: dict, taskNameInConfig: str, tablesToProduce: dict, commonTables: list, barrelCommonTables: list, muonCommonTables: list, specificTables: list, specificDeps: dict, runOverMC: bool) -> None: +def tableProducer(config: dict, taskNameInConfig: str, commonTables: list, barrelCommonTables: list, muonCommonTables: list, specificTables: list, specificDeps: dict, runOverMC: bool) -> dict: """Table producer function for tableMaker/tableMakerMC Args: config (dict): Input as JSON config file taskNameInConfig (str): Taskname in config file (table-maker/table-maker-m-c) - tablesToProduce (dict): Input as which tables are needed commonTables (list): Common tables which are always be created barrelCommonTables (list): Barrel tables in reduced DQ data model muonCommonTables (list): Muon tables in reduced DQ data model @@ -178,6 +177,8 @@ def tableProducer(config: dict, taskNameInConfig: str, tablesToProduce: dict, co runOverMC (bool): Checking to run over MC or Data """ + tablesToProduce = {} + for table in commonTables: tablesToProduce[table] = 1 @@ -211,6 +212,7 @@ def tableProducer(config: dict, taskNameInConfig: str, tablesToProduce: dict, co for table in specificTables[processFunc]: logging.info("%s", table) tablesToProduce[table] = 1 + return tablesToProduce def setSelection(config: dict, deps: dict, targetCfg: list, cliMode: bool) -> None: @@ -451,3 +453,36 @@ def setParallelismOnSkimming(commandToRun: str, taskNameInCommandLine: str, upda #NOTE: Aod writer json config arg currently not working with parallelism #return (analysisTaskName + " --configuration json://" + updatedConfigFileName + " --aod-writer-json aodWriterTempConfig.json " + " -b " + '| ' + skimmingTaskFullCommand) return (analysisTaskName + " --configuration json://" + updatedConfigFileName + " -b " + '| ' + skimmingTaskFullCommand) + + +def commonDepsToRun(commonDeps): + # Check which dependencies need to be run + depsToRun = {} + for dep in commonDeps: + depsToRun[dep] = 1 + return depsToRun + +# todo implement it +""" +def specificDepsToRun(config, taskNameInConfig, specificDeps, **depsHashMap, commonDepsToRun): + + # depsHasMap {barrelDeps : list : [processBarrel, processMuon]} + + isAtLeastOneProcessFuncInDepsList = lambda a,b: a in b + if specificDeps is not None: + for processFunc in specificDeps.keys(): + if processFunc not in config[taskNameInConfig].keys(): + continue + if config[taskNameInConfig][processFunc] == "true": + for depList,processFuncList in depsHashMap.items(): + if len(list(map(isAtLeastOneProcessFuncInDepsList, processFunc))) > 0: + if "processFull" in processFunc or "processBarrel" in processFunc or "processAmbiguousBarrel" in processFunc: + for dep in depsHashMap.keys(): + depsToRun[dep] = 1 + if "processFull" in processFunc or "processMuon" in processFunc or "processAmbiguousMuon" in processFunc: + for dep in muonDeps: + depsToRun[dep] = 1 + for dep in specificDeps[processFunc]: + depsToRun[dep] = 1 +""" + diff --git a/extramodules/dqLibGetter.py b/extramodules/dqLibGetter.py index 47c27ce..e75ea9d 100644 --- a/extramodules/dqLibGetter.py +++ b/extramodules/dqLibGetter.py @@ -16,11 +16,14 @@ # \Author: ionut.cristian.arsene@cern.ch # \Interface: cevat.batuhan.tolon@cern.ch +from itertools import chain import os import re from urllib.request import Request, urlopen import ssl +from .utils import getIfStartedInDoubleQuotes, writeFile + # TODO It should check first local path then it should try download class DQLibGetter(object): @@ -101,34 +104,17 @@ def __init__(self, allAnalysisCuts = [], allOnlyPairCuts = [], allMCSignals = [] htmlHistogramsLibrary = urlopen(requestHistogramsLibrary, context = context).read() # Save Disk to temp DQ libs - with open("tempCutsLibrary.h", "wb") as f: - f.write(htmlCutsLibrary) - f.close() - with open("tempMCSignalsLibrary.h", "wb") as f: - f.write(htmlMCSignalsLibrary) - f.close() - with open("tempMixingLibrary.h", "wb") as f: - f.write(htmlMixingLibrary) - f.close() - with open("tempHistogramsLibrary.h", "wb") as f: - f.write(htmlHistogramsLibrary) - f.close() + writeFile("tempCutsLibrary.h", htmlCutsLibrary) + writeFile("tempMCSignalsLibrary.h", htmlMCSignalsLibrary) + writeFile("tempMixingLibrary.h", htmlMixingLibrary) + writeFile("tempHistogramsLibrary.h", htmlHistogramsLibrary) print("[INFO] Libs downloaded succesfully.") + # Read Cuts, Signals, Mixing vars from downloaded files - with open("tempMCSignalsLibrary.h") as f: - stringIfSearch = [x for x in f if "if" in x] - for i in stringIfSearch: - getSignals = re.findall('"([^"]*)"', i) - self.allMCSignals = self.allMCSignals + getSignals - f.close() - - with open("tempMixingLibrary.h") as f: - stringIfSearch = [x for x in f if "if" in x] - for i in stringIfSearch: - getMixing = re.findall('"([^"]*)"', i) - self.allMixing = self.allMixing + getMixing - f.close() - + self.allMCSignals = getIfStartedInDoubleQuotes("tempMCSignalsLibrary.h") + self.allMixing = getIfStartedInDoubleQuotes("tempMixingLibrary.h") + + # Get All histograms with flags # TODO: Reduce the complexity with open("tempHistogramsLibrary.h") as f: for line in f: if "if" in line: @@ -154,27 +140,18 @@ def __init__(self, allAnalysisCuts = [], allOnlyPairCuts = [], allMCSignals = [] dileptonHistos += line f.close() - self.allEventHistos = eventHistos - self.allTrackHistos = self.allTrackHistos + trackHistos - self.allMCTruthHistos = self.allMCTruthHistos + mctruthHistos - self.allPairHistos = self.allPairHistos + pairHistos - self.allDileptonHistos = self.allDileptonHistos + dileptonHistos - - #print("mctruth :" ,mctruthHistos) - #print("track :", trackHistos) - #print("pair histos :", pairHistos) - #print("dilepton histos", dileptonHistos) - - with open("tempCutsLibrary.h") as f: - stringIfSearch = [x for x in f if "if" in x] # get lines only includes if string - for i in stringIfSearch: - getCuts = re.findall('"([^"]*)"', i) # get in double quotes string value with regex exp. - getPairCuts = [y for y in getCuts if "pair" in y] # get pair cuts - if getPairCuts: # if pair cut list is not empty - allPairCuts = (allPairCuts + getPairCuts) # Get Only pair cuts from CutsLibrary.h - namespacedPairCuts = [x + singleColon for x in allPairCuts] # paircut: - self.allAnalysisCuts = (self.allAnalysisCuts + getCuts) # Get all Cuts from CutsLibrary.h - self.allOnlyPairCuts = (self.allOnlyPairCuts + allPairCuts) # Get all Pair Cuts from CutsLibrary.h + self.allEventHistos += eventHistos + self.allTrackHistos += trackHistos + self.allMCTruthHistos += mctruthHistos + self.allPairHistos += pairHistos + self.allDileptonHistos += dileptonHistos + + self.allAnalysisCuts = getIfStartedInDoubleQuotes("tempCutsLibrary.h") + getPairCuts = [y for y in self.allAnalysisCuts if "pair" in y] + if getPairCuts: # if pair cut list is not empty + allPairCuts += getPairCuts # Get Only pair cuts from CutsLibrary.h + namespacedPairCuts = [x + singleColon for x in allPairCuts] # paircut: + self.allOnlyPairCuts += allPairCuts # Get all Pair Cuts from CutsLibrary.h # NOTE : Now we have brute-force solution for format specifiers (for dalitz cuts) # TODO We need more simple and flexible solution for this isue @@ -192,7 +169,7 @@ def __init__(self, allAnalysisCuts = [], allOnlyPairCuts = [], allMCSignals = [] # after getting clean dalitz cuts, we need remove has format specifier dalitz cuts from allAnalysisCuts and add clean dalitz cuts self.allAnalysisCuts = [x for x in self.allAnalysisCuts if "%d" not in x] # clean the has format specifier dalitz cuts - self.allAnalysisCuts = self.allAnalysisCuts + getCleanDalitzCuts # add clean dalitz cuts + self.allAnalysisCuts += getCleanDalitzCuts # add clean dalitz cuts # print(self.allAnalysisCuts) # in Filter PP Task, sels options for barrel and muon uses namespaces e.g. ":[]: and :: For Manage this issue: @@ -202,14 +179,14 @@ def __init__(self, allAnalysisCuts = [], allOnlyPairCuts = [], allMCSignals = [] for k in range(1, 10): # Style 1 :: --> selsWithDoubleColon nAddedallAnalysisCuts = [x + str(k) for x in allAnalysisCutsDoubleColon] - selsWithDoubleColon = selsWithDoubleColon + nAddedallAnalysisCuts + selsWithDoubleColon += nAddedallAnalysisCuts nAddedPairCuts = [x + str(k) for x in namespacedPairCuts] - pairCutsWithSingleColon = pairCutsWithSingleColon + nAddedPairCuts + pairCutsWithSingleColon += nAddedPairCuts # Style 2 :[]:: for i in pairCutsWithSingleColon: Style1 = [x + i for x in allAnalysisCutsSingleColon] - selsWithSingleColon = selsWithSingleColon + Style1 + selsWithSingleColon += Style1 # Merge All possible styles for Sels (cfgBarrelSels and cfgMuonSels) in FilterPP Task f.close() diff --git a/extramodules/stringOperations.py b/extramodules/utils.py similarity index 69% rename from extramodules/stringOperations.py rename to extramodules/utils.py index d4aaabe..5dec465 100644 --- a/extramodules/stringOperations.py +++ b/extramodules/utils.py @@ -13,8 +13,10 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -# This script includes string operations for logic +# This script includes utils for basic operations +import json +import re def listToString(s: list): """ @@ -68,3 +70,30 @@ def stringToListWithSlash(string: str): """ li = list(string.split("/")) return li + + +def writeFile(openFile, writeFile): + with open(openFile, "wb") as f: + f.write(writeFile) + f.close() + +def loadJson(fileName): + with open(fileName) as configFile: + return json.load(configFile) + +def writeJson(updatedConfigFileName, config): + with open(updatedConfigFileName, "w") as outputFile: + json.dump(config, outputFile, indent = 2) + +# TODO: ommit the side effects +def getIfStartedInDoubleQuotes(headerFileName): + mylist = [] + with open(headerFileName) as f: + stringIfSearch = [x for x in f if "if" in x] + for i in stringIfSearch: + mylist.extend(re.findall('"([^"]*)"', i)) + return mylist + + #f.close() + + diff --git a/runDQEfficiency.py b/runDQEfficiency.py index 3b6889c..636051c 100755 --- a/runDQEfficiency.py +++ b/runDQEfficiency.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setConfig, setFalseHasDeps, setSwitch, setSelection, debugSettings, setProcessDummy, dispArgs, multiConfigurableSet, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.dqEfficiency import DQEfficiency +from extramodules.utils import loadJson, writeJson def main(): @@ -74,9 +75,7 @@ def main(): args.process = setPrefixSuffix(args.process, "process", 'Skimmed', True, True) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -134,9 +133,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigDQEfficiency.json" - - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + writeJson(updatedConfigFileName, config) commandToRun = (taskNameInCommandLine + " --configuration json://" + updatedConfigFileName + " -b") if args.writer is not None: diff --git a/runDQFlow.py b/runDQFlow.py index eb700b7..0efcb19 100755 --- a/runDQFlow.py +++ b/runDQFlow.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setSwitch, setConverters, setConfig, debugSettings, dispArgs, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.dqFlow import AnalysisQvector +from extramodules.utils import loadJson, writeJson def main(): @@ -64,9 +65,7 @@ def main(): args.isWSlice = setPrefixSuffix(args.isWSlice, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -109,8 +108,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigDQFlow.json" - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + writeJson(updatedConfigFileName, config) # Check which dependencies need to be run depsToRun = {} diff --git a/runDalitzSelection.py b/runDalitzSelection.py index d0f38c3..9859849 100644 --- a/runDalitzSelection.py +++ b/runDalitzSelection.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setSwitch, setConverters, setConfig, debugSettings, dispArgs, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.dalitzSelection import DalitzPairing +from extramodules.utils import loadJson, writeJson def main(): @@ -64,9 +65,7 @@ def main(): args.isWSlice = setPrefixSuffix(args.isWSlice, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -109,8 +108,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigDalitzSelection.json" - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + writeJson(updatedConfigFileName, config) # Check which dependencies need to be run depsToRun = {} diff --git a/runEMEfficiency.py b/runEMEfficiency.py index 20bb6ae..455688f 100755 --- a/runEMEfficiency.py +++ b/runEMEfficiency.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setConfig, setFalseHasDeps, setSwitch, setSelection, debugSettings, setProcessDummy, dispArgs, multiConfigurableSet, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.emEfficiency import EMEfficiency +from extramodules.utils import loadJson, writeJson def main(): @@ -64,9 +65,7 @@ def main(): args.process = setPrefixSuffix(args.process, "process", 'Skimmed', True, True) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -116,9 +115,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigEMEfficiencyEE.json" - - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + writeJson(updatedConfigFileName, config) commandToRun = (taskNameInCommandLine + " --configuration json://" + updatedConfigFileName + " -b" + " --shm-segment-size 12000000000 --aod-memory-rate-limit " + args.aod_memory_rate_limit) diff --git a/runEMEfficiencyNotSkimmed.py b/runEMEfficiencyNotSkimmed.py index ceac471..030a0d1 100755 --- a/runEMEfficiencyNotSkimmed.py +++ b/runEMEfficiencyNotSkimmed.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setSwitch, setSelection, setConverters, setConfig, setProcessDummy, debugSettings, dispArgs, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.emEfficiencyNoSkimmed import EMEfficiencyNoSkimmed +from extramodules.utils import loadJson, writeJson def main(): @@ -72,9 +73,7 @@ def main(): args.isWSlice = setPrefixSuffix(args.isWSlice, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -120,9 +119,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigEMEfficiencyEENoSkimmed.json" - - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + writeJson(updatedConfigFileName, config) # Check which dependencies need to be run depsToRun = {} diff --git a/runFilterPP.py b/runFilterPP.py index fd1750c..7399a57 100755 --- a/runFilterPP.py +++ b/runFilterPP.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setSwitch, setSelection, setConverters, setConfig, setProcessDummy, debugSettings, dispArgs, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.filterPP import DQFilterPPTask +from extramodules.utils import loadJson def main(): @@ -75,9 +76,7 @@ def main(): args.isWSlice = setPrefixSuffix(args.isWSlice, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) diff --git a/runTableMaker.py b/runTableMaker.py index 0c64622..b217a03 100755 --- a/runTableMaker.py +++ b/runTableMaker.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setParallelismOnSkimming, setProcessDummy, setSwitch, setConverters, setConfig, debugSettings, dispArgs, generateDescriptors, setPrefixSuffix, tableProducer from extramodules.pycacheRemover import runPycacheRemover from dqtasks.tableMaker import TableMaker +from extramodules.utils import loadJson, writeJson def main(): @@ -137,9 +138,7 @@ def main(): # if cliMode true, Overrider mode else additional mode cliMode = args.onlySelect - - #forgettedArgsChecker(allArgs) # Transaction management - + # adding prefix for setSwitch function args.process = setPrefixSuffix(args.process, "process", '', True, False) args.pid = setPrefixSuffix(args.pid, "pid-", '', True, False) @@ -151,10 +150,7 @@ def main(): args.QA = setPrefixSuffix(args.QA, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) - + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) runOverMC = False @@ -241,9 +237,10 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigTableMaker.json" + writeJson(updatedConfigFileName, config) - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + #with open(updatedConfigFileName, "w") as outputFile: + #json.dump(config, outputFile, indent = 2) # Check which dependencies need to be run depsToRun = {} @@ -264,8 +261,7 @@ def main(): depsToRun[dep] = 1 # Check which tables are required in the output - tablesToProduce = {} - tableProducer(config, taskNameInConfig, tablesToProduce, commonTables, barrelCommonTables, muonCommonTables, specificTables, specificDeps, runOverMC) + tablesToProduce = tableProducer(config, taskNameInConfig, commonTables, barrelCommonTables, muonCommonTables, specificTables, specificDeps, runOverMC) writerConfigFileName = "aodWriterTempConfig.json" diff --git a/runTableMakerMC.py b/runTableMakerMC.py index 776b7f9..de976f6 100755 --- a/runTableMakerMC.py +++ b/runTableMakerMC.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setParallelismOnSkimming, setSwitch, setConverters, setConfig, debugSettings, dispArgs, generateDescriptors, setPrefixSuffix, tableProducer, setProcessDummy from extramodules.pycacheRemover import runPycacheRemover from dqtasks.tableMakerMC import TableMakerMC +from extramodules.utils import loadJson, writeJson def main(): @@ -135,9 +136,7 @@ def main(): args.isWSlice = setPrefixSuffix(args.isWSlice, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -191,10 +190,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigTableMakerMC.json" - - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) - + writeJson(updatedConfigFileName, config) # Check which dependencies need to be run depsToRun = {} for dep in commonDeps: diff --git a/runTableReader.py b/runTableReader.py index e0da3e3..4aedc63 100755 --- a/runTableReader.py +++ b/runTableReader.py @@ -27,6 +27,7 @@ from extramodules.configSetter import setConfig, setFalseHasDeps, setSwitch, setSelection, setProcessDummy, debugSettings, dispArgs, setPrefixSuffix from extramodules.pycacheRemover import runPycacheRemover from dqtasks.tableReader import TableReader +from extramodules.utils import loadJson def main(): @@ -85,9 +86,7 @@ def main(): args.mixing = setPrefixSuffix(args.mixing, "process", 'Skimmed', True, True) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) # Transaction jsonTypeChecker(args.cfgFileName) diff --git a/runV0selector.py b/runV0selector.py index 30a31c7..81854e1 100755 --- a/runV0selector.py +++ b/runV0selector.py @@ -27,6 +27,7 @@ from extramodules.dqTranscations import aodFileChecker, forgettedArgsChecker, jsonTypeChecker, mainTaskChecker, trackPropagationChecker from extramodules.pycacheRemover import runPycacheRemover from dqtasks.v0selector import V0selector +from extramodules.utils import loadJson, writeJson def main(): @@ -71,9 +72,7 @@ def main(): args.QA = setPrefixSuffix(args.QA, "process", '', True, False) # Load the configuration file provided as the first parameter - config = {} - with open(args.cfgFileName) as configFile: - config = json.load(configFile) + config = loadJson(args.cfgFileName) jsonTypeChecker(args.cfgFileName) @@ -119,9 +118,7 @@ def main(): # Write the updated configuration file into a temporary file updatedConfigFileName = "tempConfigV0Selector.json" - - with open(updatedConfigFileName, "w") as outputFile: - json.dump(config, outputFile, indent = 2) + writeJson(updatedConfigFileName, config) # Check which dependencies need to be run depsToRun = {}