Skip to content

fl_server_core.models

Modules:

Name Description
metric
model
training
user

Classes:

Name Description
GlobalModel

Model class for global models.

LocalModel

Model class for local models.

MeanModel

Model class for mean models.

Metric

Metric model class.

Model

Base model class for all types of model models.

SWAGModel

Model class for SWAG models.

Training

Training model class.

User

User class.

Attributes

__all__ module-attribute

__all__ = ['GlobalModel', 'LocalModel', 'Metric', 'MeanModel', 'Model', 'SWAGModel', 'Training', 'User']

Classes

GlobalModel

Bases: Model


              flowchart TD
              fl_server_core.models.GlobalModel[GlobalModel]
              fl_server_core.models.model.Model[Model]

                              fl_server_core.models.model.Model --> fl_server_core.models.GlobalModel
                


              click fl_server_core.models.GlobalModel href "" "fl_server_core.models.GlobalModel"
              click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
            

Model class for global models.

Methods:

Name Description
get_preprocessing_torch_model

Converts the preprocessing to a PyTorch model.

set_preprocessing_torch_model

Sets the preprocessing from a PyTorch model.

Attributes:

Name Type Description
description TextField

Description of the model.

input_shape ArrayField

Input shape of the model.

name CharField

Name of the model.

preprocessing BinaryField

Preprocessing of the model.

Source code in fl_server_core/models/model.py
class GlobalModel(Model):
    """
    Model class for global models.
    """

    name: CharField = CharField(max_length=256)
    """Name of the model."""
    description: TextField = TextField()
    """Description of the model."""
    # alternative to be postgres independent: create a new model for each nullable integer field
    # and map the corresponding list of integers to the model (but pay attention to the order)
    input_shape: ArrayField = ArrayField(IntegerField(null=True), null=True)
    """Input shape of the model."""
    preprocessing: BinaryField = BinaryField(null=True)
    """Preprocessing of the model."""

    def get_preprocessing_torch_model(self) -> torch.nn.Module:
        """
        Converts the preprocessing to a PyTorch model.

        Returns:
            torch.nn.Module: The PyTorch model.
        """
        return to_torch_module(self.preprocessing)

    def set_preprocessing_torch_model(self, value: torch.nn.Module):
        """
        Sets the preprocessing from a PyTorch model.

        Args:
            value (torch.nn.Module): The PyTorch model.
        """
        self.preprocessing = from_torch_module(value)

Attributes

description class-attribute instance-attribute
description: TextField = TextField()

Description of the model.

input_shape class-attribute instance-attribute
input_shape: ArrayField = ArrayField(IntegerField(null=True), null=True)

Input shape of the model.

name class-attribute instance-attribute
name: CharField = CharField(max_length=256)

Name of the model.

preprocessing class-attribute instance-attribute
preprocessing: BinaryField = BinaryField(null=True)

Preprocessing of the model.

Functions

get_preprocessing_torch_model
get_preprocessing_torch_model() -> Module

Converts the preprocessing to a PyTorch model.

Returns:

Type Description
Module

torch.nn.Module: The PyTorch model.

Source code in fl_server_core/models/model.py
def get_preprocessing_torch_model(self) -> torch.nn.Module:
    """
    Converts the preprocessing to a PyTorch model.

    Returns:
        torch.nn.Module: The PyTorch model.
    """
    return to_torch_module(self.preprocessing)
set_preprocessing_torch_model
set_preprocessing_torch_model(value: Module)

Sets the preprocessing from a PyTorch model.

Parameters:

Name Type Description Default
value
Module

The PyTorch model.

required
Source code in fl_server_core/models/model.py
def set_preprocessing_torch_model(self, value: torch.nn.Module):
    """
    Sets the preprocessing from a PyTorch model.

    Args:
        value (torch.nn.Module): The PyTorch model.
    """
    self.preprocessing = from_torch_module(value)

LocalModel

Bases: Model


              flowchart TD
              fl_server_core.models.LocalModel[LocalModel]
              fl_server_core.models.model.Model[Model]

                              fl_server_core.models.model.Model --> fl_server_core.models.LocalModel
                


              click fl_server_core.models.LocalModel href "" "fl_server_core.models.LocalModel"
              click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
            

Model class for local models.

Methods:

Name Description
get_training

Gets the training associated with the base model.

Attributes:

Name Type Description
base_model ForeignKey

Base model of the local model.

sample_size IntegerField

Sample size of the local model.

