From 1194864c31b7cbc9defe9322b73444670c1cf20e Mon Sep 17 00:00:00 2001 From: Rafal Bielski <rafal.bielski@cern.ch> Date: Mon, 2 May 2022 15:36:32 +0200 Subject: [PATCH] Fix and prevent irreproducible ordering of Trigger EDM list --- .../TrigEDMConfig/CMakeLists.txt | 5 +++++ .../TrigEDMConfig/python/TriggerEDMRun3.py | 2 +- .../TrigEDMConfig/python/testEDMRun3.py | 11 +++++++++- .../test/testTriggerEDMRun3Reproducibility.sh | 22 +++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 Trigger/TriggerCommon/TrigEDMConfig/test/testTriggerEDMRun3Reproducibility.sh diff --git a/Trigger/TriggerCommon/TrigEDMConfig/CMakeLists.txt b/Trigger/TriggerCommon/TrigEDMConfig/CMakeLists.txt index 43378552b975..f88fe64e6ced 100644 --- a/Trigger/TriggerCommon/TrigEDMConfig/CMakeLists.txt +++ b/Trigger/TriggerCommon/TrigEDMConfig/CMakeLists.txt @@ -5,6 +5,7 @@ atlas_subdir( TrigEDMConfig ) # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-select=ATL900,ATL901 ) +atlas_install_scripts( test/*.sh ) atlas_add_test( testEDM SCRIPT python/testEDM.py @@ -13,3 +14,7 @@ atlas_add_test( testEDM atlas_add_test( testEDMRun3 SCRIPT python/testEDMRun3.py POST_EXEC_SCRIPT nopost.sh ) + +atlas_add_test( testEDMRun3Reproducibility + SCRIPT testTriggerEDMRun3Reproducibility.sh + POST_EXEC_SCRIPT nopost.sh ) diff --git a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py index 70d098bcf1da..08acad35da73 100644 --- a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py +++ b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py @@ -85,7 +85,7 @@ JetCopyVarsToKeep += [f'fastDIPS20211215_p{x}' for x in 'cub'] JetCopyVars = '.'.join(JetCopyVarsToKeep) # Create a (temporary) list of TLAJetVars as the union of JetVars and JetCopyVars -TLAJetVarsToKeep = list(set(JetVarsToKeep+JetCopyVarsToKeep)) +TLAJetVarsToKeep = sorted(list(set(JetVarsToKeep+JetCopyVarsToKeep))) TLAJetVars='.'.join(TLAJetVarsToKeep) ElToKeep = ['ptcone20', 'ptvarcone20'] diff --git a/Trigger/TriggerCommon/TrigEDMConfig/python/testEDMRun3.py b/Trigger/TriggerCommon/TrigEDMConfig/python/testEDMRun3.py index 61e8429d4a2b..d5e744e0208d 100755 --- a/Trigger/TriggerCommon/TrigEDMConfig/python/testEDMRun3.py +++ b/Trigger/TriggerCommon/TrigEDMConfig/python/testEDMRun3.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -from TriggerEDMRun3 import TriggerHLTListRun3, EDMDetailsRun3, AllowedOutputFormats +from TrigEDMConfig.TriggerEDMRun3 import TriggerHLTListRun3, EDMDetailsRun3, AllowedOutputFormats from AthenaCommon.Logging import logging log = logging.getLogger('testEDMRun3') @@ -13,6 +13,15 @@ def isCLIDDefined(typename): c = cgen.genClidFromName(typename) return (cgen.getNameFromClid(c) is not None) + +def dumpListToJson(fileName): + from TrigEDMConfig.TriggerEDM import getTriggerEDMList + import json + edmDict = dict([(fmt, getTriggerEDMList(fmt, 3)) for fmt in AllowedOutputFormats]) + with open(fileName,'w') as f: + json.dump(edmDict, f) + + def main(): import re serializable_names = [] diff --git a/Trigger/TriggerCommon/TrigEDMConfig/test/testTriggerEDMRun3Reproducibility.sh b/Trigger/TriggerCommon/TrigEDMConfig/test/testTriggerEDMRun3Reproducibility.sh new file mode 100755 index 000000000000..404d7f2e735e --- /dev/null +++ b/Trigger/TriggerCommon/TrigEDMConfig/test/testTriggerEDMRun3Reproducibility.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +# + +baseFileName="trig_edmr3_repr_test_" +rm -f ${baseFileName}* + +for i in `seq 3`; do + python -c "from TrigEDMConfig.testEDMRun3 import dumpListToJson; dumpListToJson('${baseFileName}${i}.json')" +done + +diff ${baseFileName}1.json ${baseFileName}2.json >${baseFileName}diff1.txt +ret1=$? + +diff ${baseFileName}1.json ${baseFileName}3.json >${baseFileName}diff2.txt +ret2=$? + +if [[ $ret1 != 0 || $ret2 != 0 ]]; then + echo "ERROR Trigger EDM Run3 list is irreproducible" + exit 1 +fi -- GitLab