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.
- register_node(node)[source]ΒΆ
Register a node.
- Parameters:
node (
str
) β The node address.- Return type:
None
- send_communication_log(node, timestamp, direction, cmd, source_dest, package_type, package_size, round_num=None, additional_info=None)[source]ΒΆ
Send a communication log to the web services.
- Parameters:
node (
str
) β The node address.timestamp (
datetime
) β The timestamp of the communication.direction (
str
) β Direction of communication (βsentβ or βreceivedβ).cmd (
str
) β The command or message type.source_dest (
str
) β Source (if receiving) or destination (if sending) node.package_type (
str
) β Type of package (βmessageβ or βweightsβ).package_size (
int
) β Size of the package in bytes (if available).round_num (
Optional
[int
]) β The federated learning round number (if applicable).additional_info (
Optional
[dict
]) β Additional information as a dictionary.
- 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