Skip to content

fl_server_ai.trainer.events.base

Classes:

Name Description
ModelTrainerEvent

Abstract base class for a model trainer event.

Classes

ModelTrainerEvent

Bases: ABC


              flowchart TD
              fl_server_ai.trainer.events.base.ModelTrainerEvent[ModelTrainerEvent]

              

              click fl_server_ai.trainer.events.base.ModelTrainerEvent href "" "fl_server_ai.trainer.events.base.ModelTrainerEvent"
            

Abstract base class for a model trainer event.

Methods:

Name Description
__init__

Initialize the event with the given trainer.

handle

Handle the event.

next

Proceed with the next event.

Attributes:

Name Type Description
trainer

The trainer that the event is associated with.

training

The training that the event is associated with.

Source code in fl_server_ai/trainer/events/base.py
class ModelTrainerEvent(ABC):
    """
    Abstract base class for a model trainer event.
    """

    _logger = getLogger("fl.server")

    def __init__(self, trainer: "model_trainer.ModelTrainer"):
        """
        Initialize the event with the given trainer.

        Args:
            trainer (model_trainer.ModelTrainer): The trainer that the event is associated with.
        """
        super().__init__()
        self.trainer = trainer
        """The trainer that the event is associated with."""
        self.training = trainer.training
        """The training that the event is associated with."""

    @abstractmethod
    def handle(self):
        """
        Handle the event.
        """
        pass

    @abstractmethod
    def next(self):
        """
        Proceed with the next event.
        """
        pass

Attributes

trainer instance-attribute
trainer = trainer

The trainer that the event is associated with.

training instance-attribute
training = training

The training that the event is associated with.

Functions

__init__
__init__(trainer: ModelTrainer)

Initialize the event with the given trainer.

Parameters:

Name Type Description Default
trainer
ModelTrainer

The trainer that the event is associated with.

required
Source code in fl_server_ai/trainer/events/base.py
def __init__(self, trainer: "model_trainer.ModelTrainer"):
    """
    Initialize the event with the given trainer.

    Args:
        trainer (model_trainer.ModelTrainer): The trainer that the event is associated with.
    """
    super().__init__()
    self.trainer = trainer
    """The trainer that the event is associated with."""
    self.training = trainer.training
    """The training that the event is associated with."""
handle abstractmethod
handle()

Handle the event.

Source code in fl_server_ai/trainer/events/base.py
@abstractmethod
def handle(self):
    """
    Handle the event.
    """
    pass
next abstractmethod
next()

Proceed with the next event.

Source code in fl_server_ai/trainer/events/base.py
@abstractmethod
def next(self):
    """
    Proceed with the next event.
    """
    pass