class_docstr: File-based datasource for reading files.
  
  Don't use this class directly. Instead, subclass it and implement `_read_stream()`.
class_docstr_tok: ["File-based","datasource","for","reading","files",".","Do","n't","use","this","class","directly",".","Instead",",","subclass","it","and","implement","`","_read_stream","(",")","`","."]
docstr: Create a directory to write files to.
  
  If ``try_create_dir`` is ``False``, this method is a no-op.
docstr_tok: ["Create","a","directory","to","write","files","to",".","If","``","try_create_dir","``","is","``","False","``",",","this","method","is","a","no-op","."]
code: def on_write_start(
      self,
      path: str,
      try_create_dir: bool = True,
      filesystem: Optional["pyarrow.fs.FileSystem"] = None,
      **write_args,
  ) -> None:
      """Create a directory to write files to.
  
      If ``try_create_dir`` is ``False``, this method is a no-op.
      """
      from pyarrow.fs import FileType
  
      self.has_created_dir = False
      if try_create_dir:
          paths, filesystem = _resolve_paths_and_filesystem(
              path, filesystem
          )
          assert len(paths) == 1, len(paths)
          path = paths[0]
  
          if filesystem.get_file_info(path).type is FileType.NotFound:
              # Arrow's S3FileSystem doesn't allow creating buckets by default, so we
              # add a query arg enabling bucket creation if an S3 URI is provided.
              tmp = _add_creatable_buckets_param_if_s3_uri(path)
              filesystem.create_dir(tmp, recursive=True)
              self.has_created_dir = True
  
imports: import io
  import pathlib
  import posixpath
  import warnings
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, List, Literal, Optional, Union
  import numpy
  import ray
  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 _check_pyarrow_version, _is_local_scheme, call_with_retry, make_async_gen
  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.datasource import Datasource, ReadTask, WriteResult
  from ray.data.datasource.file_meta_provider import BaseFileMetadataProvider, DefaultFileMetadataProvider
  from ray.data.datasource.filename_provider import FilenameProvider, _DefaultFilenameProvider
  from ray.data.datasource.partitioning import Partitioning, PathPartitionFilter, PathPartitionParser
  from ray.data.datasource.path_util import _has_file_extension, _resolve_paths_and_filesystem
  from ray.util.annotations import Deprecated, DeveloperAPI, PublicAPI
label_desc: Use image node_id 9 for calling the FileBasedDatasource obj's underlying member method code with example usage: obj.on_write_start(path, try_create_dir, filesystem) without return types