(dir_name,
                                                     file_name_pattern)
return latest_file
Return the most recently checkpoint file matching file_name_pattern
Return the most recently checkpoint file matching file_name_pattern
Return the most recently checkpoint file matching file_name_pattern
def get_most_recently_modified_file_matching_pattern(dir_name,
                                                     file_name_pattern):
  """Return the most recently checkpoint file matching file_name_pattern"""
  file_name_regex = '^' + re.sub(r'{.*}', r'.*', file_name_pattern) + '$'

  tf_checkpoint_file = tf.train.latest_checkpoint(dir_name)
  if tf_checkpoint_file is not None and re.match(file_name_regex,
                                                 tf_checkpoint_file):
    return tf_checkpoint_file

  file_list = [
      file_name for file_name in Path(dir_name).iterdir()
      if re.match(file_name_regex, file_name.name)
  ]
  file_time_list = [single_file.stat().st_mtime for single_file in file_list]
  file_sort_by_time = np.argsort(file_time_list)
  latest_file = file_list[
      file_sort_by_time[-1]] if file_sort_by_time.shape[0] > 0 else None
  return latest_file
def get_most_recently_modified_file_matching_pattern ( dir_name , file_name_pattern ) : file_name_regex = '^' + re . sub ( r'{.*}' , r'.*' , file_name_pattern ) + '$' tf_checkpoint_file = tf . train . latest_checkpoint ( dir_name ) if tf_checkpoint_file is not None and re . match ( file_name_regex , tf_checkpoint_file ) : return tf_checkpoint_file file_list = [ file_name for file_name in Path ( dir_name ) . iterdir ( ) if re . match ( file_name_regex , file_name . name ) ] file_time_list = [ single_file . stat ( ) . st_mtime for single_file in file_list ] file_sort_by_time = np . argsort ( file_time_list ) latest_file = file_list [ file_sort_by_time [ - 1 ] ] if file_sort_by_time . shape [ 0 ] > 0 else None return latest_file