77from collections import OrderedDict
88import importlib .resources as importlib_resources
99
10- from typing import Any , Union , Callable
10+ from typing import Any , Union , Callable , List
1111
1212import pandas as pd
1313from mako .template import Template
@@ -124,7 +124,7 @@ def generate_fig(self):
124124 elif isinstance (fig , plot_common_access_table .DarshanReportTable ):
125125 # retrieve html table from `DarshanReportTable`
126126 self .fig_html = fig .html
127- else :
127+ elif fig is not None :
128128 err_msg = f"Figure of type { type (fig )} not supported."
129129 raise NotImplementedError (err_msg )
130130
@@ -137,21 +137,24 @@ class ReportData:
137137 ----------
138138 log_path: path to a darshan log file.
139139 enable_dxt_heatmap: flag indicating whether DXT heatmaps should be enabled
140+ filter_patterns: regex patterns for names to exclude/include
141+ filter_mode: whether to "exclude" or "include" the filter patterns
140142
141143 """
142- def __init__ (self , log_path : str , enable_dxt_heatmap : bool = False ):
144+ def __init__ (self , log_path : str , enable_dxt_heatmap : bool = False ,
145+ filter_patterns : List [str ] = None , filter_mode : str = "exclude" ):
143146 # store the log path and use it to generate the report
144147 self .log_path = log_path
145148 self .enable_dxt_heatmap = enable_dxt_heatmap
146149 # store the report
147150 self .report = darshan .DarshanReport (log_path , read_all = False )
148151 # read only generic module data and heatmap data by default
149- self .report .read_all_generic_records ()
152+ self .report .read_all_generic_records (filter_patterns = filter_patterns , filter_mode = filter_mode )
150153 if "HEATMAP" in self .report .data ['modules' ]:
151154 self .report .read_all_heatmap_records ()
152155 # if DXT heatmaps requested, additionally read-in DXT data
153156 if self .enable_dxt_heatmap :
154- self .report .read_all_dxt_records ()
157+ self .report .read_all_dxt_records (filter_patterns = filter_patterns , filter_mode = filter_mode )
155158 # create the header/footer
156159 self .get_header ()
157160 self .get_footer ()
@@ -496,7 +499,11 @@ def register_figures(self):
496499 elif "PNETCDF_FILE" in self .report .modules :
497500 opcounts_mods .append ("PNETCDF_FILE" )
498501
499- for mod in self .report .modules :
502+ for mod in self .report .records :
503+ # skip over modules with no records -- this likely means
504+ # records in the log were filtered out via name exclusions
505+ if len (self .report .records [mod ]) == 0 :
506+ continue
500507
501508 if "H5" in mod :
502509 sect_title = "Per-Module Statistics: HDF5"
@@ -633,6 +640,9 @@ def build_sections(self):
633640 """
634641 self .sections = {}
635642 for fig in self .figures :
643+ # skip empty figures
644+ if fig .fig_html == None :
645+ continue
636646 # if a section title is not already in sections, add
637647 # the section title and a corresponding empty list
638648 # to store its figures
@@ -669,6 +679,16 @@ def setup_parser(parser: argparse.ArgumentParser):
669679 action = "store_true" ,
670680 help = "Enable DXT-based versions of I/O activity heatmaps."
671681 )
682+ parser .add_argument (
683+ "--exclude_names" ,
684+ action = 'append' ,
685+ help = "regex patterns for file record names to exclude in summary report"
686+ )
687+ parser .add_argument (
688+ "--include_names" ,
689+ action = 'append' ,
690+ help = "regex patterns for file record names to include in summary report"
691+ )
672692
673693
674694def main (args : Union [Any , None ] = None ):
@@ -687,6 +707,17 @@ def main(args: Union[Any, None] = None):
687707
688708 log_path = args .log_path
689709 enable_dxt_heatmap = args .enable_dxt_heatmap
710+ filter_patterns = None
711+ filter_mode = None
712+ if args .exclude_names and args .include_names :
713+ print ('Error: only one of --exclude-names and --include-names may be used.' )
714+ sys .exit (1 )
715+ elif args .exclude_names :
716+ filter_patterns = args .exclude_names
717+ filter_mode = "exclude"
718+ elif args .include_names :
719+ filter_patterns = args .include_names
720+ filter_mode = "include"
690721
691722 if args .output is None :
692723 # if no output is provided, use the log file
@@ -699,7 +730,9 @@ def main(args: Union[Any, None] = None):
699730 # collect the report data to feed into the template
700731 report_data = ReportData (
701732 log_path = log_path ,
702- enable_dxt_heatmap = enable_dxt_heatmap
733+ enable_dxt_heatmap = enable_dxt_heatmap ,
734+ filter_patterns = filter_patterns ,
735+ filter_mode = filter_mode
703736 )
704737
705738 with importlib_resources .path (darshan .cli , "base.html" ) as base_path :
0 commit comments