Documentation for Noderole Module¶
Role
¶
Bases: Enum
This class defines the participant roles of the platform.
Source code in nebula/core/noderole.py
24 25 26 27 28 29 30 31 32 33 34 |
|
RoleBehavior
¶
Bases: ABC
Abstract base class for defining the role-specific behavior of a node in CFL, DFL, or SDFL systems.
Each subclass encapsulates the logic needed for a particular node role (e.g., trainer, aggregator), providing custom implementations for role-related operations such as training cycles, update aggregation, and recovery strategies.
Attributes:
Name | Type | Description |
---|---|---|
_next_role |
Role
|
The role to which the node is expected to transition. |
_next_role_locker |
Locker
|
An asynchronous lock to protect access to _next_role. |
_source_to_notificate |
Optional[Any]
|
The source node to notify once a role change is applied. |
Source code in nebula/core/noderole.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
extended_learning_cycle()
abstractmethod
async
¶
Performs the main learning or aggregation cycle associated with the current role.
This method encapsulates all the logic tied to the behavior of the node in its current role, including training, aggregating updates, and coordinating with neighbors.
Source code in nebula/core/noderole.py
92 93 94 95 96 97 98 99 100 |
|
get_next_role()
async
¶
Retrieves and clears the next role value.
Returns:
Name | Type | Description |
---|---|---|
Role |
Role
|
The next role to transition into. |
Source code in nebula/core/noderole.py
139 140 141 142 143 144 145 146 147 148 149 |
|
get_role()
abstractmethod
¶
Returns the Role enum value representing the current role of the node.
Source code in nebula/core/noderole.py
72 73 74 75 76 77 |
|
get_role_name(effective=False)
abstractmethod
¶
Returns a string representation of the current role.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
effective
|
bool
|
Whether to return the name of the current effective role when going as malicious. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
Name of the role. |
Source code in nebula/core/noderole.py
79 80 81 82 83 84 85 86 87 88 89 90 |
|
get_source_to_notificate()
async
¶
Retrieves and clears the stored source to notify after a role change.
Returns:
Name | Type | Description |
---|---|---|
Any |
The source node identifier, or None if not set. |
Source code in nebula/core/noderole.py
151 152 153 154 155 156 157 158 159 160 161 |
|
resolve_missing_updates()
abstractmethod
async
¶
Defines the fallback strategy when expected model updates are not received.
For example, an aggregator might default to a fresh model, while a trainer might proceed with its own local model.
Returns:
Name | Type | Description |
---|---|---|
Any |
The resolution outcome depending on the role's specific logic. |
Source code in nebula/core/noderole.py
114 115 116 117 118 119 120 121 122 123 124 125 |
|
select_nodes_to_wait()
abstractmethod
async
¶
Determines which neighbors the node should wait for during the current cycle.
This logic varies depending on whether the node is an aggregator, trainer, or other role.
Returns:
Type | Description |
---|---|
Set[Any]: A set of neighbor node identifiers to wait for. |
Source code in nebula/core/noderole.py
102 103 104 105 106 107 108 109 110 111 112 |
|
set_next_role(role, source_to_notificate=None)
async
¶
Schedules a role change and optionally stores the source to notify upon completion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role
|
Role
|
The new role to transition to. |
required |
source_to_notificate
|
Optional[Any]
|
Identifier of the node that triggered the change. |
None
|
Source code in nebula/core/noderole.py
127 128 129 130 131 132 133 134 135 136 137 |
|
update_role_needed()
async
¶
Checks whether a role update is scheduled.
Returns:
Name | Type | Description |
---|---|---|
bool |
True if a role update is pending, False otherwise. |
Source code in nebula/core/noderole.py
163 164 165 166 167 168 169 170 171 172 |
|