Skip to content

fl_server_ai.notification.training.finished

Classes:

Name Description
TrainingFinishedNotification

Notification that a training has finished.

Classes

TrainingFinishedNotification dataclass

Bases: TrainingNotification['TrainingFinishedNotification.Body']


              flowchart TD
              fl_server_ai.notification.training.finished.TrainingFinishedNotification[TrainingFinishedNotification]
              fl_server_ai.notification.training.training.TrainingNotification[TrainingNotification]
              fl_server_ai.notification.notification.Notification[Notification]
              fl_server_ai.notification.serializable.Serializable[Serializable]

                              fl_server_ai.notification.training.training.TrainingNotification --> fl_server_ai.notification.training.finished.TrainingFinishedNotification
                                fl_server_ai.notification.notification.Notification --> fl_server_ai.notification.training.training.TrainingNotification
                                fl_server_ai.notification.serializable.Serializable --> fl_server_ai.notification.notification.Notification
                




              click fl_server_ai.notification.training.finished.TrainingFinishedNotification href "" "fl_server_ai.notification.training.finished.TrainingFinishedNotification"
              click fl_server_ai.notification.training.training.TrainingNotification href "" "fl_server_ai.notification.training.training.TrainingNotification"
              click fl_server_ai.notification.notification.Notification href "" "fl_server_ai.notification.notification.Notification"
              click fl_server_ai.notification.serializable.Serializable href "" "fl_server_ai.notification.serializable.Serializable"
            

Notification that a training has finished.

Classes:

Name Description
Body

Inner class representing the body of the notification.

Methods:

Name Description
from_training

Create a TrainingFinishedNotification instance from a training object.

Attributes:

Name Type Description
type NotificationType

The type of the notification.

Source code in fl_server_ai/notification/training/finished.py
class TrainingFinishedNotification(TrainingNotification["TrainingFinishedNotification.Body"]):
    """
    Notification that a training has finished.
    """

    type: NotificationType = NotificationType.TRAINING_FINISHED
    """The type of the notification."""

    @dataclass
    class Body(Serializable):
        """
        Inner class representing the body of the notification.
        """
        global_model_uuid: UUID
        """The UUID of the global model."""

    @classmethod
    def from_training(cls, training: TrainingDB):
        """
        Create a `TrainingFinishedNotification` instance from a training object.

        Args:
            training (TrainingDB): The training object to create the notification from.

        Returns:
            TrainingFinishedNotification: The created notification.
        """
        receivers = list(training.participants.all())
        if not receivers.__contains__(training.actor):
            receivers.append(training.actor)
        return cls(
            receivers=receivers,
            body=cls.Body(
                global_model_uuid=training.model.id
            ),
            training_uuid=training.id
        )

Attributes

type class-attribute instance-attribute

The type of the notification.

Classes

Body dataclass

Bases: Serializable


              flowchart TD
              fl_server_ai.notification.training.finished.TrainingFinishedNotification.Body[Body]
              fl_server_ai.notification.serializable.Serializable[Serializable]

                              fl_server_ai.notification.serializable.Serializable --> fl_server_ai.notification.training.finished.TrainingFinishedNotification.Body
                


              click fl_server_ai.notification.training.finished.TrainingFinishedNotification.Body href "" "fl_server_ai.notification.training.finished.TrainingFinishedNotification.Body"
              click fl_server_ai.notification.serializable.Serializable href "" "fl_server_ai.notification.serializable.Serializable"
            

Inner class representing the body of the notification.

Methods:

Name Description
__init__

Attributes:

Name Type Description
global_model_uuid UUID

The UUID of the global model.

Source code in fl_server_ai/notification/training/finished.py
@dataclass
class Body(Serializable):
    """
    Inner class representing the body of the notification.
    """
    global_model_uuid: UUID
    """The UUID of the global model."""
Attributes
global_model_uuid instance-attribute
global_model_uuid: UUID

The UUID of the global model.

Functions
__init__
__init__(global_model_uuid: UUID) -> None

Functions

from_training classmethod
from_training(training: Training)

Create a TrainingFinishedNotification instance from a training object.

Parameters:

Name Type Description Default
training
Training

The training object to create the notification from.

required

Returns:

Name Type Description
TrainingFinishedNotification

The created notification.

Source code in fl_server_ai/notification/training/finished.py
@classmethod
def from_training(cls, training: TrainingDB):
    """
    Create a `TrainingFinishedNotification` instance from a training object.

    Args:
        training (TrainingDB): The training object to create the notification from.

    Returns:
        TrainingFinishedNotification: The created notification.
    """
    receivers = list(training.participants.all())
    if not receivers.__contains__(training.actor):
        receivers.append(training.actor)
    return cls(
        receivers=receivers,
        body=cls.Body(
            global_model_uuid=training.model.id
        ),
        training_uuid=training.id
    )