@@ -1000,22 +1000,32 @@ def stat(args):
10001000 print_statistics (res )
10011001
10021002
1003- def merge_stats_into (list_of_json_stats , outputfile ):
1003+ def merge_stats_into (list_of_json_stats , outputfile , metadata ):
10041004 running = {}
10051005 # read all the inputs
10061006 for inp_json in list_of_json_stats :
10071007 running = merge_stats (inp_json , running )
10081008
1009+ # attach meta-data
1010+ running ["meta-data" ] = metadata
1011+
10091012 # now write out the result into the output file
10101013 if running :
10111014 with open (outputfile , 'w' ) as f :
10121015 json .dump (running , f )
10131016
10141017
1018+ def build_meta_header (stringarg ):
1019+ meta = {}
1020+ if stringarg != "" :
1021+ meta = json .loads (stringarg )
1022+ return meta
1023+
10151024def json_stat (args ):
10161025 resources = extract_resources (args .pipelines )
10171026 all_stats = [produce_json_stat (res ) for res in resources ]
1018- merge_stats_into (all_stats , args .output )
1027+
1028+ merge_stats_into (all_stats , args .output , build_meta_header (args .header_data ))
10191029
10201030
10211031def merge_json_stats (args ):
@@ -1024,7 +1034,8 @@ def merge_json_stats(args):
10241034 # load the json as a dict
10251035 with open (inp ,'r' ) as f :
10261036 all_stats .append (json .load (f ))
1027- merge_stats_into (all_stats , args .output )
1037+
1038+ merge_stats_into (all_stats , args .output , build_meta_header (args .header_data ))
10281039
10291040def history (args ):
10301041 """
@@ -1277,11 +1288,13 @@ def main():
12771288 json_stat_parser .set_defaults (func = json_stat )
12781289 json_stat_parser .add_argument ("-p" , "--pipelines" , nargs = "*" , help = "Pipeline_metric files from o2_dpg_workflow_runner; Merges information" , required = True )
12791290 json_stat_parser .add_argument ("-o" , "--output" , type = str , help = "Output json filename" , required = True )
1291+ json_stat_parser .add_argument ("-hd" , "--header-data" , type = str , default = '' , help = "Some meta-data headers to be included in the JSON" )
12801292
12811293 merge_stat_parser = sub_parsers .add_parser ("merge-json-stats" , help = "Merge information from json-stats into an aggregated stat" )
12821294 merge_stat_parser .set_defaults (func = merge_json_stats )
12831295 merge_stat_parser .add_argument ("-i" , "--inputs" , nargs = "*" , help = "List of incoming/input json stat files" , required = True )
12841296 merge_stat_parser .add_argument ("-o" , "--output" , type = str , help = "Output json filename" , required = True )
1297+ merge_stat_parser .add_argument ("-hd" , "--header-data" , type = str , default = "" , help = "Some meta-data headers to be included in the JSON" )
12851298
12861299 plot_parser = sub_parsers .add_parser ("history" , help = "Plot (multiple) metrics from extracted metrics JSON file(s)" )
12871300 plot_parser .set_defaults (func = history )
0 commit comments