Source code in fl_server_core/models/model.py
class LocalModel(Model):
    """
    Model class for local models.
    """

    base_model: ForeignKey = ForeignKey(GlobalModel, on_delete=CASCADE)
    """Base model of the local model."""
    sample_size: IntegerField = IntegerField()
    """Sample size of the local model."""

    def get_training(self) -> Optional["models.Training"]:
        """
        Gets the training associated with the base model.

        Returns:
            models.Training: The training associated with the base model.
        """
        return models.Training.objects.filter(model=self.base_model).first()

Attributes

base_model class-attribute instance-attribute
base_model: ForeignKey = ForeignKey(GlobalModel, on_delete=CASCADE)

Base model of the local model.

sample_size class-attribute instance-attribute
sample_size: IntegerField = IntegerField()

Sample size of the local model.

Functions

get_training
get_training() -> Training | None

Gets the training associated with the base model.

Returns:

Type Description
Training | None

models.Training: The training associated with the base model.

Source code in fl_server_core/models/model.py
def get_training(self) -> Optional["models.Training"]:
    """
    Gets the training associated with the base model.

    Returns:
        models.Training: The training associated with the base model.
    """
    return models.Training.objects.filter(model=self.base_model).first()

MeanModel

Bases: GlobalModel


              flowchart TD
              fl_server_core.models.MeanModel[MeanModel]
              fl_server_core.models.model.GlobalModel[GlobalModel]
              fl_server_core.models.model.Model[Model]

                              fl_server_core.models.model.GlobalModel --> fl_server_core.models.MeanModel
                                fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
                



              click fl_server_core.models.MeanModel href "" "fl_server_core.models.MeanModel"
              click fl_server_core.models.model.GlobalModel href "" "fl_server_core.models.model.GlobalModel"
              click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
            

Model class for mean models.

Methods:

Name Description
get_torch_model

Converts the models to a PyTorch model.

set_torch_model

Sets the models from a PyTorch model.

Attributes:

Name Type Description
models ManyToManyField

Models of the mean model.

Source code in fl_server_core/models/model.py
class MeanModel(GlobalModel):
    """
    Model class for mean models.
    """

    models: ManyToManyField = ManyToManyField(GlobalModel, related_name="mean_models")
    """Models of the mean model."""

    def get_torch_model(self) -> torch.nn.Module:
        """
        Converts the models to a PyTorch model.

        Returns:
            torch.nn.Module: The PyTorch model.
        """
        torch_models: List[torch.nn.Module] = [model.get_torch_model() for model in self.models.all()]
        model = MeanModule(torch_models)
        if all(is_torchscript_instance(m) for m in torch_models):
            return torch.jit.script(model)
        return model

    def set_torch_model(self, value: torch.nn.Module):
        """
        Sets the models from a PyTorch model.

        Args:
            value (torch.nn.Module): The PyTorch model.
        """
        raise NotImplementedError()

Attributes

models class-attribute instance-attribute
models: ManyToManyField = ManyToManyField(GlobalModel, related_name='mean_models')

Models of the mean model.

Functions

get_torch_model
get_torch_model() -> Module

Converts the models to a PyTorch model.

Returns:

Type Description
Module

torch.nn.Module: The PyTorch model.

Source code in fl_server_core/models/model.py
def get_torch_model(self) -> torch.nn.Module:
    """
    Converts the models to a PyTorch model.

    Returns:
        torch.nn.Module: The PyTorch model.
    """
    torch_models: List[torch.nn.Module] = [model.get_torch_model() for model in self.models.all()]
    model = MeanModule(torch_models)
    if all(is_torchscript_instance(m) for m in torch_models):
        return torch.jit.script(model)
    return model
set_torch_model
set_torch_model(value: Module)

Sets the models from a PyTorch model.

Parameters:

Name Type Description Default
value
Module

The PyTorch model.

required
Source code in fl_server_core/models/model.py
def set_torch_model(self, value: torch.nn.Module):
    """
    Sets the models from a PyTorch model.

    Args:
        value (torch.nn.Module): The PyTorch model.
    """
    raise NotImplementedError()

Metric

Bases: Model


              flowchart TD
              fl_server_core.models.Metric[Metric]

              

              click fl_server_core.models.Metric href "" "fl_server_core.models.Metric"
            

Metric model class.

Methods:

Name Description
is_binary

Check if the value of the metric is binary.

is_float

Check if the value of the metric is a float.

to_torch

