Compute Plan Builder¶
- class substrafl.compute_plan_builder.ComputePlanBuilder(*args, **kwargs)¶
Bases:
abc.ABC
Base compute plan builder to be inherited from SubstraFL compute plans.
All child class arguments need to be passed to it through its
args
andkwargs
in order to use them when instantiating it as a RemoteStruct in each process.Example
class MyComputePlan(ComputePlanBuilder): def __init__(self, custom_arg, my_custom_kwargs="value"): super().__init__(custom_arg, my_custom_kwargs=my_custom_kwargs)
- abstract build_compute_plan(train_data_nodes: Optional[List[substrafl.nodes.train_data_node.TrainDataNode]], aggregation_node: Optional[List[organizations.aggregation_node.AggregationNode]], evaluation_strategy: Optional[substrafl.evaluation_strategy.EvaluationStrategy], num_rounds: Optional[int], clean_models: Optional[bool] = True) None ¶
Build the compute plan to be executed. All arguments are optional and will be feed within the
execute_experiment()
function.- Parameters
train_data_nodes (List[TrainDataNode]) – list of the train organizations
aggregation_node (Optional[AggregationNode]) – aggregation node, necessary for centralized strategy, unused otherwise
evaluation_strategy (Optional[EvaluationStrategy]) – evaluation strategy to follow for testing models.
num_rounds (int) – Number of times to repeat the compute plan sub-graph (define in perform round). It is useful in recurring graphs, but can be ignored in other cases.
clean_models (bool) – Clean the intermediary models on the Substra platform. Set it to False if you want to download or re-use intermediary models. This causes the disk space to fill quickly so should be set to True unless needed. Defaults to True.
- Returns
None
- Return type
None
- abstract load_local_state(path: pathlib.Path) Any ¶
Executed at the beginning of each step of the computation graph to load on each organization the previously saved local state.
- Parameters
path (pathlib.Path) – The path where the previous local state has been saved.
- Returns
The loaded element.
- Return type
- abstract save_local_state(path: pathlib.Path) None ¶
Executed at the end of each step of the computation graph to save the local state locally on each organization.
- Parameters
path (pathlib.Path) – The path where the previous local state has been saved.
- Returns
None
- Return type
None