ModuleMix#
- class ModuleMix(*args, **kwargs)#
-
A module containing multiple other modules.
This can allow to combine modules to collect different sources, write multiple time in different manners, etc.
This is an abstract class and should be used as a base for creating specific mixes. This abstract class initialize every module in the mix. Mixes are intended to be instantiated with the class method
create().- Parameters:
args (Any)
kwargs (Any)
- T_Self = ~T_Self#
- apply(method: str, all: Literal[True], *args: Any, select: dict[str, Any] | None = None, **kwargs: Any) list[Any]#
- apply(method: str, all: Literal[False], *args: Any, select: dict[str, Any] | None = None, **kwargs: Any) Any
- apply(method: str, all: bool, *args: Any, select: dict[str, Any] | None = None, **kwargs: Any) Any | list[Any]
Get results from all or one of the base modules.
- Parameters:
method – Method name to run
all – If True, return results from all modules, otherwise only from a selected one.
args – Passed to the method
kwargs – Passed to the method
select – Mapping of parameters passed to the selection function.
- apply_all(method, *args, **kwargs)#
Get results from every base module.
Every output is put in a list if not already.
- apply_select(method, *args, select=None, **kwargs)#
Get result from a single base module.
Module is selected with
select_func, based on current module and data-manager state.
- classmethod create(bases, select_func=None)#
Create a new mix-class from base module.
- bases
Module types to mix.
- select_func
Function to select one of the base module depending on the current module state, and data-manager parameters. It receives the instance of the module mix and additional kwargs, and must return the class-name of one of the base module.
- select(**kwargs)#
Return the module to select under current module and data-manager state.
- Parameters:
kwargs (Any) – Will be passed to the selection function.
- Return type:
T_Mod
- classmethod set_select(select_func)#
Set the selection function.
- select_func
Function to select one of the base module depending on the current module state, and data-manager parameters. It receives the instance of the module mix and additional kwargs, and must return the class-name of one of the base module.
- Parameters:
select_func (Callable[..., str])
- Return type:
None
- setup()#
Set up all base modules.
- Return type:
None