def save_crash_files(self, cycle): """Save crashes in per-cycle crash archive.""" crashes_archive_name = experiment_utils.get_crashes_archive_name(cycle) archive_path = os.path.join(os.path.dirname(self.crashes_dir), crashes_archive_name) with tarfile.open(archive_path, 'w:gz') as tar: tar.add(self.crashes_dir, arcname=os.path.basename(self.crashes_dir)) trial_crashes_dir = posixpath.join(self.trial_dir, 'crashes') archive_filestore_path = exp_path.filestore( posixpath.join(trial_crashes_dir, crashes_archive_name)) filestore_utils.cp(archive_path, archive_filestore_path) os.remove(archive_path)
def archive_crashes(self, cycle): """Archive this cycle's crashes into cloud bucket.""" if not os.listdir(self.crashes_dir): logs.info('No crashes found for cycle %d.', cycle) return logs.info('Archiving crashes for cycle %d.', cycle) crashes_archive_name = experiment_utils.get_crashes_archive_name(cycle) archive = os.path.join(os.path.dirname(self.crashes_dir), crashes_archive_name) with tarfile.open(archive, 'w:gz') as tar: tar.add(self.crashes_dir, arcname=os.path.basename(self.crashes_dir)) gcs_path = exp_path.gcs( posixpath.join(self.trial_dir, 'crashes', crashes_archive_name)) gsutil.cp(archive, gcs_path) os.remove(archive)