lenskit.pipeline.Lazy#

class lenskit.pipeline.Lazy(*args, **kwargs)#

Bases: Protocol, Generic[T]

Type for accepting lazy inputs from the pipeline runner. If your function may or may not need one of its inputs, declare the type with this to only run it as needed:

def my_component(input: str, backup: Lazy[str]) -> str:
    if input == 'invalid':
        return backup.get()
    else:
        return input
Stability:
Caller (see Stability Levels).
__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

get()

Get the value behind this lazy instance.

get()#

Get the value behind this lazy instance.

Note

As this method invokes upstream components if they have not yet been run, it may fail if one of the required components fails or pipeline data checks fail.

Raises:
  • Exception – Any exception raised by the component(s) needed to supply the lazy value may be raised when this method is called.

  • SkipComponent – Internal exception raised to indicate that no value is available and the calling component should be skipped. Components generally do not need to handle this directly, as it is used to signal the pipeline runner.

Return type:

T