class_docstr: A DirectoryWatcher wraps a loader to load from a sequence of paths.
  
  A loader reads a path and produces some kind of values as an iterator. A
  DirectoryWatcher takes a directory, a factory for loaders, and optionally a
  path filter and watches all the paths inside that directory.
  
  This class is only valid under the assumption that only one path will be
  written to by the data source at a time and that once the source stops writing
  to a path, it will start writing to a new path that's lexicographically
  greater and never come back. It uses some heuristics to check whether this is
  true based on tracking changes to the files' sizes, but the check can have
  false negatives. However, it should have no false positives.
docstr: Gets the next path to load from.
  
  This function also does the checking for out-of-order writes as it iterates
  through the paths.
  
  Returns:
    The next path to load events from, or None if there are no more paths.
docstr_tok: ["Gets","the","next","path","to","load","from",".","This","function","also","does","the","checking","for","out-of-order","writes","as","it","iterates","through","the","paths",".","Returns",":","The","next","path","to","load","events","from",",","or","None","if","there","are","no","more","paths","."]
code: def _GetNextPath(self):
      """Gets the next path to load from.
  
      This function also does the checking for out-of-order writes as it iterates
      through the paths.
  
      Returns:
        The next path to load events from, or None if there are no more paths.
      """
      paths = sorted(
          path
          for path in io_wrapper.ListDirectoryAbsolute(self._directory)
          if self._path_filter(path)
      )
      if not paths:
          return None
  
      if self._path is None:
          return paths[0]
  
      # Don't bother checking if the paths are GCS (which we can't check) or if
      # we've already detected an OOO write.
      if (
          not io_util.IsCloudPath(paths[0])
          and not self._ooo_writes_detected
      ):
          # Check the previous _OOO_WRITE_CHECK_COUNT paths for out of order writes.
          current_path_index = bisect.bisect_left(paths, self._path)
          ooo_check_start = max(
              0, current_path_index - self._OOO_WRITE_CHECK_COUNT
          )
          for path in paths[ooo_check_start:current_path_index]:
              if self._HasOOOWrite(path):
                  self._ooo_writes_detected = True
                  break
  
      next_paths = list(
          path
          for path in paths
          if self._path is None or path > self._path
      )
      if next_paths:
          return min(next_paths)
      else:
          return None
  
file_path: tensorboard/tensorboard/backend/event_processing/directory_watcher.py
imports: import bisect
  from tensorboard.backend.event_processing import io_wrapper
  from tensorboard.compat import tf
  from tensorboard.util import io_util
  from tensorboard.util import tb_logging
label_desc: Use image node_id 7 for calling the DirectoryWatcher obj's underlying member method code with example usage: obj._GetNextPath() and returns: None, paths, min, None