Python tensorflow.python.lib.io.file_io.delete_file() Examples

The following are 8 code examples of tensorflow.python.lib.io.file_io.delete_file(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorflow.python.lib.io.file_io , or try the search function .
Example #1
Source File: hooks.py    From tacotron2 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def end(self, session):
        if self.mode == tf.estimator.ModeKeys.EVAL:
            current_global_step = session.run(self.global_step_tensor)
            with open(os.path.join(self.writer.get_logdir(), "checkpoint")) as f:
                checkpoints = [ckpt for ckpt in f]
                checkpoints = [self.extract_global_step(ckpt) for ckpt in checkpoints[1:]]
                checkpoints = list(filter(lambda gs: gs < current_global_step, checkpoints))
                if len(checkpoints) > self.keep_eval_results_max_epoch:
                    checkpoint_to_delete = checkpoints[-self.keep_eval_results_max_epoch]
                    tf.logging.info("Deleting %s results at the step %d", self.mode, checkpoint_to_delete)
                    tfrecord_filespec = os.path.join(self.writer.get_logdir(),
                                                     "eval_result_step{:09d}_*.tfrecord".format(checkpoint_to_delete))
                    alignment_filespec = os.path.join(self.writer.get_logdir(),
                                                      "alignment_eval_result_step{:09d}_*.png".format(
                                                          checkpoint_to_delete))
                    mel_filespec = os.path.join(self.writer.get_logdir(),
                                                "mel_eval_result_step{:09d}_*.png".format(checkpoint_to_delete))
                    for pathname in tf.gfile.Glob([tfrecord_filespec, alignment_filespec, mel_filespec]):
                        file_io.delete_file(pathname) 
Example #2
Source File: saver.py    From lambda-packs with MIT License 5 votes vote down vote up
def _delete_file_if_exists(self, filespec):
    for pathname in file_io.get_matching_files(filespec):
      file_io.delete_file(pathname) 
Example #3
Source File: saver.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def _delete_file_if_exists(self, filespec):
    for pathname in file_io.get_matching_files(filespec):
      file_io.delete_file(pathname) 
Example #4
Source File: saver.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def _delete_file_if_exists(self, filespec):
    for pathname in file_io.get_matching_files(filespec):
      file_io.delete_file(pathname) 
Example #5
Source File: gcs_smoke.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def create_object_test():
  """Verifies file_io's object manipulation methods ."""
  starttime = int(round(time.time() * 1000))
  dir_name = "%s/tf_gcs_test_%s" % (FLAGS.gcs_bucket_url, starttime)
  print("Creating dir %s." % dir_name)
  file_io.create_dir(dir_name)

  # Create a file in this directory.
  file_name = "%s/test_file.txt" % dir_name
  print("Creating file %s." % file_name)
  file_io.write_string_to_file(file_name, "test file creation.")

  list_files_pattern = "%s/test_file*.txt" % dir_name
  print("Getting files matching pattern %s." % list_files_pattern)
  files_list = file_io.get_matching_files(list_files_pattern)
  print(files_list)

  assert len(files_list) == 1
  assert files_list[0] == file_name

  # Cleanup test files.
  print("Deleting file %s." % file_name)
  file_io.delete_file(file_name)

  # Delete directory.
  print("Deleting directory %s." % dir_name)
  file_io.delete_recursively(dir_name) 
Example #6
Source File: tf_graph_utils.py    From lmdis-rep with Apache License 2.0 5 votes vote down vote up
def _delete_file_if_exists(self, filespec):
        for pathname in file_io.get_matching_files(filespec):
            s = os.stat(pathname)[stat.ST_MODE]
            if not (s & stat.S_IWUSR):      # skip read-only file
                continue
            file_io.delete_file(pathname) 
Example #7
Source File: saver.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def _delete_file_if_exists(self, filespec):
    for pathname in file_io.get_matching_files(filespec):
      file_io.delete_file(pathname) 
Example #8
Source File: saver.py    From keras-lambda with MIT License 5 votes vote down vote up
def _delete_file_if_exists(self, filespec):
    for pathname in file_io.get_matching_files(filespec):
      file_io.delete_file(pathname)