lenskit.pipeline.Component#
- class lenskit.pipeline.Component(*args, **kwargs)#
Bases:
Configurable
,Generic
[COut
]Base class for pipeline component objects. Any component that is not just a function should extend this class.
Components are
Configurable
. The base class provides default implementations ofget_config()
andfrom_config()
that inspect the constructor arguments and instance variables to automatically provide configuration support. By default, all constructor parameters will be considered configuration parameters, and their values will be read from instance variables of the same name. Components can also defineEXTRA_CONFIG_FIELDS
andIGNORED_CONFIG_FIELDS
class variables to modify this behavior. Missing attributes are silently ignored.To work as components, derived classes also need to implement a
__call__
method to perform their operations.- __init__(*args, **kwargs)#
Methods
__init__
(*args, **kwargs)from_config
(cfg)Create a class from the specified construction.
Get the configuration by inspecting the constructor and instance variables.
Attributes
Names of instance variables that should be included in the configuration dictionary even though they do not correspond to named constructor arguments.
Names of constructor parameters that should be excluded from the configuration dictionary.
- EXTRA_CONFIG_FIELDS: ClassVar[list[str]] = []#
Names of instance variables that should be included in the configuration dictionary even though they do not correspond to named constructor arguments.
Note
This is rarely needed, and usually needs to be coupled with
**kwargs
in the constructor to make the resulting objects constructible.
- IGNORED_CONFIG_FIELDS: ClassVar[list[str]] = []#
Names of constructor parameters that should be excluded from the configuration dictionary.
- get_config()#
Get the configuration by inspecting the constructor and instance variables.