def save_checkpoint_data(self, iteration, row_scoring, col_scoring): """save checkpoint data for the specified iteration""" with util.open_shelf("%s.%04d" % (self.__checkpoint_basename, iteration)) as shelf: shelf['config'] = self.config_params shelf['iteration'] = iteration self.membership().store_checkpoint_data(shelf) row_scoring.store_checkpoint_data(shelf) col_scoring.store_checkpoint_data(shelf)
def init_from_checkpoint(self, checkpoint_filename, row_scoring, col_scoring): """initialize this object from a checkpoint file""" logging.info("Continue run using checkpoint file '%s'", checkpoint_filename) with util.open_shelf(checkpoint_filename) as shelf: self.config_params = shelf['config'] self['start_iteration'] = shelf['iteration'] + 1 self.__membership = memb.ClusterMembership.restore_from_checkpoint( self.config_params, shelf) row_scoring.restore_checkpoint_data(shelf) col_scoring.restore_checkpoint_data(shelf)