lit-deltalake
Bring Delta Lake to Pytorch Lightning
Features
- Stream immutable Delta table snapshots into PyTorch
IterableDatasetinstances. - Shard Delta-rs source fragments across initialized DDP ranks and DataLoader workers.
- Use Delta-rs, an existing PySpark session, or an existing Sail Spark Connect session.
- Select, filter, transform, decode, and rename columns before training.
- Pin Delta table versions for reproducible training data.
Installation
Install the default Delta-rs and PyArrow reader:
uv add lit-deltalake
Add an optional reader when needed:
uv add "lit-deltalake[spark]" # existing PySpark session
uv add "lit-deltalake[sail]" # existing Sail Spark Connect session
With pip:
python -m pip install lit-deltalake
Usage
from lit_deltalake.dataloaders import create_pytorch_dataloader
from lit_deltalake.readers.types import Filter
import lightning
import torch
from torch import nn
from torch.utils.data import DataLoader
loader = create_pytorch_dataloader(
"/path/to/training-table",
columns=("feature_a", "feature_b", "label"),
filters=(Filter("split", lambda column, value: column == value, "train"),),
batch_size=128,
num_workers=4,
multiprocessing_context="spawn",
)
class EventsDataModule(lightning.LightningDataModule):
def __init__(self) -> None:
super().__init__()
self.loader = loader
def train_dataloader(self) -> DataLoader:
return self.loader
class Classifier(lightning.LightningModule):
def __init__(self, learning_rate: float = 1e-3) -> None:
super().__init__()
self.model = nn.Linear(2, 2)
self.learning_rate = learning_rate
self.loss_function = nn.CrossEntropyLoss()
def forward(self, features: torch.Tensor) -> torch.Tensor:
return self.model(features)
def training_step(self, batch: dict[str, torch.Tensor], batch_idx: int) -> torch.Tensor:
del batch_idx
features = torch.stack((batch["feature_a"], batch["feature_b"]), dim=1).float()
labels = batch["label"]
loss = self.loss_function(self(features), labels)
self.log("train_loss", loss)
return loss
def configure_optimizers(self) -> torch.optim.Optimizer:
return torch.optim.AdamW(self.parameters(), lr=self.learning_rate)
trainer = lightning.Trainer(max_epochs=10)
trainer.fit(Classifier(), datamodule=EventsDataModule())
Examples
See examples and notebooks for more usage examples.
Docs
uv run mkdocs build -f ./mkdocs.yml -d ./_build/
Update template
copier update --trust -A --vcs-ref=HEAD
Credits
- Thanks for deltatorch for inspiration and code
Metadata
Release files for lit-deltalake 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lit_deltalake-0.0.1.tar.gz | 17.7 kB | Without provenance | Details for lit_deltalake-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lit_deltalake-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for lit_deltalake-0.0.1-py3-none-any.whl |
Total release size: 41.6 kB
Release files / lit_deltalake-0.0.1.tar.gz
| Download URL | lit_deltalake-0.0.1.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20e1bb6b9cc83a6a41aafbbd27642276a9bf224e5c7ad20dcc458d258f88a3d4
|
|
BLAKE2b-256 checksum How to use checksums |
549c158dbd85a37235f718af797986899d8d07ff4b4ca9ae68ac61b6c477af39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / lit_deltalake-0.0.1-py3-none-any.whl
| Download URL | lit_deltalake-0.0.1-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d835c3bec60128b741165b83a462762df30190a6cd8934cc87af2260036dd0ec
|
|
BLAKE2b-256 checksum How to use checksums |
d272952ebdfbb08f5757620bbf9775da04be621936f94ea8b0dca36669a68c9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for lit-deltalake 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.