Skip to main content

PreparedDataset

Struct PreparedDataset 

Source
pub struct PreparedDataset<P: DatasetProfile> { /* private fields */ }
Expand description

A validated, fingerprinted dataset of exactly one profile.

Implementations§

Source§

impl PreparedDataset<Canonical>

Source

pub fn from_labeled_rows( train: Vec<LabeledExample>, validation: Vec<LabeledExample>, test: Vec<LabeledExample>, decls: &CanonicalDeclarations, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>

Ingest three typed split row sets under the canonical profile.

The CLI has already decoded its dataset-specific source format into typed rows — D-05 keeps paired *_text.txt / *_labels.txt decoding on the CLI side, so this crate never sees a dataset-specific format and never touches a byte it was not handed.

Ordering matters twice, and both orders are ascending by role name because that is what DatasetFingerprint::compute debug-asserts: the fingerprint inputs and the dedup inputs. The ledger, by contrast, records in INGEST order (train, validation, test), because a log of what happened should read in the order it happened.

§Errors

Any gate-ladder variant from the split boundary. Nothing is recorded in the ledger on the failing path: a dataset that was rejected was never accessed.

Source

pub fn label_names(&self) -> &[String]

The declared label map, in label order.

Source

pub fn train(&self) -> &Split<Train>

The training split — the only selection pool.

Source

pub fn validation(&self) -> &Split<Validation>

The validation split.

Source

pub fn test(&self) -> &Split<Test>

The held-out test split.

Source

pub fn validation_witness(&self) -> ValidationWitness<'_>

A proof that this dataset has a validation split.

This method exists only on the canonical type. Its absence on PreparedDataset<Compatibility> is DATA-06’s compile-time gate:

ⓘ
use aprender_contrastive_data::prepared::{Compatibility, PreparedDataset};

fn take_witness(dataset: &PreparedDataset<Compatibility>) {
    let _ = dataset.validation_witness();
}

The same call on the canonical type compiles, which is what stops the block above from being green for an unrelated reason:

use aprender_contrastive_data::prepared::{Canonical, PreparedDataset};

fn take_witness(dataset: &PreparedDataset<Canonical>) {
    let _ = dataset.validation_witness();
}
Source

pub fn exclusions(&self) -> &ExclusionRecord

What cross-split duplication removed from the training pool.

Source

pub fn fingerprint(&self) -> &DatasetFingerprint

This dataset’s identity.

Source

pub fn encode_jsonl(&self) -> Result<PreparedJsonl, ContrastiveDataError>

Canonical JSONL bytes per split.

§Errors

ContrastiveDataError::Serialization if a split cannot be re-encoded.

Source§

impl PreparedDataset<Compatibility>

Source

pub fn from_labeled_rows( train: Vec<LabeledExample>, compatibility_test: Vec<LabeledExample>, decls: &CompatibilityDeclarations, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>

Ingest the compatibility profile’s two split row sets.

Selection cannot consume the result:

ⓘ
use aprender_contrastive_data::prepared::{Canonical, Compatibility, PreparedDataset};

fn selection(_dataset: &PreparedDataset<Canonical>) {}

fn call(compatibility: &PreparedDataset<Compatibility>) {
    selection(compatibility);
}

The canonical control, which must compile:

use aprender_contrastive_data::prepared::{Canonical, PreparedDataset};

fn selection(_dataset: &PreparedDataset<Canonical>) {}

fn call(canonical: &PreparedDataset<Canonical>) {
    selection(canonical);
}
§Errors

Any gate-ladder variant from the split boundary.

Source

pub fn label_names(&self) -> &[String]

The declared label map, in label order.

Source

pub fn train(&self) -> &Split<Train>

The training split.

Source

pub fn compatibility_test(&self) -> &Split<CompatibilityTest>

The merged compatibility test split.

Source

pub fn exclusions(&self) -> &ExclusionRecord

What cross-split duplication removed from the training pool.

Source

pub fn fingerprint(&self) -> &DatasetFingerprint

This dataset’s identity.

Source

pub fn encode_jsonl(&self) -> Result<PreparedJsonl, ContrastiveDataError>

Canonical JSONL bytes per split.

§Errors

ContrastiveDataError::Serialization if a split cannot be re-encoded.

Source§

impl PreparedDataset<Canonical>

Source

pub fn from_attested_bytes( attestation_bytes: &[u8], splits: &BTreeMap<String, Vec<u8>>, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>

The canonical profile’s attested boundary.

splits is keyed by split role — exactly the shape crate::prepared::PreparedJsonl::as_map hands back, so from_labeled_rows -> encode_jsonl -> from_attested_bytes is a closed round trip whose two ends must fingerprint identically.

§Errors

ContrastiveDataError::UnsupportedSchemaVersion, ContrastiveDataError::UnsupportedNormalizationVersion, ContrastiveDataError::ProfileMismatch, ContrastiveDataError::ConflictingSourceRole, ContrastiveDataError::MissingSplit, ContrastiveDataError::SplitHashMismatch, any gate-ladder variant (including ContrastiveDataError::InvalidClassCounts when the attested per-class counts disagree with the split contents), ContrastiveDataError::ExclusionRecordMismatch, or ContrastiveDataError::FingerprintMismatch.

Source§

impl PreparedDataset<Compatibility>

Source

pub fn from_attested_bytes( attestation_bytes: &[u8], splits: &BTreeMap<String, Vec<u8>>, ledger: &mut AccessLedger, ) -> Result<Self, ContrastiveDataError>

The compatibility profile’s attested boundary.

A canonical attestation fed here is ContrastiveDataError::ProfileMismatch, and so is a compatibility attestation fed to the canonical constructor. The profile is a type parameter, so the two are separate functions the compiler keeps apart; this check is what stops untrusted BYTES from crossing between them (D-19).

§Errors

The same set as the canonical constructor.

Trait Implementations§

Source§

impl<P: Clone + DatasetProfile> Clone for PreparedDataset<P>
where P::Splits: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + DatasetProfile> Debug for PreparedDataset<P>
where P::Splits: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Eq + DatasetProfile> Eq for PreparedDataset<P>
where P::Splits: Eq,

Source§

impl<P: PartialEq + DatasetProfile> PartialEq for PreparedDataset<P>
where P::Splits: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<P: PartialEq + DatasetProfile> StructuralPartialEq for PreparedDataset<P>
where P::Splits: PartialEq,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.