CorpusPlan#

class scikitplot.corpus.CorpusPlan(fragments=<factory>, stages=None)[source]#

An immutable, canonical description of a corpus configuration.

Parameters:
fragmentsdict

Mapping of domain name to configuration fragment.

stagestuple of str or None, optional

Explicit pipeline stage order. None means DEFAULT_STAGES.

Parameters:

Notes

Developer. fragments is stored sorted by domain, so two plans built by different call orders are equal rather than merely equivalent. That is what makes order-independence checkable rather than aspirational.

property configured: list[str]#

Domains that have been configured, in canonical order.

property effective_stages: tuple[str, ...]#

Stage order this plan will execute in.

property fingerprint: str#

Stable content-derived identifier for this configuration.

Raises:
scikitplot._utils._canonical.CanonicalError

If a fragment holds a value with no deterministic encoding. The message names the fragment and the field.

Notes

Developer. Two plans built by different call orders share a fingerprint; two plans differing in any fragment do not. A config change that moves this value is exactly a change that should invalidate a built index.

The derivation is scikitplot._utils._canonical.canonical_digest, the one encoding every identity in this package uses, so a plan, an embedding generation and a build generation cannot disagree about what two equal configurations are. It replaced a repr-based derivation that was not stable across interpreters: a fragment holding a plain object or a set of strings fingerprinted differently in a second process, which makes a persisted cache key unsound.

The full SHA-256 is returned. Use short_fingerprint for display.

fragments: dict[str, Any][source]#
get(domain)[source]#

Return the fragment for domain, or None.

Parameters:

domain (str)

Return type:

Any

property ingest_fingerprint: str#

Identity of everything that decides what this plan builds.

Notes

User. This is the value an artifact binds. If it is unchanged, a previously built index is still valid for this plan, however the retrieval configuration has moved.

Developer. Covers INGEST_DOMAINS and the effective stage order, which changes what is produced rather than how it is read.

classmethod of(**fragments)[source]#

Build a plan from keyword fragments.

Raises:
ValueError

If a keyword is not a known configuration domain.

Parameters:

fragments (Any)

Return type:

CorpusPlan

property query_fingerprint: str#

Identity of everything that decides how a build is queried.

Notes

Developer. Covers QUERY_DOMAINS. A change here never invalidates an artifact; it is separated so that a cache keyed on the build cannot be discarded by a query-time edit.

property short_fingerprint: str#

First 16 characters of fingerprint, for display only.

Notes

Developer. Never persist this or use it as a key. The full digest is the identity; a prefix narrows the collision bound for no benefit the storage layer needs.

stages: tuple[str, ...] | None = None#
to_dict()[source]#

Return a JSON-compatible description of the plan.

Return type:

dict[str, Any]

validate()[source]#

Check cross-fragment coherence.

Returns:
list of ErrorRecord

Empty when the plan is coherent. Records rather than exceptions, so a caller sees every problem in one pass.

Return type:

list[ErrorRecord]

Notes

This is phase 2 validation: fragment-level schema errors are raised at fragment construction, and capability errors (is this backend actually installed?) are deferred to build time. Nothing here touches the network or loads a model.