lenskit.pipeline.config#

Pydantic models for pipeline configuration and serialization support.

Functions

hash_config(config)

Compute the hash of a configuration model.

Classes

PipelineComponent(*, code[, config, inputs])

Specification of a pipeline component.

PipelineConfig(*[, options, inputs, ...])

Root type for serialized pipeline configuration.

PipelineHook(*, function[, priority])

A single entry in a pipeline's hook configuration.

PipelineHooks(*[, run])

Hook specifications for a pipeline.

PipelineInput(*, name, types)

Spcification of a pipeline input.

PipelineLiteral(*, encoding, value)

Literal nodes represented in the pipeline.

PipelineMeta(*[, name, version, hash])

Pipeline metadata.

PipelineOptions(*[, base, default_length, ...])

Options used for pipeline assembly, particularly for extending pipelines.

class lenskit.pipeline.config.PipelineHook(*, function, priority=1)#

Bases: BaseModel

A single entry in a pipeline’s hook configuration.

Parameters:
  • function (str)

  • priority (Annotated[int, Predicate(func=~lenskit.pipeline.config.<lambda>)])

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class lenskit.pipeline.config.PipelineHooks(*, run={})#

Bases: BaseModel

Hook specifications for a pipeline.

Parameters:

run (dict[str, list[PipelineHook]])

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class lenskit.pipeline.config.PipelineOptions(*, base=None, default_length=None, fallback_predictor=None, **extra_data)#

Bases: BaseModel

Options used for pipeline assembly, particularly for extending pipelines.

Parameters:
  • base (str | None)

  • default_length (int | None)

  • fallback_predictor (bool | None)

  • extra_data (Any)

base: str | 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#

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

model_config = {'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class lenskit.pipeline.config.PipelineConfig(**data)#

Bases: 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).
Parameters:
options: PipelineOptions | None#

Options for assembling the final pipeline.

meta: PipelineMeta#

Pipeline metadata.

inputs: list[PipelineInput]#

Pipeline inputs.

components: OrderedDict[str, PipelineComponent]#

Pipeline components, with their configurations and wiring.

aliases: dict[str, str]#

Pipeline node aliases.

default: str | 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, JsonValue]])

Return type:

PipelineConfig

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class lenskit.pipeline.config.PipelineMeta(*, name=None, version=None, hash=None)#

Bases: BaseModel

Pipeline metadata.

Stability:
Full (see Stability Levels).
Parameters:
  • name (str | None)

  • version (str | None)

  • hash (str | None)

name: str | None#

The pipeline name.

version: str | None#

The pipeline version.

hash: str | None#

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

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class lenskit.pipeline.config.PipelineInput(*, name, types)#

Bases: BaseModel

Spcification of a pipeline input.

Stability:
Full (see Stability Levels).
Parameters:
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str#

The name for this input.

types: set[str] | None#

The list of types for this input.

class lenskit.pipeline.config.PipelineComponent(*, code, config=None, inputs={})#

Bases: BaseModel

Specification of a pipeline component.

Parameters:
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

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, JsonValue] | 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.

class lenskit.pipeline.config.PipelineLiteral(*, encoding, value)#

Bases: BaseModel

Literal nodes represented in the pipeline.

Stability:
Full (see Stability Levels).
Parameters:
  • encoding (Literal['json', 'base85'])

  • value (JsonValue)

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

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 (BaseModel)

Return type:

str