Refactor `FederatedServer` and `FederatedClient` code.
This Merge Request implements a number of revisions to the declearn.main
submodule and most importantly to the FederatedClient
and FederatedServer
classes, that aim at making the code easier to read, maintain, test and override, as well as making it more end-user-friendly.
Most of these changes were first implemented on a working branch as part of the effort towards implementing Differential Privacy in declearn (see MR !11 (merged)). A combination of git cherry-picking and of further implementation efforts were used to make up the current MR, that paves the way towards merging the already-developed local DP features within the revised code.
Summary of the modifications implemented here:
-
Implement some automation tools to wrap up configurations:
- Add a generic
TomlConfig
ABC, that enables writing heavy parameter containers and parsing TOML files. - Add some generic dataclass-generation tools.
- Add a generic
-
Revise
FederatedServer
:- Implement
FLRunConfig
based onTomlConfig
, that wraps together server-side "run" method parameters. - Move the former as well as existing server-oriented dataclasses to the new
declearn.main.config
submodule. - Have initialization make use of the full config, while training and evaluation only access their own section.
- Clean up some backend code regarding client results' collection, to improve readability and reduce redundancy.
- Implement
-
Revise
FederatedClient
:- Split out the training and evaluation routines into a new
TrainingManager
class (underdeclearn.main.utils
). - Write some unit tests on the former class, that are designed to verify that effort constraints work properly.
- Fix a bug where using
epochs=None, steps=...
training constraints would result in an infinite loop.
- Split out the training and evaluation routines into a new