Skip to content

Commit a9f1986

Browse files
author
Shane Snyder
committed
testing additions
1 parent 08a49b0 commit a9f1986

File tree

5 files changed

+74
-4
lines changed

5 files changed

+74
-4
lines changed

darshan-util/pydarshan/darshan/cli/summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def main(args: Union[Any, None] = None):
713713
filter_patterns=None
714714
filter_mode="exclude"
715715
if args.exclude_names and args.include_names:
716-
print('Error: only one of --exclude-names and --include-names may be used.')
716+
print('Error: only one of --exclude_names and --include_names may be used.')
717717
sys.exit(1)
718718
elif args.exclude_names:
719719
filter_patterns = args.exclude_names

darshan-util/pydarshan/darshan/report.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ def __init__(self,
317317
dtype (str): default dtype for internal structures
318318
automatic_summary (bool): automatically generate summary after loading
319319
read_all (bool): whether to read all records for log
320+
filter_patterns (list of strings): list of Python regex strings to match against
321+
filter_mode (str): filter mode to use (either "exclude" or "include")
320322
321323
Return:
322324
None
@@ -411,6 +413,8 @@ def open(self, filename, read_all=False, filter_patterns=None, filter_mode="excl
411413
Args:
412414
filename (str): filename to open (optional)
413415
read_all (bool): whether to read all records for log
416+
filter_patterns (list of strings): list of Python regex strings to match against
417+
filter_mode (str): filter mode to use (either "exclude" or "include")
414418
415419
Return:
416420
None
@@ -521,7 +525,8 @@ def read_all(self, dtype=None, filter_patterns=None, filter_mode="exclude"):
521525
Read all available records from darshan log and return as dictionary.
522526
523527
Args:
524-
None
528+
filter_patterns (list of strings): list of Python regex strings to match against
529+
filter_mode (str): filter mode to use (either "exclude" or "include")
525530
526531
Return:
527532
None
@@ -547,7 +552,8 @@ def read_all_generic_records(self, counters=True, fcounters=True, dtype=None,
547552
Read all generic records from darshan log and return as dictionary.
548553
549554
Args:
550-
None
555+
filter_patterns (list of strings): list of Python regex strings to match against
556+
filter_mode (str): filter mode to use (either "exclude" or "include")
551557
552558
Return:
553559
None
@@ -566,7 +572,8 @@ def read_all_dxt_records(self, reads=True, writes=True, dtype=None,
566572
Read all dxt records from darshan log and return as dictionary.
567573
568574
Args:
569-
None
575+
filter_patterns (list of strings): list of Python regex strings to match against
576+
filter_mode (str): filter mode to use (either "exclude" or "include")
570577
571578
Return:
572579
None
@@ -636,6 +643,8 @@ def mod_read_all_records(self, mod, dtype=None, warnings=True,
636643
Args:
637644
mod (str): Identifier of module to fetch all records
638645
dtype (str): 'numpy' for ndarray (default), 'dict' for python dictionary, 'pandas'
646+
filter_patterns (list of strings): list of Python regex strings to match against
647+
filter_mode (str): filter mode to use (either "exclude" or "include")
639648
640649
Return:
641650
None
@@ -819,6 +828,8 @@ def mod_read_all_dxt_records(self, mod, dtype=None, warnings=True, reads=True, w
819828
Args:
820829
mod (str): Identifier of module to fetch all records
821830
dtype (str): 'numpy' for ndarray (default), 'dict' for python dictionary
831+
filter_patterns (list of strings): list of Python regex strings to match against
832+
filter_mode (str): filter mode to use (either "exclude" or "include")
822833
823834
Return:
824835
None
@@ -872,6 +883,8 @@ def mod_read_all_lustre_records(self, dtype=None, warnings=True,
872883
873884
Args:
874885
dtype (str): 'numpy' for ndarray (default), 'dict' for python dictionary
886+
filter_patterns (list of strings): list of Python regex strings to match against
887+
filter_mode (str): filter mode to use (either "exclude" or "include")
875888
876889
Return:
877890
None

darshan-util/pydarshan/darshan/tests/test_data_access_by_filesystem.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,3 +679,32 @@ def test_stdio_basic_inclusion(logname,
679679
assert_series_equal(file_wr_series, expected_file_wr_series)
680680
assert_series_equal(bytes_rd_series, expected_bytes_rd_series)
681681
assert_series_equal(bytes_wr_series, expected_bytes_wr_series)
682+
683+
def test_plot_with_empty_data():
684+
# generate a report object that filters out all contained records
685+
# to ensure data access by category plot properly returns None instead of failing
686+
logpath = get_log_path("ior_hdf5_example.darshan")
687+
# use a bogus regex with the "include" filter mode to ensure no records are included
688+
with darshan.DarshanReport(logpath, filter_patterns=["bogus-regex"], filter_mode="include") as report:
689+
fig = data_access_by_filesystem.plot_with_report(report=report)
690+
assert fig == None
691+
692+
def test_with_filtered_data():
693+
# ensure get_io_cost_df doesn't include data for modules with no records
694+
logpath = get_log_path("sample-badost.darshan")
695+
# generate a report object with all STDIO module records filtered out
696+
# POSIX records should still remain
697+
with darshan.DarshanReport(logpath, filter_patterns=["ior-posix"], filter_mode="include") as report:
698+
file_id_dict = report.data["name_records"]
699+
actual_df_reads, actual_df_writes = data_access_by_filesystem.rec_to_rw_counter_dfs_with_cols(report=report,
700+
file_id_dict=file_id_dict)
701+
assert len(actual_df_reads) == 0
702+
assert len(actual_df_writes) == 2048
703+
# generate a report object with all POSIX module records filtered out
704+
# STDIO records should still remain
705+
with darshan.DarshanReport(logpath, filter_patterns=["ior-posix"], filter_mode="exclude") as report:
706+
file_id_dict = report.data["name_records"]
707+
actual_df_reads, actual_df_writes = data_access_by_filesystem.rec_to_rw_counter_dfs_with_cols(report=report,
708+
file_id_dict=file_id_dict)
709+
assert len(actual_df_reads) == 1
710+
assert len(actual_df_writes) == 2

darshan-util/pydarshan/darshan/tests/test_plot_io_cost.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,22 @@ def test_plot_io_cost_x_ticks_and_labels(logname,
315315
expected_rotations = 90
316316
x_rotations = [tl.get_rotation() for tl in xticklabels]
317317
assert_allclose(x_rotations, expected_rotations)
318+
319+
def test_plot_io_cost_empty_data():
320+
# generate a report object that filters out all contained records
321+
# to ensure plot_io_cost properly returns None instead of failing
322+
logpath = get_log_path("ior_hdf5_example.darshan")
323+
# use a bogus regex with the "include" filter mode to ensure no records are included
324+
with darshan.DarshanReport(logpath, filter_patterns=["bogus-regex"], filter_mode="include") as report:
325+
fig = plot_io_cost(report=report)
326+
assert fig == None
327+
328+
def test_plot_io_cost_filtered_data():
329+
# ensure get_io_cost_df doesn't include data for modules with no records
330+
logpath = get_log_path("sample-badost.darshan")
331+
# generate a report object with all POSIX module records filtered out
332+
# STDIO records should still remain
333+
with darshan.DarshanReport(logpath, filter_patterns=["ior-posix"], filter_mode="exclude") as report:
334+
io_cost_df = get_io_cost_df(report=report)
335+
assert "POSIX" not in io_cost_df.index
336+
assert "STDIO" in io_cost_df.index

darshan-util/pydarshan/darshan/tests/test_report.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ def test_load_records():
7575
report.mod_read_all_records("POSIX")
7676
assert 1 == len(report.data['records']['POSIX'])
7777

78+
def test_load_records_filtered():
79+
"""Sample for an expected number of records after filtering."""
80+
logfile = get_log_path("shane_macsio_id29959_5-22-32552-7035573431850780836_1590156158.darshan")
81+
with darshan.DarshanReport(logfile, filter_patterns=["\.h5$"], filter_mode="exclude") as report:
82+
assert 2 == len(report.data['records']['POSIX'])
83+
assert 0 == len(report.data['records']['MPI-IO'])
84+
with darshan.DarshanReport(logfile, filter_patterns=["\.h5$"], filter_mode="include") as report:
85+
assert 1 == len(report.data['records']['POSIX'])
86+
assert 1 == len(report.data['records']['MPI-IO'])
7887

7988
@pytest.mark.parametrize("unsupported_record",
8089
["DXT_POSIX", "DXT_MPIIO", "LUSTRE", "APMPI", "APXC"]

0 commit comments

Comments
 (0)