def validate(self): """Runs a validation test. This checks that a samples group exist, and that pickeled data can be loaded. Returns ------- bool : Whether or not the file is valid as a checkpoint file. """ try: if 'sampler_info/saved_state' in self: load_state(self, path='sampler_info/saved_state') checkpoint_valid = True except KeyError: checkpoint_valid = False return checkpoint_valid
def restore_state(filename): """Restore state of the background buffers from a file""" from pycbc.io.hdf import load_state fp = h5py.File(filename, 'r') try: mgr = load_state(fp) except Exception as e: fp.close() raise e fp.close() next_template = mgr.tnum_finished + 1 logging.info('Restoring with checkpoint at template %s', next_template) return mgr.tnum_finished + 1, mgr
def read_pickled_data_from_checkpoint_file(self): """Load the sampler state (pickled) from checkpoint file """ return load_state(self, path='sampler_info/saved_state')