Skip to content

Commit

Permalink
improved reporting of baseline file count mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Aug 19, 2016
1 parent 96c3c18 commit f6ea4a1
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions utils/python/CIME/hist_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,29 @@ def _compare_hists(case, from_dir1, from_dir2, suffix1="", suffix2=""):
if len_hist1 == 0:
comments += " no hist files found for model %s\n"%model
continue
if len_hist1 != len_hist2:
if len_hist1 > len_hist2:
comments += " num hists does not match %d != %d\n" % (len_hist1, len_hist2)
all_success = False
continue
hists2 += ['MISSING'] * (len_hist1 - len_hist2)
if len_hist1 < len_hist2:
comments += " num hists does not match %d != %d\n" % (len_hist1, len_hist2)
all_success = False
hists1 += ['MISSING'] * (len_hist2 - len_hist1)

num_compared += len(hists1)
for hist1, hist2 in zip(hists1, hists2):
success, cprnc_comments = cprnc(hist1, hist2, case, from_dir1)
if success:
comments += " %s matched %s\n" % (hist1, hist2)
if hist1 == "MISSING":
comments += " No match for file %s found in %s\n"%(hist2, from_dir1)
elif hist2 == "MISSING":
comments += " No match for file %s found in %s\n"%(hist1, from_dir2)
else:
comments += " %s did NOT match %s\n" % (hist1, hist2)
comments += cprnc_comments + "\n"
all_success = False
success, cprnc_comments = cprnc(hist1, hist2, case, from_dir1)
if success:
comments += " %s matched %s\n" % (hist1, hist2)
else:
comments += " %s did NOT match %s\n" % (hist1, hist2)
comments += cprnc_comments + "\n"
all_success = False

expect(num_compared > 0, "Did not compare any hist files for suffix1='%s' suffix2='%s', dir1='%s', dir2='%s'\nComments=%s" %
(suffix1, suffix2, from_dir1, from_dir2, comments))
Expand Down

2 comments on commit f6ea4a1

@gold2718
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a lot of extra code which may still end up trying a cprnc on two completely different files. For less code, you can get filename mismatches. Is there a reason not to just look for filename differences? Something like:
hnames1 = set([ x[:len(x)-len(suffix1)] for x in hists1 ])
hnames2 = set([ x[:len(x)-len(suffix2)] for x in hists2 ])
if len(set1 - set2) > 0:
comments += " No match in %s for following files from %s: %s\n"%(from_dir2, from_dir1, ", ".join(set1 - set2)
elif len(set2 - set1) > 0:
comments += " No match in %s for following files from %s: %s\n"%(from_dir1, from_dir2, ", ".join(set2 - set1)
else:
# Go ahead and compare all the files

@jedwards4b
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - you could do the same file basename strip that we do in compare_namelists.

Please sign in to comment.