This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XP-456: replace the CLI arguments with a config file
Cc: finiteprods <kwok.doc@gmail.com> Cc: Robert Steiner <robertt.debug@gmail.com> Cc: janpetschexain <58227040+janpetschexain@users.noreply.github.com> References ========== https://xainag.atlassian.net/browse/XP-456 https://xainag.atlassian.net/browse/DO-58 Rationale ========= The CLI is getting complex so it is worth loading the configuration from a file instead. Implementation details ====================== TOML ---- We decided to use TOML for the following reasons: - it is human friendly, ie easy to read and write - our configuration has a pretty flat structure which makes TOML quite adapted - it is well specified and has lots of implementation - it is well known The other options we considered: - INI: it is quite frequent in the Python ecosystem to use INI for config files, and the standard library even provides support for this. However, INI is not as powerful as TOML and does not have a specification - JSON: it is very popular but is not human friendly. For instance, it does not support comments, is very verbose, and breaks easily (if a trailing comma is forgotten at the end of a list for instance) - YAML: another popular choice, but is in my opinion more complex than TOML. Validation ---------- We use the third-party `schema` library to validate the configuration. It provides a convenient way to: - declare a schema to validate our config - leverage third-party libraries to validate some inputs (we use the `idna` library to validate hostnames) - define our own validators - transform data after it has been validated: this can be useful to turn a relative path into an absolute one for example - provide user friendly error message when the configuration is invalid The `Config` class ------------------ By default, the `schema` library returns a dictionary containing a valid configuration, but that is not convenient to manipulate in Python. Therefore, we dynamically create a `Config` class from the configuration schema, and instantiate a `Config` object from the data returned by the `schema` validator. Package re-organization ----------------------- We moved the command line and config file logic into its own `config` sub-package, and moved the former `xain_fl.cli.main` entrypoint into the `xain_fl.__main__` module. Docker infrastructure --------------------- - Cache the xain_fl dependencies. This considerably reduces "edit->build-> debug" cycle, since installing the dependencies takes about 30 minutes. - Move all the docker related files into the `docker/` directory Current limitations and future work ----------------------------------- 1. The documentation generated for the `ServerConfig`, `AiConfig` and `StorageConfig` classes is wrong. Each attribute is documented as "Alias for field number X". This can be fixed by having `create_class_from_schema()` setting the `__doc__` attribute for each attribute. However, we won't be able to automatically document the type of each attribute. 2. When the configuration contains an invalid value, the error message we generate does not contain the invalid value in question. I think it is possible to enable this in the future but haven't really looked into it.
- Loading branch information
1 parent
8b3e765
commit 5a60096
Showing
16 changed files
with
777 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[server] | ||
# Address to listen on for incoming gRPC connections | ||
host = "0.0.0.0" | ||
# Port to listen on for incoming gRPC connections | ||
port = 50051 | ||
|
||
[ai] | ||
# Path to a file containing a numpy ndarray to use a initial model weights. | ||
initial_weights = "/initial_weights.npy" | ||
# Number of global rounds the model is going to be trained for. This | ||
# must be a positive integer. | ||
rounds = 1 | ||
# Number of local epochs per round | ||
epochs = 1 | ||
# Minimum number of participants to be selected for a round. | ||
min_participants = 1 | ||
# Fraction of total clients that participate in a training round. This | ||
# must be a float between 0 and 1. | ||
fraction_participants = 1.0 | ||
|
||
[storage] | ||
# URL to the storage service to use | ||
endpoint = "http://minio-dev:9000" | ||
# Name of the bucket for storing the aggregated models | ||
bucket = "xain-fl-aggregated-weights" | ||
# AWS access key ID to use to authenticate to the storage service | ||
access_key_id = "minio" | ||
# AWS secret access to use to authenticate to the storage service | ||
secret_access_key = "minio123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[server] | ||
# Address to listen on for incoming gRPC connections | ||
host = "localhost" | ||
# Port to listen on for incoming gRPC connections | ||
port = 50051 | ||
|
||
[ai] | ||
# Path to a file containing a numpy ndarray to use a initial model weights. | ||
initial_weights = "./docker/dev/initial_weights.npy" | ||
# Number of global rounds the model is going to be trained for. This | ||
# must be a positive integer. | ||
rounds = 1 | ||
# Number of local epochs per round | ||
epochs = 1 | ||
# Minimum number of participants to be selected for a round. | ||
min_participants = 1 | ||
# Fraction of total clients that participate in a training round. This | ||
# must be a float between 0 and 1. | ||
fraction_participants = 1.0 | ||
|
||
[storage] | ||
# URL to the storage service to use | ||
endpoint = "http://minio-dev:9000" | ||
# Name of the bucket for storing the aggregated models | ||
bucket = "xain-fl-aggregated-weights" | ||
# AWS access key ID to use to authenticate to the storage service | ||
access_key_id = "minio" | ||
# AWS secret access to use to authenticate to the storage service | ||
secret_access_key = "minio123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.