nemo_automodel.components.datasets.llm.delta_lake_dataset
nemo_automodel.components.datasets.llm.delta_lake_dataset
Delta Lake dataset support for streaming instruction-tuning datasets.
This module provides support for reading Delta Lake tables from Databricks or local storage as streaming datasets. It integrates with the existing ColumnMappedTextInstructionDataset infrastructure.
Supports tables with Deletion Vectors (Databricks Runtime 15.4+) via Spark (Databricks runtime) and optionally via Databricks SQL Connector for Unity Catalog access outside of Spark.
Module Contents
Classes
Functions
Data
API
HuggingFace datasets-compatible wrapper for Delta Lake tables.
This class provides better integration with the HuggingFace datasets library, supporting features like sharding, shuffling, and epoch setting for distributed training scenarios.
Parameters:
Path to the Delta Lake table.
Optional list of column names to read.
Optional dict of storage options for cloud authentication.
Optional specific version of the Delta table to read.
Get a specific row by index.
Iterate over rows in the dataset.
Return the number of rows in the table.
Set the current epoch for deterministic shuffling.
Parameters:
The epoch number.
Shard the dataset for distributed processing.
Parameters:
Total number of shards.
Index of this shard (0-based).
Returns: DeltaLakeDataset
Self for method chaining.
Configure shuffling for the dataset.
Note: For streaming Delta Lake datasets, shuffling is performed on-the-fly using a shuffle buffer. The actual shuffling happens during iteration.
Parameters:
Size of the shuffle buffer.
Random seed for reproducibility.
Returns: DeltaLakeDataset
Self for method chaining.
Limit the dataset to the first n samples.
Parameters:
Number of samples to take.
Returns: DeltaLakeDataset
A new DeltaLakeDataset limited to n samples.
Iterator that yields rows from a Delta Lake table.
This class provides a streaming interface for Delta Lake tables, yielding rows as dictionaries one at a time to support memory-efficient iteration over large tables.
Supports tables with deletion vectors (Databricks Runtime 15.4+) via Spark backend (recommended when running in Databricks notebooks/jobs).
Parameters:
Path to the Delta Lake table.
Optional list of column names to read. If None, reads all columns.
Optional storage options for cloud storage access.
Number of rows to read at a time (default: 1024).
Optional version of the table to read.
Optional SQL query to read the table and/or create alias columns.
Optional sharding configuration (num_shards, shard_index).
When provided, only rows where row_idx % num_shards == shard_index are yielded.
Iterate over rows in the Delta Lake table.
Add storage options from environment variables if not already set.
Iterate over all rows (no sharding).
Iterate using Databricks SQL Connector (for Unity Catalog tables).
This is the recommended method for accessing Unity Catalog tables as it handles authentication, deletion vectors, and column mapping natively.
Iterate using deltalake library.
Iterate using Spark (supports deletion vectors on Databricks).
This backend requires a working SparkSession (e.g., Databricks notebooks/jobs). It is the recommended fallback for Delta tables that use deletion vectors.
Shard the iterator for distributed processing.
Parameters:
Total number of shards.
Index of this shard (0-based).
Internal wrapper to limit a Delta Lake dataset to n samples.
Build a fully-qualified UC table name with safe quoting.
Check if databricks-sql-connector is available for Unity Catalog access.
Check if any Delta Lake reader is available (deltalake, Spark, or databricks-sql).
Check if the deltalake package is available.
Check if PySpark is available (used as a fallback on Databricks for deletion vectors).
Get an active Spark session if available (Databricks notebooks/jobs).
Returns: Optional[Any]
A SparkSession instance if available, else None.
Return True if e looks like the deltalake ‘deletionVectors’ unsupported-reader-features error.
Return True if e looks like Databricks UC managed-storage overlap.
Check if path refers to a Unity Catalog table (catalog.schema.table format).
Normalize a Delta Lake path by removing the delta:// prefix if present.
Parameters:
The Delta Lake path.
Returns: str
The normalized path suitable for the deltalake library.
Parse Unity Catalog managed storage IDs from a __unitystorage path.
Direct path access to these locations is blocked on Databricks (“LOCATION_OVERLAP”).
Quote an identifier for Spark SQL (handles embedded backticks).
If path looks like UC managed storage, try to resolve to catalog.schema.table.
Best-effort reverse lookup of a UC table name via Databricks system tables.
Check if a path refers to a Delta Lake table.
A path is considered a Delta Lake path if:
- It starts with “delta://” protocol prefix
- It’s a local directory containing a “_delta_log” subdirectory
- It starts with “dbfs:/” (Databricks file system)
Parameters:
The path to check.
Returns: bool
True if the path is a Delta Lake table, False otherwise.