Convert the binary value of the metric to a torch module or tensor.

Attributes:

Name Type Description
identifier CharField

Identifier of the metric.

key CharField

Key of the metric.

model ForeignKey

Model associated with the metric.

reporter ForeignKey

User who reported the metric.

step IntegerField

Step of the metric.

value float | bytes

Value of the metric.

value_binary BinaryField

Binary value of the metric.

value_float FloatField

Float value of the metric.

Source code in fl_server_core/models/metric.py
class Metric(models.Model):
    """
    Metric model class.
    """

    model: ForeignKey = ForeignKey(Model, on_delete=CASCADE)
    """Model associated with the metric."""
    identifier: CharField = CharField(max_length=64, null=True, blank=True)
    """Identifier of the metric."""
    key: CharField = CharField(max_length=32)
    """Key of the metric."""
    value_float: FloatField = FloatField(null=True, blank=True)
    """Float value of the metric."""
    value_binary: BinaryField = BinaryField(null=True, blank=True)
    """Binary value of the metric."""
    step: IntegerField = IntegerField(null=True, blank=True)
    """Step of the metric."""
    reporter: ForeignKey = ForeignKey(User, null=True, blank=True, on_delete=CASCADE)
    """User who reported the metric."""

    @property
    def value(self) -> float | bytes:
        """
        Value of the metric.

        Returns:
            float | bytes: The value of the metric.
        """
        if self.is_float():
            return self.value_float
        return self.value_binary

    @value.setter
    def value(self, value: float | int | bytes | Module | Tensor):
        """
        Setter for the value of the metric.

        Args:
            value (float | int | bytes | Module | Tensor): The value to set.
        """
        if isinstance(value, float):
            self.value_float = value
        elif isinstance(value, int):
            self.value_float = float(value)
        elif isinstance(value, (Module, Tensor)):
            self.value_binary = from_torch_module_or_tensor(value)
        else:
            self.value_binary = value

    @value.deleter
    def value(self):
        """
        Deleter for the value of the metric.
        """
        self.value_float = None
        self.value_binary = None

    def is_float(self) -> bool:
        """
        Check if the value of the metric is a float.

        Returns:
            bool: `True` if the value of the metric is a float, otherwise `False`.
        """
        return self.value_float is not None

    def is_binary(self) -> bool:
        """
        Check if the value of the metric is binary.

        Returns:
            bool: `True` if the value of the metric is binary, otherwise `False`.
        """
        return self.value_binary is not None

    def to_torch(self) -> Module | Tensor:
        """
        Convert the binary value of the metric to a torch module or tensor.

        Returns:
            Module | Tensor: The converted torch module or tensor.
        """
        return to_torch_module_or_tensor(self.value_binary)

Attributes

identifier class-attribute instance-attribute
identifier: CharField = CharField(max_length=64, null=True, blank=True)

Identifier of the metric.

key class-attribute instance-attribute
key: CharField = CharField(max_length=32)

Key of the metric.

model class-attribute instance-attribute
model: ForeignKey = ForeignKey(Model, on_delete=CASCADE)

Model associated with the metric.

reporter class-attribute instance-attribute
reporter: ForeignKey = ForeignKey(User, null=True, blank=True, on_delete=CASCADE)

User who reported the metric.

step class-attribute instance-attribute
step: IntegerField = IntegerField(null=True, blank=True)

Step of the metric.

value deletable property writable
value: float | bytes

Value of the metric.

Returns:

Type Description
float | bytes

float | bytes: The value of the metric.

value_binary class-attribute instance-attribute
value_binary: BinaryField = BinaryField(null=True, blank=True)

Binary value of the metric.

value_float class-attribute instance-attribute
value_float: FloatField = FloatField(null=True, blank=True)

Float value of the metric.

Functions

is_binary
is_binary() -> bool

Check if the value of the metric is binary.

Returns:

Name Type Description
bool bool

True if the value of the metric is binary, otherwise False.

Source code in fl_server_core/models/metric.py
def is_binary(self) -> bool:
    """
    Check if the value of the metric is binary.

    Returns:
        bool: `True` if the value of the metric is binary, otherwise `False`.
    """
    return self.value_binary is not None
is_float
is_float() -> bool

Check if the value of the metric is a float.

Returns:

Name Type Description
bool bool

True if the value of the metric is a float, otherwise False.

