def testWorkerDoesRemoveDirPath(self): temp_dir = self.get_temp_dir() strategy = DistributedFileUtilsTest.MockedWorkerStrategy() dir_to_write = distributed_file_utils.write_dirpath(temp_dir, strategy) file_to_write = os.path.join(dir_to_write, 'tmp') self.assertFalse(os.path.exists(file_to_write)) self._write_dummy_file(file_to_write) self.assertTrue(os.path.exists(file_to_write)) distributed_file_utils.remove_temp_dirpath(temp_dir, strategy) self.assertFalse(os.path.exists(file_to_write)) self.assertFalse(os.path.exists(os.path.dirname(file_to_write)))
def back_up(self, epoch): """Back up the current state of training into a checkpoint file. Args: epoch: The current epoch information to be saved. """ K.set_value(self._ckpt_saved_epoch, epoch) # Save the model plus CKPT_SAVED_EPOCH variable. if self.write_checkpoint_manager.save(): distributed_file_utils.remove_temp_dirpath( self.write_checkpoint_manager.directory, self._model.distribute_strategy)
def testMultipleRemoveDirToWritePathIsFine(self): temp_dir = self.get_temp_dir() strategy = DistributedFileUtilsTest.MockedWorkerStrategy() dir_to_write = distributed_file_utils.write_dirpath(temp_dir, strategy) file_to_write = os.path.join(dir_to_write, 'tmp') self._write_dummy_file(file_to_write) distributed_file_utils.remove_temp_dirpath(dir_to_write, strategy) distributed_file_utils.remove_temp_dirpath(dir_to_write, strategy) distributed_file_utils.remove_temp_dirpath(dir_to_write, strategy)