@@ -539,6 +539,21 @@ def calc_thresholds(rel_val_dict, default_thresholds, margins_thresholds, args):
539539 return the_thresholds
540540
541541
542+ def write_single_summary (comp_objects , meta_info , path ):
543+ with open (path , "w" ) as f :
544+ json .dump ({"objects" : comp_objects , "meta_info" : meta_info }, f , indent = 2 )
545+
546+
547+ def read_single_summary (path ):
548+ with open (path , "r" ) as f :
549+ d = json .load (f )
550+ return d .get ("objects" , {}), d .get ("meta_info" , {})
551+
552+
553+ def make_single_meta_info (args ):
554+ return {"batch_i" : [abspath (path ) for path in args .input1 ], "batch_j" : [abspath (path ) for path in args .input2 ]}
555+
556+
542557def make_single_summary (rel_val_dict , args , output_dir , include_patterns = None , exclude_patterns = None , flags = None , flags_summary = None ):
543558 """
544559 Make the usual summary
@@ -557,7 +572,6 @@ def assign_result_flag(is_critical, comparable, passed):
557572 result = "WARNING"
558573 return result
559574
560- user_thresholds = {}
561575 this_summary = {}
562576
563577 default_thresholds = {t : getattr (args , f"{ t } _threshold" ) for t in REL_VAL_TEST_NAMES }
@@ -663,19 +677,27 @@ def run_macro(cmd, log_file):
663677 cmd = f"root -l -b -q { ROOT_MACRO_RELVAL } { cmd } "
664678 print ("Running RelVal on extracted objects" )
665679 run_macro (cmd , log_file_rel_val )
680+ # This comes from the ROOT macro
666681 json_path = join (output_dir , "RelVal.json" )
667682
668- if exists (json_path ):
669- # go through all we found
670- rel_val_summary = None
671- with open (json_path , "r" ) as f :
672- rel_val_summary = json .load (f )
673- final_summary = make_single_summary (rel_val_summary , args , output_dir )
674- with open (join (output_dir , "Summary.json" ), "w" ) as f :
675- json .dump (final_summary , f , indent = 2 )
676- plot_pie_charts (final_summary , output_dir , "" )
677- plot_values_thresholds (final_summary , output_dir , "" )
678- plot_summary_grid (final_summary , None , None , None , join (output_dir , "SummaryTests.png" ))
683+ if not exists (json_path ):
684+ # something went wrong
685+ print (f"ERROR: Something went wrong, cannot find { json_path } which was supposed to be created by ROOT, log file is" )
686+ with open (log_file_rel_val , "r" ) as f :
687+ print (f .read ())
688+ return 1
689+
690+ # go through all we found
691+ rel_val_summary = None
692+ with open (json_path , "r" ) as f :
693+ rel_val_summary = json .load (f )
694+ final_summary = make_single_summary (rel_val_summary , args , output_dir )
695+ meta_info = make_single_meta_info (args )
696+ write_single_summary (final_summary , meta_info , join (output_dir , "Summary.json" ))
697+
698+ plot_pie_charts (final_summary , output_dir , "" )
699+ plot_values_thresholds (final_summary , output_dir , "" )
700+ plot_summary_grid (final_summary , None , None , None , join (output_dir , "SummaryTests.png" ))
679701
680702 return 0
681703
@@ -727,11 +749,15 @@ def make_global_summary(in_dir):
727749 file_paths = glob (f"{ in_dir } /**/Summary.json" , recursive = True )
728750 summary = {}
729751
752+ batch_i = []
753+ batch_j = []
754+
730755 for path in file_paths :
731756 # go through all we found
732- current_summary = None
733- with open (path , "r" ) as f :
734- current_summary = json .load (f )
757+ current_summary , meta_info = read_single_summary (path )
758+ batch_i .extend (meta_info .get ("batch_i" , []))
759+ batch_j .extend (meta_info .get ("batch_j" , []))
760+
735761 # remove the file name, used as the top key for this collection
736762 rel_val_path = "/" .join (path .split ("/" )[:- 1 ])
737763 type_specific = relpath (rel_val_path , in_dir )
@@ -745,7 +771,8 @@ def make_global_summary(in_dir):
745771 test ["type_global" ] = type_global
746772 test ["type_specific" ] = type_specific
747773 test ["rel_path_plot" ] = join (rel_path_plot , f"{ histo_name } .png" )
748- return summary
774+
775+ return summary , {"batch_i" : batch_i , "batch_j" : batch_j }
749776
750777
751778def rel_val_sim_dirs (args ):
@@ -825,12 +852,12 @@ def rel_val(args):
825852 if not exists (args .output ):
826853 makedirs (args .output )
827854 func (args )
828- global_summary = make_global_summary (args .output )
829- with open (join (args .output , "SummaryGlobal.json" ), "w" ) as f :
830- json .dump (global_summary , f , indent = 2 )
855+ global_summary , meta_info = make_global_summary (args .output )
856+ write_single_summary (global_summary , meta_info , join (args .output , "SummaryGlobal.json" ))
831857 print_summary (global_summary )
832858 return 0
833859
860+
834861def get_filepath (d ):
835862 summary_global = join (d , "SummaryGlobal.json" )
836863 if exists (summary_global ):
@@ -841,6 +868,7 @@ def get_filepath(d):
841868 print (f"Can neither find { summary_global } nor { summary } . Nothing to work with." )
842869 return None
843870
871+
844872def copy_overlays (path , output_dir ,summary ):
845873 """
846874 copy overlay plots in this summary from the input directory to the output directory
@@ -857,6 +885,7 @@ def copy_overlays(path, output_dir,summary):
857885 print (f"File { filename } not found." )
858886 return 0
859887
888+
860889def inspect (args ):
861890 """
862891 Inspect a Summary.json in view of RelVal severity
@@ -875,12 +904,9 @@ def inspect(args):
875904 include_patterns , exclude_patterns = load_patterns (args .include_patterns , args .exclude_patterns )
876905 flags = args .flags
877906 flags_summary = args .flags_summary
878- current_summary = None
879- with open (path , "r" ) as f :
880- current_summary = json .load (f )
907+ current_summary , meta_info = read_single_summary (path )
881908 summary = make_single_summary (current_summary , args , output_dir , include_patterns , exclude_patterns , flags , flags_summary )
882- with open (join (output_dir , "Summary.json" ), "w" ) as f :
883- json .dump (summary , f , indent = 2 )
909+ write_single_summary (summary , meta_info , join (output_dir , "Summary.json" ))
884910 print_summary (summary , include_patterns )
885911
886912 if args .plot :
@@ -976,17 +1002,9 @@ def influx(args):
9761002 # always the same
9771003 row_tags = table_name + tags_out
9781004
979- def replace_None (value ):
980- # helper to replace None by string null
981- if value is None :
982- return "null"
983- return value
984-
9851005 out_file = join (output_dir , "influxDB.dat" )
9861006
987- summary = None
988- with open (json_in , "r" ) as f :
989- summary = json .load (f )
1007+ summary , _ = read_single_summary (json_in )
9901008 with open (out_file , "w" ) as f :
9911009 for i , (histo_name , tests ) in enumerate (summary .items ()):
9921010 if not tests :
@@ -1005,6 +1023,7 @@ def replace_None(value):
10051023 f .write (f"{ test_string } \n " )
10061024 return 0
10071025
1026+
10081027def dir_comp (args ):
10091028 """
10101029 Entry point for RelVal
@@ -1022,6 +1041,7 @@ def dir_comp(args):
10221041 json .dump (file_sizes_to_json , f , indent = 2 )
10231042 return 0
10241043
1044+
10251045def print_table (args ):
10261046 """
10271047 Print the filtered histogram names of a Summary.json as list to screen
@@ -1033,8 +1053,7 @@ def print_table(args):
10331053 return 1
10341054
10351055 include_patterns , exclude_patterns = load_patterns (args .include_patterns , args .exclude_patterns , False )
1036- with open (path , "r" ) as f :
1037- summary = json .load (f )
1056+ summary , _ = read_single_summary (path )
10381057 for histo_name , tests in summary .items ():
10391058 if not check_patterns (histo_name , include_patterns , exclude_patterns ):
10401059 continue
@@ -1044,6 +1063,7 @@ def print_table(args):
10441063
10451064 return 0
10461065
1066+
10471067def print_header ():
10481068 print (f"\n { '#' * 25 } \n #{ ' ' * 23 } #\n # RUN ReleaseValidation #\n #{ ' ' * 23 } #\n { '#' * 25 } \n " )
10491069
0 commit comments