Source code in fl_server_core/models/metric.py
def is_float(self) -> bool:
    """
    Check if the value of the metric is a float.

    Returns:
        bool: `True` if the value of the metric is a float, otherwise `False`.
    """
    return self.value_float is not None
to_torch
to_torch() -> Module | Tensor

Convert the binary value of the metric to a torch module or tensor.

Returns:

Type Description
Module | Tensor

Module | Tensor: The converted torch module or tensor.

Source code in fl_server_core/models/metric.py
def to_torch(self) -> Module | Tensor:
    """
    Convert the binary value of the metric to a torch module or tensor.

    Returns:
        Module | Tensor: The converted torch module or tensor.
    """
    return to_torch_module_or_tensor(self.value_binary)

Model

Bases: PolymorphicModel


              flowchart TD
              fl_server_core.models.Model[Model]

              

              click fl_server_core.models.Model href "" "fl_server_core.models.Model"
            

Base model class for all types of model models.

Methods:

Name Description
get_torch_model

Converts the model weights to a PyTorch model.

get_training

Gets the training associated with the model.

is_global_model

Checks if the model is a global model.

is_local_model

Checks if the model is a local model.

set_torch_model

Sets the model weights from a PyTorch model.

Attributes:

Name Type Description
id UUIDField

Unique identifier for the model.

owner ForeignKey

User who owns the model.

round IntegerField

Round number of the model.

weights BinaryField

Weights of the model.

Source code in fl_server_core/models/model.py
class Model(PolymorphicModel):
    """
    Base model class for all types of model models.
    """

    id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)
    """Unique identifier for the model."""
    owner: ForeignKey = ForeignKey(User, on_delete=CASCADE)
    """User who owns the model."""
    round: IntegerField = IntegerField()
    """Round number of the model."""
    weights: BinaryField = BinaryField()
    """Weights of the model."""

    def is_global_model(self):
        """
        Checks if the model is a global model.

        Returns:
            bool: True if the model is a global model, False otherwise.
        """
        return isinstance(self, GlobalModel)

    def is_local_model(self):
        """
        Checks if the model is a local model.

        Returns:
            bool: True if the model is a local model, False otherwise.
        """
        return isinstance(self, LocalModel)

    def get_torch_model(self) -> torch.nn.Module:
        """
        Converts the model weights to a PyTorch model.

        Returns:
            torch.nn.Module: The PyTorch model.
        """
        return to_torch_module(self.weights)

    def set_torch_model(self, value: torch.nn.Module):
        """
        Sets the model weights from a PyTorch model.

        Args:
            value (torch.nn.Module): The PyTorch model.
        """
        self.weights = from_torch_module(value)

    def get_training(self) -> Optional["models.Training"]:
        """
        Gets the training associated with the model.

        Returns:
            models.Training: The training associated with the model.
        """
        return models.Training.objects.filter(model=self).first()

Attributes

id class-attribute instance-attribute
id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)

Unique identifier for the model.

owner class-attribute instance-attribute
owner: ForeignKey = ForeignKey(User, on_delete=CASCADE)

User who owns the model.

round class-attribute instance-attribute
round: IntegerField = IntegerField()

Round number of the model.

weights class-attribute instance-attribute
weights: BinaryField = BinaryField()

Weights of the model.

Functions

get_torch_model
get_torch_model() -> Module

Converts the model weights to a PyTorch model.

Returns:

Type Description
Module

torch.nn.Module: The PyTorch model.

Source code in fl_server_core/models/model.py
def get_torch_model(self) -> torch.nn.Module:
    """
    Converts the model weights to a PyTorch model.

    Returns:
        torch.nn.Module: The PyTorch model.
    """
    return to_torch_module(self.weights)
get_training
get_training() -> Training | None

Gets the training associated with the model.

Returns:

Type Description
Training | None

models.Training: The training associated with the model.

Source code in fl_server_core/models/model.py
def get_training(self) -> Optional["models.Training"]:
    """
    Gets the training associated with the model.

    Returns:
        models.Training: The training associated with the model.
    """
    return models.Training.objects.filter(model=self).first()
is_global_model
is_global_model()

Checks if the model is a global model.

Returns:

Name Type Description
bool

True if the model is a global model, False otherwise.

Source code in fl_server_core/models/model.py
def is_global_model(self):
    """
    Checks if the model is a global model.

    Returns:
        bool: True if the model is a global model, False otherwise.
    """
    return isinstance(self, GlobalModel)
is_local_model
is_local_model()

Checks if the model is a local model.

Returns:

