client.communication ¶
Classes:
| Name | Description |
|---|---|
Communication | Client communication module. |
Functions:
| Name | Description |
|---|---|
is_torchscript_instance | |
Attributes:
| Name | Type | Description |
|---|---|---|
T | |
Attributes¶
T module-attribute ¶
T = TypeVar('T', bound='Communication')
- API Reference
clientcommunication ClassesCommunication Functions
Classes¶
Communication ¶
Client communication module.
This module is responsible for the communication between the server and the client training/testing/etc. scripts.
- API Reference
clientclient AttributesCommunication
Methods:
| Name | Description |
|---|---|
__init__ | Create a new client communication module instance. |
download_model | Download the global model from the server. |
end_training | Start the end training procedure of the client. |
from_http_authorization | Create a new client communication module instance from a HTTP authorization header value. |
from_user_password | Create a new client communication module instance from a username and password. |
get_headers | Get default HTTP headers for the communication with the server. |
init_training | Start the initialization training procedure of the client. |
pack_model | Pack a model to a blob. |
start_testing | Start the trainings script to test the current global model. |
start_training | Start the trainings script to train the next round. |
unknown_message | Handle an unknown notification from the server. |
unpack_model | Unpack a model from a blob. |
upload_metrics | Upload the global model metrics to the server. |
upload_model | Upload the local model to the server including the metrics and the sample size. |
Attributes:
| Name | Type | Description |
|---|---|---|
client_id | UUID of the client. | |
http_authorization | HTTP authorization header value. | |
model_id | UUID of the global model. | |
round | Number of the training round. | |
training_id | UUID of the training. |
Source code in dlr/fl/client/communication.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
Attributes¶
http_authorization instance-attribute ¶
HTTP authorization header value.
Functions¶
__init__ ¶
__init__(client_id: UUID, training_id: UUID, round: int, model_id: UUID, http_authorization: str) -> None
Create a new client communication module instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the client | required |
| UUID | UUID of the training | required |
| int | number of the training round | required |
| UUID | UUID of the global model | required |
| str | HTTP authorization header value | required |
Source code in dlr/fl/client/communication.py
download_model ¶
download_model() -> Any
Download the global model from the server.
Raises:
| Type | Description |
|---|---|
ModelDownloadException | Model download failed |
Returns:
| Name | Type | Description |
|---|---|---|
Any | Any | global model |
Source code in dlr/fl/client/communication.py
end_training classmethod ¶
end_training(training_id: UUID, model_id: UUID) -> None
Start the end training procedure of the client. I.e. clean up and shutdown the client for the specific training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the training | required |
| UUID | UUID of the global model | required |
Source code in dlr/fl/client/communication.py
from_http_authorization classmethod ¶
from_http_authorization(client_id: UUID, training_id: UUID, round: int, model_id: UUID, http_authorization: str) -> T
Create a new client communication module instance from a HTTP authorization header value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the client | required |
| UUID | UUID of the training | required |
| int | number of the training round | required |
| UUID | UUID of the global model | required |
| str | HTTP authorization header value | required |
Returns:
| Name | Type | Description |
|---|---|---|
T | T | new client communication module instance |
Source code in dlr/fl/client/communication.py
from_user_password classmethod ¶
from_user_password(client_id: UUID, training_id: UUID, round: int, model_id: UUID, username: str, password: str) -> T
Create a new client communication module instance from a username and password.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the client | required |
| UUID | UUID of the training | required |
| int | number of the training round | required |
| UUID | UUID of the global model | required |
| str | Authorization username | required |
| str | Authorization password | required |
Returns:
| Name | Type | Description |
|---|---|---|
T | T | new client communication module instance |
Source code in dlr/fl/client/communication.py
get_headers ¶
init_training classmethod ¶
init_training(training_id: UUID, model_id: UUID) -> None
Start the initialization training procedure of the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the training | required |
| UUID | UUID of the global model | required |
Source code in dlr/fl/client/communication.py
pack_model ¶
Pack a model to a blob.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| Any | data (model) to pack | required |
Returns:
| Name | Type | Description |
|---|---|---|
bytes | bytes | data blob |
Source code in dlr/fl/client/communication.py
start_testing classmethod ¶
Start the trainings script to test the current global model.
Also see documentation of _start_script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the training | required |
| int | number of the training round | required |
| UUID | UUID of the global model | required |
Source code in dlr/fl/client/communication.py
start_training classmethod ¶
Start the trainings script to train the next round.
Also see documentation of _start_script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | UUID of the training | required |
| int | number of the training round | required |
| UUID | UUID of the global model | required |
Source code in dlr/fl/client/communication.py
unknown_message classmethod ¶
unknown_message(message_type: str, training_id: UUID, data: Any) -> int
Handle an unknown notification from the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| UUID | Type if the message | required |
| UUID | UUID of the training | required |
| Any | notification body | required |
Returns:
| Name | Type | Description |
|---|---|---|
int | int | http response status code |
Source code in dlr/fl/client/communication.py
unpack_model ¶
Unpack a model from a blob.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| bytes | data blob to unpack | required |
Returns:
| Name | Type | Description |
|---|---|---|
Any | Any | unpack model |
Source code in dlr/fl/client/communication.py
upload_metrics ¶
Upload the global model metrics to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| dict[str, Any] | metrics of the local model | required |
Raises:
| Type | Description |
|---|---|
MetricsUploadException | Metrics upload failed |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool |
|
Source code in dlr/fl/client/communication.py
upload_model ¶
Upload the local model to the server including the metrics and the sample size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| Any | local model | required |
| dict[str, Any] | metrics of the local model | required |
| int | sample size of the training data | required |
Raises:
| Type | Description |
|---|---|
ModelUploadException | Model upload failed |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool |
|