lenskit.pipeline.config#

Pydantic models for pipeline configuration and serialization support.

Attributes#

Classes#

PipelineHook

A single entry in a pipeline's hook configuration.

PipelineHooks

Hook specifications for a pipeline.

PipelineOptions

Options used for pipeline assembly, particularly for extending pipelines.

PipelineConfig

Root type for serialized pipeline configuration. A pipeline config contains

PipelineMeta

Pipeline metadata.

PipelineInput

Spcification of a pipeline input.

PipelineComponent

Specification of a pipeline component.

PipelineLiteral

Literal nodes represented in the pipeline.

Functions#

check_name(name, *[, what, allow_reserved])

Check that a name is valid.

hash_config(config)

Compute the hash of a configuration model.

Module Contents#

lenskit.pipeline.config.VALID_NAME#
lenskit.pipeline.config.check_name(name, *, what='node', allow_reserved=False)#

Check that a name is valid.

Raises:

ValueError – If the specified name is not valid.

Parameters:
class lenskit.pipeline.config.PipelineHook#

Bases: pydantic.BaseModel

A single entry in a pipeline’s hook configuration.

function: str#
priority: Annotated[int, Predicate(lambda x: x != 0)] = 1#
classmethod from_entry(hook)#
Parameters:

hook (lenskit.pipeline._hooks.HookEntry[Any])

class lenskit.pipeline.config.PipelineHooks#

Bases: pydantic.BaseModel

Hook specifications for a pipeline.

run: dict[str, list[PipelineHook]]#
class lenskit.pipeline.config.PipelineOptions#

Bases: pydantic.BaseModel

Options used for pipeline assembly, particularly for extending pipelines.

base: str | None = None#

Apply this configuration to a base pipeline.

default_length: int | None#

For top-N base pipelines, the default ranking length to configure.

fallback_predictor: bool | None = None#

For rating prediction pipelines, enable or disable the default fallback predictor.

class lenskit.pipeline.config.PipelineConfig#

Bases: pydantic.BaseModel

Root type for serialized pipeline configuration. A pipeline config contains the full configuration, components, and wiring for the pipeline, but does not contain the learned parameters.

Stability:
Full (see Stability Levels).
options: PipelineOptions | None = None#

Options for assembling the final pipeline.

meta: PipelineMeta#

Pipeline metadata.

inputs: list[PipelineInput] = []#

Pipeline inputs.

components: collections.OrderedDict[str, PipelineComponent]#

Pipeline components, with their configurations and wiring.

aliases: dict[str, str]#

Pipeline node aliases.

default: str | None = None#

The default node for running this pipeline.

literals: dict[str, PipelineLiteral]#

Literals

hooks: PipelineHooks#

The hooks configured for the pipeline.

merge_component_configs(configs)#

Merge component configuration options into the pipeline configuration.

This returns a modified copy of the pipeline with the applied configurations, and does not modify the configuration in-place.

Parameters:

configs (Mapping[str, Mapping[str, pydantic.JsonValue]])

Return type:

PipelineConfig

class lenskit.pipeline.config.PipelineMeta#

Bases: pydantic.BaseModel

Pipeline metadata.

Stability:
Full (see Stability Levels).
name: str | None = None#

The pipeline name.

version: str | None = None#

The pipeline version.

hash: str | None = None#

The pipeline configuration hash. This is optional, particularly when hand-crafting pipeline configuration files.

class lenskit.pipeline.config.PipelineInput#

Bases: pydantic.BaseModel

Spcification of a pipeline input.

Stability:
Full (see Stability Levels).
name: str#

The name for this input.

types: set[str] | None#

The list of types for this input.

classmethod from_node(node)#
Parameters:

node (lenskit.pipeline.nodes.InputNode[Any])

Return type:

Self

class lenskit.pipeline.config.PipelineComponent#

Bases: pydantic.BaseModel

Specification of a pipeline component.

code: str#

The path to the component’s implementation, either a class or a function. This is a Python qualified path of the form module:name.

config: Mapping[str, pydantic.JsonValue] | None = None#

The component configuration. If not provided, the component will be created with its default constructor parameters.

inputs: dict[str, str]#

The component’s input wirings, mapping input names to node names. For certain meta-nodes, it is specified as a list instead of a dict.

classmethod from_node(node)#
Parameters:

node (lenskit.pipeline.nodes.ComponentNode[Any])

Return type:

Self

class lenskit.pipeline.config.PipelineLiteral#

Bases: pydantic.BaseModel

Literal nodes represented in the pipeline.

Stability:
Full (see Stability Levels).
encoding: Literal['json', 'base85']#
value: pydantic.JsonValue#
classmethod represent(data)#
Parameters:

data (Any)

Return type:

Self

decode()#

Decode the represented literal.

Return type:

Any

lenskit.pipeline.config.hash_config(config)#

Compute the hash of a configuration model.

Stability:
Internal (see Stability Levels).
Parameters:

config (pydantic.BaseModel)

Return type:

str

Exported Aliases#

exception lenskit.pipeline.config.PipelineError#

Re-exported alias for lenskit.diagnostics.PipelineError.

exception lenskit.pipeline.config.PipelineWarning#

Re-exported alias for lenskit.diagnostics.PipelineWarning.

class lenskit.pipeline.config.HookEntry#

Re-exported alias for lenskit.pipeline._hooks.HookEntry.

lenskit.pipeline.config.make_importable_path()#

Re-exported alias for lenskit.pipeline._types.make_importable_path().

class lenskit.pipeline.config.Component#

Re-exported alias for lenskit.pipeline.components.Component.

class lenskit.pipeline.config.ComponentConstructorNode#

Re-exported alias for lenskit.pipeline.nodes.ComponentConstructorNode.

class lenskit.pipeline.config.ComponentInstanceNode#

Re-exported alias for lenskit.pipeline.nodes.ComponentInstanceNode.

class lenskit.pipeline.config.ComponentNode#

Re-exported alias for lenskit.pipeline.nodes.ComponentNode.

class lenskit.pipeline.config.InputNode#

Re-exported alias for lenskit.pipeline.nodes.InputNode.