Name Type Description
bool

True if the model is a local model, False otherwise.

Source code in fl_server_core/models/model.py
def is_local_model(self):
    """
    Checks if the model is a local model.

    Returns:
        bool: True if the model is a local model, False otherwise.
    """
    return isinstance(self, LocalModel)
set_torch_model
set_torch_model(value: Module)

Sets the model weights from a PyTorch model.

Parameters:

Name Type Description Default
value
Module

The PyTorch model.

required
Source code in fl_server_core/models/model.py
def set_torch_model(self, value: torch.nn.Module):
    """
    Sets the model weights from a PyTorch model.

    Args:
        value (torch.nn.Module): The PyTorch model.
    """
    self.weights = from_torch_module(value)

SWAGModel

Bases: GlobalModel


              flowchart TD
              fl_server_core.models.SWAGModel[SWAGModel]
              fl_server_core.models.model.GlobalModel[GlobalModel]
              fl_server_core.models.model.Model[Model]

                              fl_server_core.models.model.GlobalModel --> fl_server_core.models.SWAGModel
                                fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
                



              click fl_server_core.models.SWAGModel href "" "fl_server_core.models.SWAGModel"
              click fl_server_core.models.model.GlobalModel href "" "fl_server_core.models.model.GlobalModel"
              click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
            

Model class for SWAG models.

Attributes:

Name Type Description
first_moment Tensor

Gets the first moment of the SWAG model.

second_moment Tensor

Gets the second moment of the SWAG model.

swag_first_moment BinaryField

First moment of the SWAG model.

swag_second_moment BinaryField

Second moment of the SWAG model.

Source code in fl_server_core/models/model.py
class SWAGModel(GlobalModel):
    """
    Model class for SWAG models.
    """

    swag_first_moment: BinaryField = BinaryField()
    """First moment of the SWAG model."""
    swag_second_moment: BinaryField = BinaryField()
    """Second moment of the SWAG model."""

    @property
    def first_moment(self) -> Tensor:
        """
        Gets the first moment of the SWAG model.

        Returns:
            Tensor: The first moment of the SWAG model.
        """
        return to_torch_tensor(self.swag_first_moment)

    @first_moment.setter
    def first_moment(self, value: Tensor):
        """
        Sets the first moment of the SWAG model.

        Args:
            value (Tensor): The first moment of the SWAG model.
        """
        self.swag_first_moment = from_torch_tensor(value)

    @property
    def second_moment(self) -> Tensor:
        """
        Gets the second moment of the SWAG model.

        Returns:
            Tensor: The second moment of the SWAG model.
        """
        return to_torch_tensor(self.swag_second_moment)

    @second_moment.setter
    def second_moment(self, value: Tensor):
        """
        Sets the second moment of the SWAG model.

        Args:
            value (Tensor): The second moment of the SWAG model.
        """
        self.swag_second_moment = from_torch_tensor(value)

Attributes

first_moment property writable
first_moment: Tensor

Gets the first moment of the SWAG model.

Returns:

Name Type Description
Tensor Tensor

The first moment of the SWAG model.

second_moment property writable
second_moment: Tensor

Gets the second moment of the SWAG model.

Returns:

Name Type Description
Tensor Tensor

The second moment of the SWAG model.

swag_first_moment class-attribute instance-attribute
swag_first_moment: BinaryField = BinaryField()

First moment of the SWAG model.

swag_second_moment class-attribute instance-attribute
swag_second_moment: BinaryField = BinaryField()

Second moment of the SWAG model.

Training

Bases: Model


              flowchart TD
              fl_server_core.models.Training[Training]

              

              click fl_server_core.models.Training href "" "fl_server_core.models.Training"
            

Training model class.

Attributes:

Name Type Description
actor ForeignKey

User who is the actor of the training.

aggregation_method CharField

Aggregation method used in the training.

id UUIDField

Unique identifier for the training.

last_update

Time of the last update.

locked BooleanField

Flag indicating whether the training is locked.

model OneToOneField

Model used in the training.

options JSONField

Options for the training.

participants ManyToManyField

Users who are the participants of the training.

state CharField

State of the training.

target_num_updates IntegerField

Target number of updates for the training.

uncertainty_method CharField

Uncertainty method used in the training.

