poprox_recommender.lkpipeline.components#
Definition of the component interfaces.
Functions
|
Classes
|
Base class for pipeline component objects. |
|
Interface for configurable objects such as pipeline components with settings or hyperparameters. |
- class poprox_recommender.lkpipeline.components.Configurable(*args, **kwargs)#
Bases:
Protocol
Interface for configurable objects such as pipeline components with settings or hyperparameters. A configurable object supports two operations:
saving its configuration with
get_config()
.creating a new instance from a saved configuration with the class method
from_config()
.
An object must implement both of these methods to be considered configurable. Components extending the
Component
class automatically have working versions of these methods if they define their constructor parameters and fields appropriately.Note
Configuration data should be JSON-compatible (strings, numbers, etc.).
- classmethod from_config(cfg)#
Reinstantiate this component from configuration values.
- class poprox_recommender.lkpipeline.components.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.- 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.