From 6b41209bc53c40f35bb0e1060f88f5c904f480cb Mon Sep 17 00:00:00 2001 From: Ryan Everett <ryan.everett@ligo.org> Date: Tue, 4 Aug 2015 16:13:14 -0500 Subject: [PATCH] gstlal_inspiral: PR #2343 Create a checkpoint --- gstlal-inspiral/bin/gstlal_inspiral | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gstlal-inspiral/bin/gstlal_inspiral b/gstlal-inspiral/bin/gstlal_inspiral index dd50179573..a5d75883b1 100755 --- a/gstlal-inspiral/bin/gstlal_inspiral +++ b/gstlal-inspiral/bin/gstlal_inspiral @@ -178,6 +178,7 @@ import socket import time import tempfile import math +import subprocess from collections import namedtuple # The following snippet is taken from http://gstreamer.freedesktop.org/wiki/FAQ#Mypygstprogramismysteriouslycoredumping.2Chowtofixthis.3F @@ -546,7 +547,22 @@ else: # -for svd_bank, output_filename, likelihood_namedtuple in zip(svd_banks, options.output, likelihood_namedtuples_list): +for output_file_number, (svd_bank, output_filename, likelihood_namedtuple) in enumerate(zip(svd_banks, options.output, likelihood_namedtuples_list)): + # + # Checkpointing only supported for gzip files in offline analysis + # FIXME Is there a better way to check if a file is corrupted? Implement a means by which to check for sqlite file validity + # + + if options.data_source not in ("lvshm", "framexmit") and output_filename.endswith('.gz'): + try: + subprocess.check_call(["gzip", "--test", output_filename]) + # File is OK and there is no need to process it, skip ahead in the loop + continue + except subprocess.CalledProcessError: + # File does not exist or is corrupted, need to reprocess + print >>sys.stderr, "Checkpoint: {0} of {1} files completed and continuing with {2}".format(output_file_number, len(options.output), os.path.basename(output_filename)) + pass + # # create a new, empty, Bottle application and make it the current # default, then start http server(s) to serve it up -- GitLab