715def testEDMList(edm_list, check_edmdetails_for_version=-1):
716 """
717 Checks EDM list entries for serialization and configuration compliance.
718 """
719
720
721 _noAuxList = ["xAOD::" + contType for contType in ["TrigConfKeys", "BunchConfKey"]]
722
723 cgen = clidGenerator("", False)
724 return_code = 0
725 found_allow_truncation = False
726 serializable_names = []
727 serializable_names_no_label = []
728 serializable_names_no_properties = []
729
730 for i, edm in enumerate(edm_list):
731
732
733 if len(edm) < 3:
734 log.error("EDM entry too short for " + edm[0])
735 return_code = 1
736 continue
737
738 serializable_name = edm[0]
739 serializable_name_no_label = re.sub(r"\#.*", "", serializable_name)
740 serializable_name_no_properties = serializable_name.split('.')[0]
741
742 serializable_names.append(serializable_name)
743 serializable_names_no_label.append(serializable_name_no_label)
744 serializable_names_no_properties.append(serializable_name_no_properties)
745
746
747 if not isCLIDDefined(cgen,serializable_name_no_label):
748 log.error("no CLID for " + serializable_name)
749 return_code = 1
750
751
752 if "Aux" not in serializable_name and "." in serializable_name:
753 log.error("A '.' found in non-Aux container name " + serializable_name)
754 return_code = 1
755
756
757 if "Aux" in serializable_name and "Aux." not in serializable_name:
758 log.error("no final Aux. in label for " + serializable_name)
759 return_code = 1
760
761
762 if serializable_name.count("#") != 1:
763 log.error("Invalid naming structure for " + serializable_name)
764 return_code = 1
765 else:
766
767 if serializable_name.startswith("xAOD") and "Aux" not in serializable_name:
768 cont_type,cont_name = serializable_name.split("#")
769 if cont_type not in _noAuxList:
770 auxmismatch = False
771 if len(edm_list) == i+1:
772 auxmismatch = True
773 cont_to_test = "nothing"
774 else:
775 cont_to_test = edm_list[i+1][0].
split(
".")[0]+
"."
776 cont_type_short = cont_type.replace("Container","")
777 pattern = re.compile(cont_type_short+r".*Aux.*\#"+cont_name+"Aux.")
778 if not pattern.match(cont_to_test):
779
780 shallow_pattern = re.compile("xAOD::ShallowAuxContainer#"+cont_name+"Aux.")
781 if not shallow_pattern.match(cont_to_test):
782 auxmismatch = True
783 if auxmismatch:
784 log.error("Expected relevant Aux container following interface container %s, but found %s instead.",serializable_name,cont_to_test)
785 return_code = 1
786 else:
787
789 if len(edm_list[i+1]) > 1 and cont_to_test.count("#") == 1:
790 contname_to_test = cont_to_test.split("#")[1]
791 targets_to_test =
set(edm_list[i+1][1].
split())
792 if len(targets ^ targets_to_test) > 0:
793 log.error("Targets of %s (%s) and %s (%s) do not match",cont_name,targets,contname_to_test,targets_to_test)
794 return_code = 1
795
796
797 if i>0 and "Aux" in serializable_name and "Aux" in edm_list[i-1][0]:
798 log.error(f"Aux container {serializable_name} needs to folow the "
799 "associated interface container in the EDM list")
800 return_code = 1
801
802
803
804 file_types = edm[1].
split()
805 for file_type in file_types:
806 if file_type not in AllowedOutputFormats:
807 log.error("unknown file type " + file_type + " for " + serializable_name)
808 return_code = 1
809 for higher_level,required_lower_level in [('AOD','ESD'), ('SLIM','AODFULL')]:
810 if higher_level in file_type and required_lower_level not in file_types:
811 log.error("Target list for %s containing '%s' must also contain lower level target '%s'.",serializable_name,file_type,required_lower_level)
812 return_code = 1
813
814
815 tags = edm[3] if len(edm) > 3 else None
816 allow_truncation_flag = False
817 if tags:
818 allow_truncation_flag = allowTruncation in tags
819 if allow_truncation_flag:
820 found_allow_truncation = True
821
822 if found_allow_truncation and not allow_truncation_flag:
823 log.error("All instances of 'allowTruncation' need to be at the END of the EDM serialisation list")
824 return_code = 1
825
826
827
828
829
830 if len(
set(serializable_names_no_properties)) != len(serializable_names_no_properties):
831 log.error("Duplicates in EDM list! Duplicates found:")
833 for item, count in collections.Counter(serializable_names_no_properties).items():
834 if count > 1:
835 log.error(str(count) + "x: " + str(item))
836 return_code = 1
837
838
839 if check_edmdetails_for_version > 0:
840 EDMDetailList = []
841 if check_edmdetails_for_version == 3:
842 EDMDetailList = EDMDetailsRun3
843 elif check_edmdetails_for_version >= 4:
844 EDMDetailList = EDMDetailsRun4
845 else: log.warning("No EDMDetails for EDM version %d. Skipping EDMDetails check.", check_edmdetails_for_version)
846
847 for EDMDetail in EDMDetailList:
848 if EDMDetail not in serializable_names_no_label:
849 msg = "EDMDetail for " + EDMDetail + " does not correspond to any name in TriggerList"
850 log.error(msg)
851 return_code = 1
852 else: log.debug("Skipping EDMDetails check.")
853
854 return return_code
855