class_docstr: Partition parser 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 under the base directory
  will be discovered based on `{key1}={value1}/{key2}={value2}` naming
  conventions. Key/value pairs do not need to be presented in the same
  order across all paths. Directory names nested under the base directory that
  don't follow this naming condition will be considered unpartitioned. If a
  partition filter is defined, then it will be called with an empty input
  dictionary for each unpartitioned file.
  
  For `DIRECTORY` Partitioning, all directories under the base directory will
  be interpreted as partition values of the form `{value1}/{value2}`. An
  accompanying ordered list of partition field names must also be provided,
  where the order and length of all partition values must match the order and
  length of field names. Files stored directly in the base directory will
  be considered unpartitioned. If a partition filter is defined, then it will
  be called with an empty input dictionary for each unpartitioned file. For
  example, if the base directory is `"foo"`, then `"foo.csv"` and `"foo/bar.csv"`
  would be considered unpartitioned files but `"foo/bar/baz.csv"` would be associated
  with partition `"bar"`. If the base directory is undefined, then `"foo.csv"` would
  be unpartitioned, `"foo/bar.csv"` would be associated with partition `"foo"`, and
  "foo/bar/baz.csv" would be associated with partition `("foo", "bar")`.
class_docstr_tok: ["Partition","parser","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","under","the","base","directory","will","be","discovered","based","on","`","{","key1","}","=","{","value1","}","\/","{","key2","}","=","{","value2","}","`","naming","conventions",".","Key\/value","pairs","do","not","need","to","be","presented","in","the","same","order","across","all","paths",".","Directory","names","nested","under","the","base","directory","that","do","n't","follow","this","naming","condition","will","be","considered","unpartitioned",".","If","a","partition","filter","is","defined",",","then","it","will","be","called","with","an","empty","input","dictionary","for","each","unpartitioned","file",".","For","`","DIRECTORY","`","Partitioning",",","all","directories","under","the","base","directory","will","be","interpreted","as","partition","values","of","the","form","`","{","value1","}","\/","{","value2","}","`",".","An","accompanying","ordered","list","of","partition","field","names","must","also","be","provided",",","where","the","order","and","length","of","all","partition","values","must","match","the","order","and","length","of","field","names",".","Files","stored","directly","in","the","base","directory","will","be","considered","unpartitioned",".","If","a","partition","filter","is","defined",",","then","it","will","be","called","with","an","empty","input","dictionary","for","each","unpartitioned","file",".","For","example",",","if","the","base","directory","is","`","``","foo","''","`",",","then","`","``","foo.csv","''","`","and","`","``","foo\/bar.csv","''","`","would","be","considered","unpartitioned","files","but","`","``","foo\/bar\/baz.csv","''","`","would","be","associated","with","partition","`","``","bar","''","`",".","If","the","base","directory","is","undefined",",","then","`","``","foo.csv","''","`","would","be","unpartitioned",",","`","``","foo\/bar.csv","''","`","would","be","associated","with","partition","`","``","foo","''","`",",","and","''","foo\/bar\/baz.csv","''","would","be","associated","with","partition","`","(","``","foo","''",",","``","bar","''",")","`","."]
docstr: Creates a path-based partition parser.
  
  Args:
      partitioning: The path-based partition scheme. The parser starts
          searching for partitions from this scheme's base directory. File paths
          outside the base directory will be considered unpartitioned. If the
          base directory is `None` or an empty string then this will search for
          partitions in all file path directories. Field names are required for
          DIRECTORY partitioning, and optional for HIVE partitioning. When
          non-empty, the order and length of partition key field names must match
          the order and length of partition directories discovered.
docstr_tok: ["Creates","a","path-based","partition","parser",".","Args",":","partitioning",":","The","path-based","partition","scheme",".","The","parser","starts","searching","for","partitions","from","this","scheme","'s","base","directory",".","File","paths","outside","the","base","directory","will","be","considered","unpartitioned",".","If","the","base","directory","is","`","None","`","or","an","empty","string","then","this","will","search","for","partitions","in","all","file","path","directories",".","Field","names","are","required","for","DIRECTORY","partitioning",",","and","optional","for","HIVE","partitioning",".","When","non-empty",",","the","order","and","length","of","partition","key","field","names","must","match","the","order","and","length","of","partition","directories","discovered","."]
code: def __init__(self, partitioning: Partitioning):
      """Creates a path-based partition parser.
  
      Args:
          partitioning: The path-based partition scheme. The parser starts
              searching for partitions from this scheme's base directory. File paths
              outside the base directory will be considered unpartitioned. If the
              base directory is `None` or an empty string then this will search for
              partitions in all file path directories. Field names are required for
              DIRECTORY partitioning, and optional for HIVE partitioning. When
              non-empty, the order and length of partition key field names must match
              the order and length of partition directories discovered.
      """
      style = partitioning.style
      field_names = partitioning.field_names
      if style == PartitionStyle.DIRECTORY and not field_names:
          raise ValueError(
              "Directory partitioning requires a corresponding list of "
              "partition key field names. Please retry your request with one "
              "or more field names specified."
          )
      parsers = {
          PartitionStyle.HIVE: self._parse_hive_path,
          PartitionStyle.DIRECTORY: self._parse_dir_path,
      }
      self._parser_fn: Callable[[str], Dict[str, str]] = parsers.get(
          style
      )
      if self._parser_fn is None:
          raise ValueError(
              f"Unsupported partition style: {style}. "
              f"Supported styles: {parsers.keys()}"
          )
      self._scheme = partitioning
  
imports: import posixpath
  from dataclasses import dataclass
  from enum import Enum
  from typing import TYPE_CHECKING, Callable, Dict, List, Optional
  from ray.util.annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 2 to create a new PathPartitionParser object  with example: obj = PathPartitionParser(partitioning)