Datasets¶
Describing the data you have, and reading it back without a pipeline. The guide covers these in Working with Datasets.
Public IO API: datasets, the in-memory shard primitive, and store options.
Configure store behavior via Pipeline.options(io_options=StoreOptions(...)).
- class ArrowOptions(cpu_threads=_NotSupplied.TOKEN, io_threads=_NotSupplied.TOKEN)[source]¶
Bases:
objectProcess-wide Arrow CPU and I/O pool sizes, shared by all Arrow readers.
Counts default to one. Explicit
Noneleaves that pool unchanged. Configuring another store in the same process affects existing readers too.- classmethod from_any(obj)[source]¶
Normalize Arrow pool options without importing PyArrow.
- Return type:
- class CacheOptions(enabled=_NotSupplied.TOKEN, root=_NotSupplied.TOKEN, limit_bytes=_NotSupplied.TOKEN, rg_cache_bytes=_NotSupplied.TOKEN, keep_zip=_NotSupplied.TOKEN, validate_hash=_NotSupplied.TOKEN, download_retry=_NotSupplied.TOKEN, download_timeout=_NotSupplied.TOKEN, open_retry_attempts=_NotSupplied.TOKEN, open_retry_initial_backoff=_NotSupplied.TOKEN, open_retry_max_backoff=_NotSupplied.TOKEN, min_slack_bytes=_NotSupplied.TOKEN, max_slack_bytes=_NotSupplied.TOKEN)[source]¶
Bases:
objectOn-disk shard-cache configuration.
- class Dataset(name, backend, path=None, _ids=None, _counts=None)[source]¶
Bases:
objectDescriptor for a dataset with index and backend info.
Instances are created via
from_path(file-backed) orfrom_dict(in-memory/testing). They always provide:name: a user-facing identifier used in mixturesbackend: opaque metadata that lets FetchOp build a reader laterpath: original filesystem path if file-backed, otherwiseNone
File-backed datasets also carry a few-KB handle to the node-local shard catalog (set by
from_path); this is what travels in ctx, notshard_meta.Shard counts are not stored as a mapping; read them via
ids()/counts()/total()/max_count()/shard_count().Backend kinds used by the internal store builder:
litdata/mds/jsonl/parquet/vortex:kindandpath(no per-shardshardsgraph — that lives in the catalog now)inmem:kindandshards(dict[int, InMemoryShard])
Note: this class does not expose any method to fetch rows; IO is delegated to an internal shard store owned by the FetchOp.
- raw_bytes()[source]¶
Return per-shard byte sizes (
int64), aligned withids().File-backed datasets read the catalog’s on-disk shard sizes; in-memory shards size their resident payloads lazily (
InMemoryShard.raw_bytes).- Return type:
- classmethod from_path(name, path, *, fmt=None)[source]¶
Construct a file-backed dataset descriptor.
Performs a count-only discovery: it obtains
shard_id+num_rowsas small numpy arrays (the work source’s input) without materializing the per-shardshard_metagraph. The full columnar catalog is built once per node later, by the Engine’sfinalize()(or lazily by the store builder for Engine-less use).- Parameters:
- Return type:
Supported formats:
litdatadirectories containingindex.jsonstructured withconfigandchunksmdsdirectories containingindex.jsonstructured withshardsjsonldirectories where*.jsonlfiles act as shards, with an optional Zephonindex.jsonfor fast discovery
Special URI schemes:
hf://org/name[@rev]/[config/]splitis served through the HuggingFace backend: the split’s uploaded files when their format is readable, else HuggingFace’s Parquet conversion when it is complete and built from the requested commit.fmtpicks the source in that format; appending~originalor~parquetto the revision (hf://org/name@~parquet/split) forces one. A partial conversion is used only withZEPHON_HF_ALLOW_PARTIAL=1. Uploaded files are read as stored: the dataset card’s reader options andfeaturescasting are not applied. The dataset’spathbecomes a URI pinned to the resolved commit, source and config.
- Returns:
a descriptor populated with shard counts and a catalog handle for later IO.
- Return type:
- Raises:
FileNotFoundError – if
pathdoes not exist.ValueError – if
pathis not a directory or format unsupported.
- class InMemoryShard(rows)[source]¶
Bases:
objectList-backed shard useful for tests and quickstarts.
- class ParquetOptions(use_threads=_NotSupplied.TOKEN, rg_cache=<factory>)[source]¶
Bases:
objectParquet read behavior and the node-shared decoded row-group cache.
use_threadsenables parallel column decoding through Arrow’s CPU pool. False keeps each read on its calling thread; separate fetches can still decode concurrently. Pool sizes are configured separately in ArrowOptions.- rg_cache: ParquetRGCacheOptions¶
- class ParquetRGCacheOptions(enabled=_NotSupplied.TOKEN, root=_NotSupplied.TOKEN, limit_bytes=_NotSupplied.TOKEN, min_free_bytes=_NotSupplied.TOKEN)[source]¶
Bases:
objectNode-shared decoded Parquet row-group cache configuration.
enabled=Noneenables the cache with the shard cache or an explicitroot. An omitted root uses the shard cache’s reserved.parquet-rg-cachechild. An omitted limit uses the deprecated shard option when present, otherwise the larger of 4 GiB and 10% of the shard cache limit. These defaults resolve when the store is built so option merges retain the distinction between omitted and explicit values. ExplicitNoneresets a previously supplied field to its automatic default.
- class StoreOptions(cache=<factory>, arrow=<factory>, parquet=<factory>, vortex=<factory>, metadata_cache_entries=_NotSupplied.TOKEN)[source]¶
Bases:
objectTop-level IO store options passed to FetchOp.
metadata_cache_entriesbounds retained footers per format and fetch replica, independently of the on-disk shard cache; zero disables retention. Parquet footer sizes grow with the number of columns and row groups.- cache: CacheOptions¶
- arrow: ArrowOptions¶
- parquet: ParquetOptions¶
- vortex: VortexOptions¶
- resolved_parquet_rg_cache()[source]¶
Resolve decoded-cache defaults against the shard-cache options.
- Return type:
- class VortexOptions(segment_cache_bytes=_NotSupplied.TOKEN, worker_threads=_NotSupplied.TOKEN)[source]¶
Bases:
objectVortex read-cache and process-wide worker-pool configuration.
segment_cache_bytessets the encoded-segment cache’s target size per fetch replica. Zero disables it. The target is not a strict memory bound.worker_threadsdefaults to one background worker; calling fetch threads can also execute Vortex work. Zero disables background workers, and explicit None leaves the pool unchanged. An explicit count overrides VORTEX_MAX_THREADS; an omitted count respects that environment variable. Stores in one process share the pool, so the last applied count wins.- classmethod from_any(obj)[source]¶
Normalize Vortex options, accepting byte sizes such as
'64mb'.- Return type:
Inspecting a dataset¶
- class DatasetInspector(dataset, *, io_options=None)[source]¶
Bases:
objectInspect raw payloads from one dataset without a work source or pipeline.
This utility is intended for interactive inspection and dataset validation. It does not choose sample order, add record metadata, prefetch, batch, or run workers. Training pipelines should continue to use
zephon.Pipeline.Use inspectors as context managers so opened shard resources are closed promptly. An inspector is single-process and not thread-safe.
- read(shard_id, sample_index)[source]¶
Return one raw payload identified by its shard and local row index.
- Parameters:
- Returns:
The payload stored by the underlying format. Payloads are normally mappings, but binary formats may return arrays or other supported payload values.
- Return type:
bytes | memoryview | str | int | float | complex | Any | None | list[SamplePayload] | dict[Any, SamplePayload]
- read_many(shard_id, sample_indices)[source]¶
Return raw payloads for local row indices from one shard.
The returned list preserves the order of
sample_indices. Supplying an empty list performs no I/O and returns an empty list.- Return type:
list[bytes | memoryview | str | int | float | complex | Any | None | list[bytes | memoryview | str | int | float | complex | Any | None | list[SamplePayload] | dict[Any, SamplePayload]] | dict[Any, bytes | memoryview | str | int | float | complex | Any | None | list[SamplePayload] | dict[Any, SamplePayload]]]