nemo_curator.stages.file_partitioning
nemo_curator.stages.file_partitioning
Module Contents
Classes
API
Bases: ProcessingStage[_EmptyTask, FileGroupTask]
Stage that partitions input file paths into FileGroupTasks.
This stage runs as a dedicated processing stage (not on the driver) and creates file groups based on the partitioning strategy.
Parameters
file_paths: str | list[str] Path to the input files. files_per_partition: int | None = None Number of files per partition. If both files_per_partition and blocksize are not provided, then default to files_per_partition = 1 and enforce a blocksize <= 512 MB per partition safeguard. Errors if both files_per_partition and blocksize are provided. blocksize: int | str | None = None Target size of the partitions. A blocksize of 512 MB or less is recommended. Errors if both files_per_partition and blocksize are provided. Note: For compressed files, the compressed size is used for blocksize estimation. file_extensions: list[str] | None = None File extensions to filter. storage_options: dict[str, Any] | None = None Storage options to pass to the file system. limit: int | None = None Maximum number of partitions to create.
Initialize default values.
Extract dataset name from file paths (fsspec-compatible).
Get the list of files to process.
Partition files by count.
Partition files by target size. Args: files: A list of tuples (file_path, file_size) blocksize: The target size of the partitions Returns: A list of lists, where each inner list contains the file paths of the files in the partitionN
Process the initial task to create file group tasks.
This stage expects a simple Task with file paths information and outputs multiple FileGroupTasks for parallel processing.
Ray stage specification for this stage.