p2pfl.management.logger.logger moduleΒΆ

P2PFL Logger.

Note

Not all is typed because the python logger is not typed (yep, is a TODO…).

class p2pfl.management.logger.logger.ColoredFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]ΒΆ

Bases: Formatter

Formatter that adds color to the log messages.

format(record)[source]ΒΆ

Format the log record with color.

Parameters:

record – The log record.

exception p2pfl.management.logger.logger.NodeNotRegistered[source]ΒΆ

Bases: Exception

Exception raised when a node is not registered.

class p2pfl.management.logger.logger.P2PFLogger(nodes=None, disable_locks=False)[source]ΒΆ

Bases: object

Class that manages the node logging (not a singleton).

Parameters:

p2pfl_web_services – The P2PFL Web Services to log and monitor the nodes remotely.

add_handler(handler)[source]ΒΆ

Add a handler to the logger.

Parameters:

handler (Handler) – The logger handler.

Return type:

None

cleanup()[source]ΒΆ

Cleanup the logger.

Return type:

None

connect_web(url, key)[source]ΒΆ

Connect to the web services.

Parameters:
  • url (str) – The URL of the web services.

  • key (str) – The API key.

Return type:

None

critical(node, message, *, _ray_trace_ctx=None)[source]ΒΆ

Log a critical message.

Parameters:
  • node (str) – The node name.

  • message (str) – The message to log.

Return type:

None

debug(node, message, *, _ray_trace_ctx=None)[source]ΒΆ

Log a debug message.

Parameters:
  • node (str) – The node name.

  • message (str) – The message to log.

Return type:

None

error(node, message, *, _ray_trace_ctx=None)[source]ΒΆ

Log an error message.

Parameters:
  • node (str) – The node name.

  • message (str) – The message to log.

Return type:

None

experiment_finished(node)[source]ΒΆ

Notify the experiment end.

Parameters:

node (str) – The node address.

Return type:

None

experiment_started(node, experiment)[source]ΒΆ

Notify the experiment start.

Parameters:
  • node (str) – The node address.

  • experiment (Experiment | None) – The experiment.

Return type:

None

get_global_logs()[source]ΒΆ

Get the logs.

Parameters:
  • node – The node name.

  • exp – The experiment name.

Return type:

Dict[str, Dict[str, Dict[str, List[Tuple[int, float]]]]]

Returns:

The logs.

get_level()[source]ΒΆ

Get the logger level.

Return type:

int

Returns

The logger level.

get_level_name(lvl)[source]ΒΆ

Get the logger level name.

Parameters:

lvl (int) – The logger level.

Return type:

str

Returns:

The logger level name.

get_local_logs()[source]ΒΆ

Get the logs.

Parameters:
  • node – The node name.

  • exp – The experiment name.

Return type:

Dict[str, Dict[int, Dict[str, Dict[str, List[Tuple[int, float]]]]]]

Returns:

The logs.

get_nodes()[source]ΒΆ

Get the registered nodes.

Return type:

Dict[str, Dict[Any, Any]]

Returns:

The registered nodes.

info(node, message, *, _ray_trace_ctx=None)[source]ΒΆ

Log an info message.

Parameters:
  • node (str) – The node name.

  • message (str) – The message to log.

Return type:

None

log(level, node, message)[source]ΒΆ

Log a message.

Parameters:
  • level (int) – The log level.

  • node (str) – The node name.

  • message (str) – The message to log.

Return type:

None

log_metric(addr, metric, value, round=None, step=None)[source]ΒΆ

Log a metric.

Parameters:
  • addr (str) – The node name.

  • metric (str) – The metric to log.

  • value (float) – The value.

  • step (Optional[int]) – The step.

  • round (Optional[int]) – The round.

Return type:

None

log_system_metric(node, metric, value, time)[source]ΒΆ

Log a system metric.

Parameters:
  • node (str) – The node name.

  • metric (str) – The metric to log.

  • value (float) – The value.

  • time (datetime) – The time.

Return type:

None

register_node(node, simulation)[source]ΒΆ

Register a node.

Parameters:
  • node (str) – The node address.

  • simulation (bool) – If the node is a simulation.

Return type:

None

round_finished(node)[source]ΒΆ

Notify the round end.

Parameters:

node (str) – The node address.

Return type:

None

round_started(node, experiment)[source]ΒΆ

Notify the round start.

Parameters:
  • node (str) – The node address.

  • experiment (Experiment | None) – The experiment.

Return type:

None

set_level(level)[source]ΒΆ

Set the logger level.

Parameters:

level (Union[int, str]) – The logger level.

Return type:

None

unregister_node(node)[source]ΒΆ

Unregister a node.

Parameters:

node (str) – The node address.

Return type:

None

warning(node, message, *, _ray_trace_ctx=None)[source]ΒΆ

Log a warning message.

Parameters:
  • node (str) – The node name.

  • message (str) – The message to log.

Return type:

None