From 8a1d843403cda4b82417167d3473f3cefdfdc463 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Wed, 28 Aug 2019 11:07:03 -0500 Subject: update cat-grid-jobs This commit updates cat-grid-jobs to only warn once about a mismatch between the SHA1 of the current zdab-cat program and the grid results, and also cleans up some of the output. --- utils/cat-grid-jobs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'utils/cat-grid-jobs') diff --git a/utils/cat-grid-jobs b/utils/cat-grid-jobs index 1f83bea..218c1b7 100755 --- a/utils/cat-grid-jobs +++ b/utils/cat-grid-jobs @@ -119,6 +119,18 @@ class bcolors: UNDERLINE = '\033[4m' def print_warning(msg): + print(bcolors.WARNING + msg + bcolors.ENDC,file=sys.stderr) + +warned = False + +def print_warning_once(msg): + global warned + if not warned: + print_warning(msg) + print("skipping further warnings") + warned = True + +def print_fail(msg): print(bcolors.FAIL + msg + bcolors.ENDC,file=sys.stderr) if __name__ == '__main__': @@ -126,7 +138,7 @@ if __name__ == '__main__': import matplotlib.pyplot as plt import numpy as np from subprocess import check_call - from os.path import join + from os.path import join, split import os import sys import h5py @@ -161,9 +173,13 @@ if __name__ == '__main__': total_events = fout['ev'].shape[0] for filename in glob.glob(join(args.directory,'*.hdf5')): with h5py.File(filename) as f: + if 'git_sha1' not in f.attrs: + print_fail("No git sha1 found for %s. Skipping..." % tail) + continue # Check to see if the git sha1 match if fout.attrs['git_sha1'] != f.attrs['git_sha1']: - print_warning("git_sha1 is %s for current version but %s for %s" % (fout.attrs['git_sha1'],f.attrs['git_sha1'],filename)) + head, tail = split(filename) + print_warning_once("git_sha1 is %s for current version but %s for %s" % (fout.attrs['git_sha1'],f.attrs['git_sha1'],tail)) # get fits which match up with the events valid_fits = f['fits'][np.isin(f['fits'][:][['run','gtid']],fout['ev'][:][['run','gtid']])] # Add the fit results -- cgit