florist.api.servers.config_parsers module

Parsers for FL server configurations.

class BasicConfigParser[source]

Bases: object

Parser for basic server configurations.

classmethod mandatory_fields()[source]

Define the mandatory fields for basic server configuration.

Namely: n_server_rounds, batch_size and local_epochs.

Return type:

List[str]

Returns:

(List[str]) the list of required fields for basic server configuration.

classmethod parse(config_json_str)[source]

Parse a configuration JSON string into a dictionary.

Parameters:

config_json_str (str) – (str) the configuration JSON string

Return type:

Dict[str, Any]

Returns:

(Dict[str, Any]) The configuration JSON string parsed as a dictionary.

class ConfigParser(value)[source]

Bases: Enum

Enum to define the types of server configuration parsers.

BASIC = 'BASIC'
FEDPROX = 'FEDPROX'
classmethod class_for_parser(config_parser)[source]

Return the class for a given config parser.

Parameters:

config_parser (Self) – (ConfigParser) The config parser enumeration instance.

Return type:

type[BasicConfigParser]

Returns:

(type[BasicConfigParser]) A subclass of BasicConfigParser corresponding to the given config parser.

Raises:

ValueError – if the config_parser is not supported.

classmethod list()[source]

List all the supported config parsers.

Return type:

List[str]

Returns:

(List[str]) a list of supported config parsers.

class FedProxConfigParser[source]

Bases: BasicConfigParser

Parser for FedProx server configurations.

classmethod mandatory_fields()[source]

Define the mandatory fields for FedProx configuration.

Namely: n_server_rounds, adapt_proximal_weight, initial_proximal_weight, proximal_weight_delta, proximal_weight_patience, local_epochs and batch_size.

Return type:

List[str]

Returns:

(List[str]) the list of required fields for FedProx server configuration.

exception IncompleteConfigError[source]

Bases: Exception

Defines errors in server config strings that have incomplete information.