docstr: Initialize this datasink.
  
  Args:
      path: The folder to write files to.
      filesystem: The filesystem to write files to. If not provided, the
          filesystem is inferred from the path.
      try_create_dir: Whether to create the directory to write files to.
      open_stream_args: Arguments to pass to ``filesystem.open_output_stream``.
      filename_provider: A :class:`ray.data.datasource.FilenameProvider` that
          generates filenames for each row or block.
      dataset_uuid: The UUID of the dataset being written. If specified, it's
          included in the filename.
      file_format: The file extension. If specified, files are written with this
          extension.
docstr_tok: ["Initialize","this","datasink",".","Args",":","path",":","The","folder","to","write","files","to",".","filesystem",":","The","filesystem","to","write","files","to",".","If","not","provided",",","the","filesystem","is","inferred","from","the","path",".","try_create_dir",":","Whether","to","create","the","directory","to","write","files","to",".","open_stream_args",":","Arguments","to","pass","to","``","filesystem.open_output_stream","``",".","filename_provider",":","A",":","class",":","`","ray.data.datasource.FilenameProvider","`","that","generates","filenames","for","each","row","or","block",".","dataset_uuid",":","The","UUID","of","the","dataset","being","written",".","If","specified",",","it's","included","in","the","filename",".","file_format",":","The","file","extension",".","If","specified",",","files","are","written","with","this","extension","."]
code: def __init__(
      self,
      path: str,
      *,
      filesystem: Optional["pyarrow.fs.FileSystem"] = None,
      try_create_dir: bool = True,
      open_stream_args: Optional[Dict[str, Any]] = None,
      filename_provider: Optional[FilenameProvider] = None,
      block_path_provider: Optional[BlockWritePathProvider] = None,
      dataset_uuid: Optional[str] = None,
      file_format: Optional[str] = None,
  ):
      """Initialize this datasink.
  
      Args:
          path: The folder to write files to.
          filesystem: The filesystem to write files to. If not provided, the
              filesystem is inferred from the path.
          try_create_dir: Whether to create the directory to write files to.
          open_stream_args: Arguments to pass to ``filesystem.open_output_stream``.
          filename_provider: A :class:`ray.data.datasource.FilenameProvider` that
              generates filenames for each row or block.
          dataset_uuid: The UUID of the dataset being written. If specified, it's
              included in the filename.
          file_format: The file extension. If specified, files are written with this
              extension.
      """
      if open_stream_args is None:
          open_stream_args = {}
  
      if block_path_provider is not None:
          warnings.warn(
              "`block_path_provider` has been deprecated in favor of "
              "`filename_provider`. For more information, see "
              "https://docs.ray.io/en/master/data/api/doc/ray.data.datasource.FilenameProvider.html",  # noqa: E501
              DeprecationWarning,
          )
  
      if filename_provider is None and block_path_provider is None:
          filename_provider = _DefaultFilenameProvider(
              dataset_uuid=dataset_uuid, file_format=file_format
          )
  
      self.unresolved_path = path
      paths, self.filesystem = _resolve_paths_and_filesystem(
          path, filesystem
      )
      assert len(paths) == 1, len(paths)
      self.path = paths[0]
  
      self.try_create_dir = try_create_dir
      self.open_stream_args = open_stream_args
      self.filename_provider = filename_provider
      self.block_path_provider = block_path_provider
      self.dataset_uuid = dataset_uuid
      self.file_format = file_format
  
      self.has_created_dir = False
  
imports: import posixpath
  import warnings
  from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional
  from ray._private.utils import _add_creatable_buckets_param_if_s3_uri
  from ray.data._internal.dataset_logger import DatasetLogger
  from ray.data._internal.execution.interfaces import TaskContext
  from ray.data._internal.util import _is_local_scheme, call_with_retry
  from ray.data.block import Block, BlockAccessor
  from ray.data.context import DataContext
  from ray.data.datasource.block_path_provider import BlockWritePathProvider
  from ray.data.datasource.datasink import Datasink
  from ray.data.datasource.filename_provider import FilenameProvider, _DefaultFilenameProvider
  from ray.data.datasource.path_util import _resolve_paths_and_filesystem
  from ray.util.annotations import DeveloperAPI
label_desc: Use image node_id 1 to create a new _FileDatasink object from inherited base classes: Datasink with example: obj = _FileDatasink(path)