bridge.data.sources.hf#
Declarative Hugging Face sources, named presets, and shared normalization.
Module Contents#
Classes#
Serializable source selection for one Hugging Face dataset split. |
|
Resolved physical source metadata for a built-in dataset. |
Functions#
Return whether a declarative |
|
Return whether a source declares support for a logical split. |
|
Resolve a named preset or custom source to complete physical metadata. |
|
Load one declarative Hugging Face source without adapting its rows. |
|
Materialize Hugging Face caches once before distributed readers start. |
|
Load a Hugging Face split and normalize it to canonical SFT rows. |
Data#
API#
- bridge.data.sources.hf._has_unset_data_file(value: Any) bool#
Return whether a declarative
data_filesvalue contains no usable path.
- class bridge.data.sources.hf.HFDatasetSourceConfig#
Serializable source selection for one Hugging Face dataset split.
Exactly one source mode is required.
dataset_nameselects a built-in dataset preset that owns its Hub path, subset, and schema adapter.path_or_datasetselects a custom source;schema_adapteris optional when its rows already match the selected chat or prompt-completion preprocessing schema.- dataset_name: str | None#
None
- path_or_dataset: str | None#
None
- split: str | None#
None
- subset: str | list[str] | None#
None
- load_kwargs: dict[str, Any] | None#
None
- schema_adapter: str | None#
None
- adapter_kwargs: dict[str, Any] | None#
None
- validate() None#
Validate declarative source and adapter settings.
- with_split(split: str) bridge.data.sources.hf.HFDatasetSourceConfig#
Return a copy selecting another split expression.
- class bridge.data.sources.hf._HFDatasetPreset#
Resolved physical source metadata for a built-in dataset.
- path_or_dataset: str#
None
- schema_adapter: str | None#
None
- split: str#
‘train’
- subset: str | list[str] | None#
None
- load_kwargs: dict[str, Any] | None#
None
- adapter_kwargs: dict[str, Any] | None#
None
- required_adapter_kwargs: tuple[str, ...]#
()
- split_aliases: dict[str, str] | None#
None
- supported_splits: tuple[str, ...] | None#
None
- bridge.data.sources.hf._HF_DATASET_PRESETS: dict[str, bridge.data.sources.hf._HFDatasetPreset]#
None
- bridge.data.sources.hf._resolve_preset_split(
- dataset_name: str,
- preset: bridge.data.sources.hf._HFDatasetPreset,
- split: str,
- bridge.data.sources.hf.hf_dataset_supports_split(
- source: bridge.data.sources.hf.HFDatasetSourceConfig,
- split: str,
Return whether a source declares support for a logical split.
- bridge.data.sources.hf.resolve_hf_dataset_source( ) bridge.data.sources.hf.HFDatasetSourceConfig#
Resolve a named preset or custom source to complete physical metadata.
- bridge.data.sources.hf.load_hf_dataset_source( ) Any#
Load one declarative Hugging Face source without adapting its rows.
- bridge.data.sources.hf.prepare_hf_dataset_sources(
- sources: collections.abc.Sequence[bridge.data.sources.hf.HFDatasetSourceConfig],
Materialize Hugging Face caches once before distributed readers start.
Hugging Face cache creation is not reliable when multiple distributed ranks concurrently build the same source on a shared filesystem. Rank zero loads each requested source first, then broadcasts completion so every rank reads an already-stable cache. Single-process callers need no preparation because their normal load has no competing writer.
- bridge.data.sources.hf.load_and_adapt_hf_dataset( ) list[dict[str, Any]]#
Load a Hugging Face split and normalize it to canonical SFT rows.