Module - Tasks are defined within modules¶
- class manta.module.Module(python_program: str | Path, image: str, method: str = 'any', fixed: bool = False, excepted_ids: list | None = None, specified_ids: list | None = None, maximum: int | float | None = None, alias: str | None = None, network_name: str | None = None, gpu: bool = False)¶
Class which holds the description of a task
- Parameters:
python_program (Union[str, Path]) – Python program code
image (str) – Image name of the container in which the program will be executed
method (str) – Currently, only
"any"
is availablefixed (bool) – If
True
, the chosen nodes must remain the same over the execution of theSwarm
excepted_ids (Optional[list]) – List of ids that must not be chosen for this module
specified_ids (Optional[list]) – List of ids that must be chosen for this module
maximum (Optional[Union[int, float]]) – Maximum of ids that can be chosen for this module. If it is a float, it is a percentage between
0.0
and1.0
gpu (bool) – If
True
, the module will be executed on GPU
- kernel¶
Description of a task
- Type:
ModuleKernel
Examples
>>> aggregator = Module( ... python_program="modules/aggregator.py", ... image="manta-demo:latest", ... method="any", ... fixed=False, ... maximum=1, ... alias="aggregator", ... )
- __call__(module: List[Module | ModuleID] | Module | ModuleID | None = None, condition: Condition = Condition.FINISHED) ModuleID ¶
Transform itself into a
ModuleID
and update its own graph- Parameters:
module (Optional[Union[List[ModuleLike], ModuleLike]]) – One or multiple modules to connect with itself
condition (Condition) – Condition which tells to the Manager when next task should be executed
- Returns:
Module ID with its graph updated given arguments
- Return type:
Examples
>>> aggregator = Module( ... "modules/aggregator.py", ... "manta-demo:latest", ... ) >>> worker = Module("modules/worker", "manta-demo:latest") >>> m = aggregator(worker) # start worker and follow by aggregator >>> isinstance(aggregator, Module) # True >>> isinstance(worker, Module) # True >>> isinstance(m, ModuleID) # True
- class manta.module.ModuleID(graph: Graph | None = None)¶
Unique class associated with an ID which helps to connect module
- Parameters:
graph (Optional[Graph]) – Graph of the module
- graph¶
Hold the connectivity with previous modules
- Type:
Graph
- uuid¶
ID of the module
- Type:
UUID
- __call__(module: List[Module | ModuleID] | Module | ModuleID | None = None, condition: Condition = Condition.FINISHED) ModuleID ¶
Update its own graph
- Parameters:
module (Optional[Union[List[ModuleLike], ModuleLike]) – One or multiple modules to connect with itself
condition (Condition) – Condition which tells to the Manager when next task should be executed
- Returns:
Return itself
- Return type:
Notes
It has the same behavior as
Module.__call__