Spec

Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

class Spec(name: str, params: ~typing.Mapping[str, ~typing.Any] = <factory>, version: str = '1.0')[source]

Bases: object

Specification of ONE pluggable component.

name

Registered component name, e.g. "slic".

Type:

str

params

Constructor parameters. Defaults live in the component classes themselves so a spec only records deviations.

Type:

Mapping[str, Any]

version

Specification schema version, reserved for future migrations.

Type:

str

__post_init__() → None[source]

Normalise the parameter mapping into an immutable plain dict.

fingerprint() → str[source]

Return a stable hash identifying this exact specification.

Two runs with equal fingerprints are scientifically comparable; caching and provenance key on it.

Returns:

Hex digest of the canonical payload.

to_dict() → Dict[str, Any][source]

Serialise to a plain dict (YAML/JSON isomorphic).

classmethod from_dict(payload: Mapping[str, Any]) → Spec[source]

Rebuild a spec from its dict form.

Parameters:

payload – Mapping with name and optional params / version.

Returns:

The reconstructed spec.

Raises:

HABITAPIError – If name is missing.

__init__(name: str, params: ~typing.Mapping[str, ~typing.Any] = <factory>, version: str = '1.0') → None

Examples using habit.spec.Spec

Quickstart: Python API

Quickstart: Python API