Source code in fl_server_core/models/training.py
class Training(models.Model):
    """
    Training model class.
    """

    id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)
    """Unique identifier for the training."""
    model: OneToOneField = OneToOneField(Model, on_delete=CASCADE)
    """Model used in the training."""
    actor: ForeignKey = ForeignKey(User, on_delete=CASCADE, related_name="actors")
    """User who is the actor of the training."""
    participants: ManyToManyField = ManyToManyField(User)
    """Users who are the participants of the training."""
    state: CharField = CharField(max_length=1, choices=TrainingState.choices)
    """State of the training."""
    target_num_updates: IntegerField = IntegerField()
    """Target number of updates for the training."""
    last_update = models.DateTimeField(auto_now=True)
    """Time of the last update."""
    uncertainty_method: CharField = CharField(
        max_length=32, choices=UncertaintyMethod.choices, default=UncertaintyMethod.NONE
    )
    """Uncertainty method used in the training."""
    aggregation_method: CharField = CharField(
        max_length=32, choices=AggregationMethod.choices, default=AggregationMethod.FED_AVG
    )
    """Aggregation method used in the training."""
    # HINT: https://docs.djangoproject.com/en/4.2/topics/db/queries/#querying-jsonfield
    options: JSONField = JSONField(default=dict, encoder=DjangoJSONEncoder)
    """Options for the training."""
    locked: BooleanField = BooleanField(default=False)
    """Flag indicating whether the training is locked."""

Attributes

actor class-attribute instance-attribute
actor: ForeignKey = ForeignKey(User, on_delete=CASCADE, related_name='actors')

User who is the actor of the training.

aggregation_method class-attribute instance-attribute
aggregation_method: CharField = CharField(max_length=32, choices=choices, default=FED_AVG)

Aggregation method used in the training.

id class-attribute instance-attribute
id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)

Unique identifier for the training.

last_update class-attribute instance-attribute
last_update = DateTimeField(auto_now=True)

Time of the last update.

locked class-attribute instance-attribute
locked: BooleanField = BooleanField(default=False)

Flag indicating whether the training is locked.

model class-attribute instance-attribute
model: OneToOneField = OneToOneField(Model, on_delete=CASCADE)

Model used in the training.

options class-attribute instance-attribute
options: JSONField = JSONField(default=dict, encoder=DjangoJSONEncoder)

Options for the training.

participants class-attribute instance-attribute
participants: ManyToManyField = ManyToManyField(User)

Users who are the participants of the training.

state class-attribute instance-attribute
state: CharField = CharField(max_length=1, choices=choices)

State of the training.

target_num_updates class-attribute instance-attribute
target_num_updates: IntegerField = IntegerField()

Target number of updates for the training.

uncertainty_method class-attribute instance-attribute
uncertainty_method: CharField = CharField(max_length=32, choices=choices, default=NONE)

Uncertainty method used in the training.

User

Bases: AbstractUser, NotificationReceiver


              flowchart TD
              fl_server_core.models.User[User]
              fl_server_core.models.user.NotificationReceiver[NotificationReceiver]

                              fl_server_core.models.user.NotificationReceiver --> fl_server_core.models.User
                


              click fl_server_core.models.User href "" "fl_server_core.models.User"
              click fl_server_core.models.user.NotificationReceiver href "" "fl_server_core.models.user.NotificationReceiver"
            

User class.

Inherits from Django's AbstractUser and NotificationReceiver.

Attributes:

Name Type Description
actor BooleanField

Flag indicating whether the user is an actor.

client BooleanField

Flag indicating whether the user is a client.

id UUIDField

Unique identifier for the user.

message_endpoint URLField

Endpoint to send the message to.

Source code in fl_server_core/models/user.py
class User(AbstractUser, NotificationReceiver):
    """
    User class.

    Inherits from Django's AbstractUser and NotificationReceiver.
    """

    id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)
    """Unique identifier for the user."""
    actor: BooleanField = BooleanField(default=False)
    """Flag indicating whether the user is an actor."""
    client: BooleanField = BooleanField(default=False)
    """Flag indicating whether the user is a client."""
    message_endpoint: URLField = URLField()
    """Endpoint to send the message to."""

Attributes

actor class-attribute instance-attribute
actor: BooleanField = BooleanField(default=False)

Flag indicating whether the user is an actor.

client class-attribute instance-attribute
client: BooleanField = BooleanField(default=False)

Flag indicating whether the user is a client.

id class-attribute instance-attribute
id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)

Unique identifier for the user.

message_endpoint class-attribute instance-attribute
message_endpoint: URLField = URLField()

Endpoint to send the message to.