p2pfl.management.p2pfl_web_services moduleΒΆ

Communication with P2PFL Web Services (via REST API).

Todo

Implement batch sending.

Todo

Implement get_pending_actions.

Todo

Implement unregister_node.

Todo

Implement get_experiment_id.

class p2pfl.management.p2pfl_web_services.P2pflWebServices(url, key)[source]ΒΆ

Bases: object

Class that manages the communication with the p2pfl-web services.

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

  • key (str) – The key to access the services.

get_pending_actions()[source]ΒΆ

Get pending actions from the p2pfl-web services.

register_node(node, is_simulated)[source]ΒΆ

Register a node.

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

  • is_simulated (bool) – If the node is simulated.

Return type:

None

send_global_metric(exp, round, metric, node, value)[source]ΒΆ

Send a local metric.

Parameters:
  • exp (str) – The experiment.

  • round (int) – The round.

  • metric (str) – The metric.

  • node (str) – The node address.

  • value (float) – The value.

send_local_metric(exp, round, metric, node, value, step)[source]ΒΆ

Send a local metric.

Parameters:
  • exp (str) – The experiment.

  • round (int) – The round.

  • metric (str) – The metric.

  • node (str) – The node address.

  • value (float) – The value.

  • step (int) – The step.

Return type:

None

send_log(time, node, level, message)[source]ΒΆ

Send a log message.

Parameters:
  • time (datetime) – The time of the message.

  • node (str) – The node address.

  • level (int) – The log level.

  • message (str) – The message.

Return type:

None

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

Send a metric.

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

  • metric (str) – The metric.

  • value (float) – The value.

  • time (datetime) – The time.

unregister_node(node)[source]ΒΆ

Unregister a node.

Parameters:

node (str) – The node address.

Return type:

None

exception p2pfl.management.p2pfl_web_services.P2pflWebServicesError(code, message)[source]ΒΆ

Bases: Exception

P2PFL Web Services Error.

Parameters:
  • code (int) – Error code.

  • message (str) – Error message.