fluke.utils.log

This submodule provides logging utilities.

Classes included in fluke.utils.log

Log

Basic logger.

WandBLog

Weights and Biases logger.

TensorboardLog

TensorBoard logger.

ClearMLLog

ClearML logger.

class fluke.utils.log.Log

class fluke.utils.log.Log(**kwargs: dict[str, Any])[source]

Basic logger. This class is used to log the performance of the global model and the communication costs during the federated learning process. The logging happens in the console.

global_eval

The global evaluation metrics.

Type:

dict

locals_eval

The clients local model evaluation metrics on the server’s test set.

Type:

dict

prefit_eval

The clients’ pre-fit evaluation metrics.

Type:

dict

postfit_eval

The clients’ post-fit evaluation metrics.

Type:

dict

locals_eval_summary

The mean of the clients local model evaluation metrics.

Type:

dict

prefit_eval_summary

The mean of the clients pre-fit evaluation metrics.

Type:

dict

postfit_eval_summary

The mean of the clients post-fit evaluation metrics.

Type:

dict

comm_costs

The communication costs.

Type:

dict

current_round

The current round.

Type:

int

add_scalar(key: Any, value: float, round: int) None[source]

Add a scalar to the logger.

Parameters:
  • key (Any) – The key of the scalar.

  • value (float) – The value of the scalar.

  • round (int) – The round.

add_scalars(key: Any, values: dict[str, float], round: int) None[source]

Add scalars to the logger.

Parameters:
  • key (Any) – The main key of the scalars.

  • values (dict[str, float]) – The key-value pairs of the scalars.

  • round (int) – The round.

init(**kwargs: dict[str, Any]) None[source]

Initialize the logger. The initialization is done by printing the configuration in the console.

Parameters:

**kwargs – The configuration.

log(message: str) None[source]

Log a message.

Parameters:

message (str) – The message to log.

message_received(message: Message) None[source]

Update the communication costs.

Parameters:

message (Message) – The message received.

pretty_log(data: Any, title: str) None[source]

Log a pretty-printed data.

Parameters:
  • data (Any) – The data to log.

  • title (str) – The title of the data.

save(path: str) None[source]

Save the logger’s history to a JSON file.

Parameters:

path (str) – The path to the JSON file.

class fluke.utils.log.WandBLog

class fluke.utils.log.WandBLog(**config)[source]

Bases: Log

Weights and Biases logger. This class is used to log the performance of the global model and the communication costs during the federated learning process on Weights and Biases.

See also

For more information on Weights and Biases, see the Weights and Biases documentation.

Parameters:

**config – The configuration for Weights and Biases.

class fluke.utils.log.TensorboardLog

class fluke.utils.log.TensorboardLog(**config)[source]

Bases: Log

TensorBoard logger. This class is used to log the performance of the global model and the communication costs during the federated learning process on TensorBoard

See also

For more information on TensorBoard, see the official documentation.

Parameters:

**config – The configuration for TensorBoard.

class fluke.utils.log.ClearMLLog

class fluke.utils.log.ClearMLLog(**config)[source]

Bases: TensorboardLog

ClearML logger. This class is used to log the performance of the global model and the communication costs during the federated learning process on ClearML.

Note

The ClearML logger takes advantage of the TensorBoard logger, thus the logging also happens on TensorBoard. The logging folder is “./runs/{experiment_name}_{timestamp}”.

See also

For more information on ClearML, see the official documentation.

Parameters:

**config – The configuration for ClearML.

Functions

fluke.utils.log.get_logger(lname: str, **kwargs: dict[str, Any]) Log[source]

Get a logger from its name. This function is used to get a logger from its name. It is used to dynamically import loggers. The supported loggers are the ones defined in the fluke.utils.log module.

Parameters:
  • lname (str) – The name of the logger.

  • **kwargs – The keyword arguments to pass to the logger’s constructor.

Returns:

The logger.

Return type:

Log | WandBLog | ClearMLLog | TensorboardLog