class_docstr: Callable that generates directory path strings for path-based partition formats.
  Path-based partition formats embed all partition keys and values directly in
  their dataset file paths.
  Two path partition formats are currently supported - `HIVE` and `DIRECTORY`.
  For `HIVE` Partitioning, all partition directories will be generated using a
  `{key1}={value1}/{key2}={value2}` naming convention under the base directory.
  An accompanying ordered list of partition key field names must also be
  provided, where the order and length of all partition values must match the
  order and length of field names
  For `DIRECTORY` Partitioning, all directories will be generated from partition
  values using a `{value1}/{value2}` naming convention under the base directory.
class_docstr_tok: ["Callable","that","generates","directory","path","strings","for","path-based","partition","formats",".","Path-based","partition","formats","embed","all","partition","keys","and","values","directly","in","their","dataset","file","paths",".","Two","path","partition","formats","are","currently","supported","-","`","HIVE","`","and","`","DIRECTORY","`",".","For","`","HIVE","`","Partitioning",",","all","partition","directories","will","be","generated","using","a","`","{","key1","}","=","{","value1","}","\/","{","key2","}","=","{","value2","}","`","naming","convention","under","the","base","directory",".","An","accompanying","ordered","list","of","partition","key","field","names","must","also","be","provided",",","where","the","order","and","length","of","all","partition","values","must","match","the","order","and","length","of","field","names","For","`","DIRECTORY","`","Partitioning",",","all","directories","will","be","generated","from","partition","values","using","a","`","{","value1","}","\/","{","value2","}","`","naming","convention","under","the","base","directory","."]
docstr: Creates a new partition path encoder.
  Args:
      partitioning: The path-based partition scheme. All partition paths
          will be generated under this scheme's base directory. Field names are
          required for HIVE partition paths, optional for DIRECTORY partition
          paths. When non-empty, the order and length of partition key field
          names must match the order and length of partition values.
code: def __init__(self, partitioning: Partitioning):
      """Creates a new partition path encoder.
      Args:
          partitioning: The path-based partition scheme. All partition paths
              will be generated under this scheme's base directory. Field names are
              required for HIVE partition paths, optional for DIRECTORY partition
              paths. When non-empty, the order and length of partition key field
              names must match the order and length of partition values.
      """
      style = partitioning.style
      field_names = partitioning.field_names
      if style == PartitionStyle.HIVE and not field_names:
          raise ValueError(
              "Hive partition path generation requires a corresponding list of "
              "partition key field names. Please retry your request with one "
              "or more field names specified."
          )
      generators = {
          PartitionStyle.HIVE: self._as_hive_partition_dirs,
          PartitionStyle.DIRECTORY: self._as_directory_partition_dirs,
      }
      self._encoder_fn: Callable[
          [List[str]], List[str]
      ] = generators.get(style)
      if self._encoder_fn is None:
          raise ValueError(
              f"Unsupported partition style: {style}. "
              f"Supported styles: {generators.keys()}"
          )
      self._scheme = partitioning
  
imports: import json
  import os
  import posixpath
  from typing import Any, Callable, Dict, Iterator, List, Optional, Union
  import pandas
  import pyarrow
  import pyarrow
  import pytest
  from pyarrow.fs import FileType
  from pytest_lazyfixture import lazy_fixture
  import ray
  from ray.data.block import Block
  from ray.data.dataset import Dataset
  from ray.data.datasource import FileBasedDatasource, PathPartitionParser
  from ray.data.datasource.file_based_datasource import FileExtensionFilter, _resolve_paths_and_filesystem
  from ray.data.datasource.partitioning import Partitioning, PartitionStyle, PathPartitionFilter
  from ray.data.tests.conftest import *
  from ray.tests.conftest import *
label_desc: Use image node_id 2 to create a new PathPartitionEncoder object  with example: obj = PathPartitionEncoder(partitioning)