flwr-nightly 1.19.0.dev20250507__py3-none-any.whl → 1.19.0.dev20250508__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flwr/common/constant.py +4 -0
- flwr/common/inflatable.py +80 -0
- {flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/METADATA +1 -1
- {flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/RECORD +6 -5
- {flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/entry_points.txt +0 -0
flwr/common/constant.py
CHANGED
@@ -127,6 +127,10 @@ GRPC_RETRY_MAX_DELAY = 20 # Maximum delay duration between two consecutive retr
|
|
127
127
|
# Constants for ArrayRecord
|
128
128
|
GC_THRESHOLD = 200_000_000 # 200 MB
|
129
129
|
|
130
|
+
# Constants for Inflatable
|
131
|
+
HEAD_BODY_DIVIDER = b"\x00"
|
132
|
+
TYPE_BODY_LEN_DIVIDER = " "
|
133
|
+
|
130
134
|
|
131
135
|
class MessageType:
|
132
136
|
"""Message type."""
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# Copyright 2025 Flower Labs GmbH. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
# ==============================================================================
|
15
|
+
"""InflatableObject base class."""
|
16
|
+
|
17
|
+
|
18
|
+
import hashlib
|
19
|
+
from typing import TypeVar
|
20
|
+
|
21
|
+
from .constant import HEAD_BODY_DIVIDER, TYPE_BODY_LEN_DIVIDER
|
22
|
+
|
23
|
+
T = TypeVar("T", bound="InflatableObject")
|
24
|
+
|
25
|
+
|
26
|
+
class InflatableObject:
|
27
|
+
"""Base class for inflatable objects."""
|
28
|
+
|
29
|
+
def deflate(self) -> bytes:
|
30
|
+
"""Deflate object."""
|
31
|
+
raise NotImplementedError()
|
32
|
+
|
33
|
+
@property
|
34
|
+
def object_id(self) -> str:
|
35
|
+
"""Get object_id."""
|
36
|
+
return get_object_id(self.deflate())
|
37
|
+
|
38
|
+
|
39
|
+
def get_object_id(object_content: bytes) -> str:
|
40
|
+
"""Return a SHA-256 hash of the (deflated) object content."""
|
41
|
+
return hashlib.sha256(object_content).hexdigest()
|
42
|
+
|
43
|
+
|
44
|
+
def get_object_body(object_content: bytes, cls: type[T]) -> bytes:
|
45
|
+
"""Return object body but raise an error if object type doesn't match class name."""
|
46
|
+
class_name = cls.__qualname__
|
47
|
+
object_type = get_object_type_from_object_content(object_content)
|
48
|
+
if not object_type == class_name:
|
49
|
+
raise ValueError(
|
50
|
+
f"Class name ({class_name}) and object type "
|
51
|
+
f"({object_type}) do not match."
|
52
|
+
)
|
53
|
+
|
54
|
+
# Return object body
|
55
|
+
return _get_object_body(object_content)
|
56
|
+
|
57
|
+
|
58
|
+
def add_header_to_object_body(object_body: bytes, cls: T) -> bytes:
|
59
|
+
"""Add header to object content."""
|
60
|
+
# Construct header
|
61
|
+
header = f"{cls.__class__.__qualname__}{TYPE_BODY_LEN_DIVIDER}{len(object_body)}"
|
62
|
+
enc_header = header.encode(encoding="utf-8")
|
63
|
+
# Concatenate header and object body
|
64
|
+
return enc_header + HEAD_BODY_DIVIDER + object_body
|
65
|
+
|
66
|
+
|
67
|
+
def _get_object_head(object_content: bytes) -> bytes:
|
68
|
+
"""Return object head from object content."""
|
69
|
+
return object_content.split(HEAD_BODY_DIVIDER, 1)[0]
|
70
|
+
|
71
|
+
|
72
|
+
def _get_object_body(object_content: bytes) -> bytes:
|
73
|
+
"""Return object body from object content."""
|
74
|
+
return object_content.split(HEAD_BODY_DIVIDER, 1)[1]
|
75
|
+
|
76
|
+
|
77
|
+
def get_object_type_from_object_content(object_content: bytes) -> str:
|
78
|
+
"""Return object type from bytes."""
|
79
|
+
obj_head: str = _get_object_head(object_content).decode(encoding="utf-8")
|
80
|
+
return obj_head.split(TYPE_BODY_LEN_DIVIDER, 1)[0]
|
{flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: flwr-nightly
|
3
|
-
Version: 1.19.0.
|
3
|
+
Version: 1.19.0.dev20250508
|
4
4
|
Summary: Flower: A Friendly Federated AI Framework
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: Artificial Intelligence,Federated AI,Federated Analytics,Federated Evaluation,Federated Learning,Flower,Machine Learning
|
{flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/RECORD
RENAMED
@@ -115,7 +115,7 @@ flwr/common/args.py,sha256=-aX_jVnSaDrJR2KZ8Wq0Y3dQHII4R4MJtJOIXzVUA0c,5417
|
|
115
115
|
flwr/common/auth_plugin/__init__.py,sha256=m271m9YjK2QfKDOuIIhcTvGmv1GWh1PL97QB05NTSHs,887
|
116
116
|
flwr/common/auth_plugin/auth_plugin.py,sha256=GaXw4IiU2DkVNkp5S9ue821sbkU9zWSu6HSVZetEdjs,3938
|
117
117
|
flwr/common/config.py,sha256=glcZDjco-amw1YfQcYTFJ4S1pt9APoexT-mf1QscuHs,13960
|
118
|
-
flwr/common/constant.py,sha256=
|
118
|
+
flwr/common/constant.py,sha256=fQeR6Hz6ezE5kK6b0vAw85fHED72-ZBv7SGHkGj9hug,7216
|
119
119
|
flwr/common/context.py,sha256=Be8obQR_OvEDy1OmshuUKxGRQ7Qx89mf5F4xlhkR10s,2407
|
120
120
|
flwr/common/date.py,sha256=1ZT2cRSpC2DJqprOVTLXYCR_O2_OZR0zXO_brJ3LqWc,1554
|
121
121
|
flwr/common/differential_privacy.py,sha256=FdlpdpPl_H_2HJa8CQM1iCUGBBQ5Dc8CzxmHERM-EoE,6148
|
@@ -129,6 +129,7 @@ flwr/common/exit/exit_code.py,sha256=PNEnCrZfOILjfDAFu5m-2YWEJBrk97xglq4zCUlqV7E
|
|
129
129
|
flwr/common/exit_handlers.py,sha256=MEk5_savTLphn-6lW57UQlos-XrFA39XEBn-OF1vXXg,3174
|
130
130
|
flwr/common/grpc.py,sha256=manTaHaPiyYngUq1ErZvvV2B2GxlXUUUGRy3jc3TBIQ,9798
|
131
131
|
flwr/common/heartbeat.py,sha256=yzi-gWH5wswdg0hfQwxwGkjI5twxIHBBVW45MD5QITI,3924
|
132
|
+
flwr/common/inflatable.py,sha256=SPERmqeaUHeUr4JySWHQ7CUia8vCZxTC_S2OtwIsSXw,2779
|
132
133
|
flwr/common/logger.py,sha256=JbRf6E2vQxXzpDBq1T8IDUJo_usu3gjWEBPQ6uKcmdg,13049
|
133
134
|
flwr/common/message.py,sha256=znr205Erq2hkxwFbvNNCsQTRS2UKv_Qsyu0sFNEhEAw,23721
|
134
135
|
flwr/common/object_ref.py,sha256=p3SfTeqo3Aj16SkB-vsnNn01zswOPdGNBitcbRnqmUk,9134
|
@@ -331,7 +332,7 @@ flwr/superexec/exec_servicer.py,sha256=Z0YYfs6eNPhqn8rY0x_R04XgR2mKFpggt07IH0EhU
|
|
331
332
|
flwr/superexec/exec_user_auth_interceptor.py,sha256=iqygALkOMBUu_s_R9G0mFThZA7HTUzuXCLgxLCefiwI,4440
|
332
333
|
flwr/superexec/executor.py,sha256=M5ucqSE53jfRtuCNf59WFLqQvA1Mln4741TySeZE7qQ,3112
|
333
334
|
flwr/superexec/simulation.py,sha256=j6YwUvBN7EQ09ID7MYOCVZ70PGbuyBy8f9bXU0EszEM,4088
|
334
|
-
flwr_nightly-1.19.0.
|
335
|
-
flwr_nightly-1.19.0.
|
336
|
-
flwr_nightly-1.19.0.
|
337
|
-
flwr_nightly-1.19.0.
|
335
|
+
flwr_nightly-1.19.0.dev20250508.dist-info/METADATA,sha256=br7z9VS1iXUglNh4xLC9wnOQZeqosPkVn4HcPxEGMVs,15880
|
336
|
+
flwr_nightly-1.19.0.dev20250508.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
337
|
+
flwr_nightly-1.19.0.dev20250508.dist-info/entry_points.txt,sha256=2-1L-GNKhwGw2_7_RoH55vHw2SIHjdAQy3HAVAWl9PY,374
|
338
|
+
flwr_nightly-1.19.0.dev20250508.dist-info/RECORD,,
|
{flwr_nightly-1.19.0.dev20250507.dist-info → flwr_nightly-1.19.0.dev20250508.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|