To use a model that has been trained on Substra, you need to first download the files with the
These files are used to re-instantiate and load all variables to retrieve the Substra Algo in its wanted state by the
An example on how to download a model is available in the MNIST Substrafl FedAvg example.
- substrafl.model_loading.download_algo_files(client: substra.sdk.client.Client, compute_plan_key: str, dest_folder: os.PathLike, round_idx: Optional[int] = None)¶
Download all the files needed to load the model:
hosted on the client organization
being part of the given compute plan
being the result of the associated strategy after round_idx steps
Those files are:
the algorithm used for this task
the output local state of the task
This function supports only strategies with one composite traintask for a given organization and round.
client (substra.Client) – Substra client where to fetch the model from.
compute_plan_key (str) – Compute plan key to fetch the model from.
dest_folder (os.PathLike) – Folder where to download the files.
round_idx (Optional[int], None) – Round of the strategy to fetch the model from. If set to
None, the last round will be used. (Default to None).
TrainTaskNotFoundError – If no composite matches the given requirements.
MultipleTrainTaskError – The experiment to get the model from can’t have multiple TrainDataNodes hosted on the same organization. In practice this means the presence of multiple composite train tasks with the same round number on the same rank.
UnfinishedTrainTaskError – The task from which the files are trying to be downloaded is not done.
- substrafl.model_loading.load_algo(input_folder: os.PathLike) Any ¶
Loads an algo from a specified folder. This folder should contains:
the file specified in metadata.local_state_file
This kind of folder can be generated with the
input_folder (os.PathLike) – Path to folder containing the required files.
The serialized algo within the input_folder
- Return type