flwr 1.15.2__py3-none-any.whl → 1.17.0__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.
Files changed (120) hide show
  1. flwr/cli/build.py +2 -0
  2. flwr/cli/log.py +20 -21
  3. flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl +1 -1
  4. flwr/cli/new/templates/app/pyproject.baseline.toml.tpl +1 -1
  5. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +1 -1
  6. flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl +1 -1
  7. flwr/cli/new/templates/app/pyproject.jax.toml.tpl +1 -1
  8. flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +1 -1
  9. flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +1 -1
  10. flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +1 -1
  11. flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +1 -1
  12. flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +1 -1
  13. flwr/cli/run/run.py +5 -9
  14. flwr/client/app.py +6 -4
  15. flwr/client/client_app.py +260 -86
  16. flwr/client/clientapp/app.py +6 -2
  17. flwr/client/grpc_client/connection.py +24 -21
  18. flwr/client/message_handler/message_handler.py +28 -28
  19. flwr/client/mod/__init__.py +2 -2
  20. flwr/client/mod/centraldp_mods.py +7 -7
  21. flwr/client/mod/comms_mods.py +16 -22
  22. flwr/client/mod/localdp_mod.py +4 -4
  23. flwr/client/mod/secure_aggregation/secaggplus_mod.py +31 -31
  24. flwr/client/rest_client/connection.py +4 -6
  25. flwr/client/run_info_store.py +2 -2
  26. flwr/client/supernode/__init__.py +0 -2
  27. flwr/client/supernode/app.py +1 -11
  28. flwr/common/__init__.py +12 -4
  29. flwr/common/address.py +35 -0
  30. flwr/common/args.py +8 -2
  31. flwr/common/auth_plugin/auth_plugin.py +2 -1
  32. flwr/common/config.py +4 -4
  33. flwr/common/constant.py +16 -0
  34. flwr/common/context.py +4 -4
  35. flwr/common/event_log_plugin/__init__.py +22 -0
  36. flwr/common/event_log_plugin/event_log_plugin.py +60 -0
  37. flwr/common/grpc.py +1 -1
  38. flwr/common/logger.py +2 -2
  39. flwr/common/message.py +338 -102
  40. flwr/common/object_ref.py +0 -10
  41. flwr/common/record/__init__.py +8 -4
  42. flwr/common/record/arrayrecord.py +626 -0
  43. flwr/common/record/{configsrecord.py → configrecord.py} +75 -29
  44. flwr/common/record/conversion_utils.py +9 -18
  45. flwr/common/record/{metricsrecord.py → metricrecord.py} +78 -32
  46. flwr/common/record/recorddict.py +288 -0
  47. flwr/common/recorddict_compat.py +410 -0
  48. flwr/common/secure_aggregation/quantization.py +5 -1
  49. flwr/common/secure_aggregation/secaggplus_constants.py +1 -1
  50. flwr/common/serde.py +67 -190
  51. flwr/common/telemetry.py +0 -10
  52. flwr/common/typing.py +44 -8
  53. flwr/proto/exec_pb2.py +3 -3
  54. flwr/proto/exec_pb2.pyi +3 -3
  55. flwr/proto/message_pb2.py +12 -12
  56. flwr/proto/message_pb2.pyi +9 -9
  57. flwr/proto/recorddict_pb2.py +70 -0
  58. flwr/proto/{recordset_pb2.pyi → recorddict_pb2.pyi} +35 -35
  59. flwr/proto/run_pb2.py +31 -31
  60. flwr/proto/run_pb2.pyi +3 -3
  61. flwr/server/__init__.py +3 -1
  62. flwr/server/app.py +74 -3
  63. flwr/server/compat/__init__.py +2 -2
  64. flwr/server/compat/app.py +15 -12
  65. flwr/server/compat/app_utils.py +26 -18
  66. flwr/server/compat/{driver_client_proxy.py → grid_client_proxy.py} +41 -41
  67. flwr/server/fleet_event_log_interceptor.py +94 -0
  68. flwr/server/{driver → grid}/__init__.py +8 -7
  69. flwr/server/{driver/driver.py → grid/grid.py} +48 -19
  70. flwr/server/{driver/grpc_driver.py → grid/grpc_grid.py} +88 -56
  71. flwr/server/{driver/inmemory_driver.py → grid/inmemory_grid.py} +41 -54
  72. flwr/server/run_serverapp.py +6 -17
  73. flwr/server/server_app.py +126 -33
  74. flwr/server/serverapp/app.py +10 -10
  75. flwr/server/superlink/fleet/grpc_rere/fleet_servicer.py +2 -2
  76. flwr/server/superlink/fleet/message_handler/message_handler.py +8 -12
  77. flwr/server/superlink/fleet/vce/backend/backend.py +3 -3
  78. flwr/server/superlink/fleet/vce/backend/raybackend.py +2 -2
  79. flwr/server/superlink/fleet/vce/vce_api.py +33 -38
  80. flwr/server/superlink/linkstate/in_memory_linkstate.py +171 -132
  81. flwr/server/superlink/linkstate/linkstate.py +51 -64
  82. flwr/server/superlink/linkstate/sqlite_linkstate.py +253 -285
  83. flwr/server/superlink/linkstate/utils.py +171 -133
  84. flwr/server/superlink/{driver → serverappio}/__init__.py +1 -1
  85. flwr/server/superlink/{driver → serverappio}/serverappio_grpc.py +1 -1
  86. flwr/server/superlink/{driver → serverappio}/serverappio_servicer.py +27 -29
  87. flwr/server/superlink/simulation/simulationio_servicer.py +2 -2
  88. flwr/server/typing.py +3 -3
  89. flwr/server/utils/__init__.py +2 -2
  90. flwr/server/utils/validator.py +53 -68
  91. flwr/server/workflow/default_workflows.py +52 -58
  92. flwr/server/workflow/secure_aggregation/secaggplus_workflow.py +48 -50
  93. flwr/simulation/app.py +2 -2
  94. flwr/simulation/ray_transport/ray_actor.py +4 -2
  95. flwr/simulation/ray_transport/ray_client_proxy.py +34 -32
  96. flwr/simulation/run_simulation.py +15 -15
  97. flwr/superexec/app.py +0 -14
  98. flwr/superexec/deployment.py +4 -4
  99. flwr/superexec/exec_event_log_interceptor.py +135 -0
  100. flwr/superexec/exec_grpc.py +10 -4
  101. flwr/superexec/exec_servicer.py +6 -6
  102. flwr/superexec/exec_user_auth_interceptor.py +22 -4
  103. flwr/superexec/executor.py +3 -3
  104. flwr/superexec/simulation.py +3 -3
  105. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/METADATA +5 -5
  106. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/RECORD +111 -112
  107. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/entry_points.txt +0 -3
  108. flwr/client/message_handler/task_handler.py +0 -37
  109. flwr/common/record/parametersrecord.py +0 -204
  110. flwr/common/record/recordset.py +0 -202
  111. flwr/common/recordset_compat.py +0 -418
  112. flwr/proto/recordset_pb2.py +0 -70
  113. flwr/proto/task_pb2.py +0 -33
  114. flwr/proto/task_pb2.pyi +0 -100
  115. flwr/proto/task_pb2_grpc.py +0 -4
  116. flwr/proto/task_pb2_grpc.pyi +0 -4
  117. /flwr/proto/{recordset_pb2_grpc.py → recorddict_pb2_grpc.py} +0 -0
  118. /flwr/proto/{recordset_pb2_grpc.pyi → recorddict_pb2_grpc.pyi} +0 -0
  119. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/LICENSE +0 -0
  120. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/WHEEL +0 -0
flwr/cli/build.py CHANGED
@@ -138,6 +138,8 @@ def build(
138
138
  and f.name != "pyproject.toml" # Exclude the original pyproject.toml
139
139
  ]
140
140
 
141
+ all_files.sort()
142
+
141
143
  for file_path in all_files:
142
144
  # Read the file content manually
143
145
  with open(file_path, "rb") as f:
flwr/cli/log.py CHANGED
@@ -38,6 +38,10 @@ from flwr.proto.exec_pb2_grpc import ExecStub
38
38
  from .utils import init_channel, try_obtain_cli_auth_plugin, unauthenticated_exc_handler
39
39
 
40
40
 
41
+ class AllLogsRetrieved(BaseException):
42
+ """Raised when all logs are retrieved."""
43
+
44
+
41
45
  def start_stream(
42
46
  run_id: int, channel: grpc.Channel, refresh_period: int = CONN_REFRESH_PERIOD
43
47
  ) -> None:
@@ -56,10 +60,10 @@ def start_stream(
56
60
  # pylint: disable=E1101
57
61
  if e.code() == grpc.StatusCode.NOT_FOUND:
58
62
  logger(ERROR, "Invalid run_id `%s`, exiting", run_id)
59
- if e.code() == grpc.StatusCode.CANCELLED:
60
- pass
61
63
  else:
62
64
  raise e
65
+ except AllLogsRetrieved:
66
+ pass
63
67
  finally:
64
68
  channel.close()
65
69
 
@@ -94,6 +98,7 @@ def stream_logs(
94
98
  with unauthenticated_exc_handler():
95
99
  for res in stub.StreamLogs(req, timeout=duration):
96
100
  print(res.log_output, end="")
101
+ raise AllLogsRetrieved()
97
102
  except grpc.RpcError as e:
98
103
  # pylint: disable=E1101
99
104
  if e.code() != grpc.StatusCode.DEADLINE_EXCEEDED:
@@ -108,27 +113,21 @@ def stream_logs(
108
113
  def print_logs(run_id: int, channel: grpc.Channel, timeout: int) -> None:
109
114
  """Print logs from the beginning of a run."""
110
115
  stub = ExecStub(channel)
111
- req = StreamLogsRequest(run_id=run_id)
116
+ req = StreamLogsRequest(run_id=run_id, after_timestamp=0.0)
112
117
 
113
118
  try:
114
- while True:
115
- try:
116
- with unauthenticated_exc_handler():
117
- # Enforce timeout for graceful exit
118
- for res in stub.StreamLogs(req, timeout=timeout):
119
- print(res.log_output)
120
- except grpc.RpcError as e:
121
- # pylint: disable=E1101
122
- if e.code() == grpc.StatusCode.DEADLINE_EXCEEDED:
123
- break
124
- if e.code() == grpc.StatusCode.NOT_FOUND:
125
- logger(ERROR, "Invalid run_id `%s`, exiting", run_id)
126
- break
127
- if e.code() == grpc.StatusCode.CANCELLED:
128
- break
129
- raise e
130
- except KeyboardInterrupt:
131
- logger(DEBUG, "Stream interrupted by user")
119
+ with unauthenticated_exc_handler():
120
+ # Enforce timeout for graceful exit
121
+ for res in stub.StreamLogs(req, timeout=timeout):
122
+ print(res.log_output)
123
+ break
124
+ except grpc.RpcError as e:
125
+ if e.code() == grpc.StatusCode.NOT_FOUND: # pylint: disable=E1101
126
+ logger(ERROR, "Invalid run_id `%s`, exiting", run_id)
127
+ elif e.code() == grpc.StatusCode.DEADLINE_EXCEEDED: # pylint: disable=E1101
128
+ pass
129
+ else:
130
+ raise e
132
131
  finally:
133
132
  channel.close()
134
133
  logger(DEBUG, "Channel closed")
@@ -35,7 +35,7 @@ warnings.filterwarnings("ignore", category=UserWarning)
35
35
  # pylint: disable=too-many-arguments
36
36
  # pylint: disable=too-many-instance-attributes
37
37
  class FlowerClient(NumPyClient):
38
- """Standard Flower client for CNN training."""
38
+ """Flower client for LLM fine-tuning."""
39
39
 
40
40
  def __init__(
41
41
  self,
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets[vision]>=0.5.0",
13
13
  "torch==2.5.1",
14
14
  "torchvision==0.20.1",
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets>=0.5.0",
13
13
  "torch==2.3.1",
14
14
  "trl==0.8.1",
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets>=0.5.0",
13
13
  "torch==2.5.1",
14
14
  "transformers>=4.30.0,<5.0",
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "jax==0.4.30",
13
13
  "jaxlib==0.4.30",
14
14
  "scikit-learn==1.6.1",
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets[vision]>=0.5.0",
13
13
  "mlx==0.21.1",
14
14
  ]
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "numpy>=2.0.2",
13
13
  ]
14
14
 
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets[vision]>=0.5.0",
13
13
  "torch==2.5.1",
14
14
  "torchvision==0.20.1",
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets[vision]>=0.5.0",
13
13
  "scikit-learn>=1.6.1",
14
14
  ]
@@ -8,7 +8,7 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.15.2",
11
+ "flwr[simulation]>=1.17.0",
12
12
  "flwr-datasets[vision]>=0.5.0",
13
13
  "tensorflow>=2.11.1,<2.18.0",
14
14
  ]
flwr/cli/run/run.py CHANGED
@@ -35,15 +35,11 @@ from flwr.cli.constant import FEDERATION_CONFIG_HELP_MESSAGE
35
35
  from flwr.common.config import (
36
36
  flatten_dict,
37
37
  parse_config_args,
38
- user_config_to_configsrecord,
38
+ user_config_to_configrecord,
39
39
  )
40
40
  from flwr.common.constant import CliOutputFormat
41
41
  from flwr.common.logger import print_json_error, redirect_output, restore_output
42
- from flwr.common.serde import (
43
- configs_record_to_proto,
44
- fab_to_proto,
45
- user_config_to_proto,
46
- )
42
+ from flwr.common.serde import config_record_to_proto, fab_to_proto, user_config_to_proto
47
43
  from flwr.common.typing import Fab
48
44
  from flwr.proto.exec_pb2 import StartRunRequest # pylint: disable=E0611
49
45
  from flwr.proto.exec_pb2_grpc import ExecStub
@@ -171,14 +167,14 @@ def _run_with_exec_api(
171
167
 
172
168
  fab = Fab(fab_hash, content)
173
169
 
174
- # Construct a `ConfigsRecord` out of a flattened `UserConfig`
170
+ # Construct a `ConfigRecord` out of a flattened `UserConfig`
175
171
  fed_conf = flatten_dict(federation_config.get("options", {}))
176
- c_record = user_config_to_configsrecord(fed_conf)
172
+ c_record = user_config_to_configrecord(fed_conf)
177
173
 
178
174
  req = StartRunRequest(
179
175
  fab=fab_to_proto(fab),
180
176
  override_config=user_config_to_proto(parse_config_args(config_overrides)),
181
- federation_options=configs_record_to_proto(c_record),
177
+ federation_options=config_record_to_proto(c_record),
182
178
  )
183
179
  with unauthenticated_exc_handler():
184
180
  res = stub.StartRun(req)
flwr/client/app.py CHANGED
@@ -495,8 +495,9 @@ def start_client_internal(
495
495
  context = run_info_store.retrieve_context(run_id=run_id)
496
496
  # Create an error reply message that will never be used to prevent
497
497
  # the used-before-assignment linting error
498
- reply_message = message.create_error_reply(
499
- error=Error(code=ErrorCode.UNKNOWN, reason="Unknown")
498
+ reply_message = Message(
499
+ Error(code=ErrorCode.UNKNOWN, reason="Unknown"),
500
+ reply_to=message,
500
501
  )
501
502
 
502
503
  # Handle app loading and task message
@@ -593,8 +594,9 @@ def start_client_internal(
593
594
  log(ERROR, "%s raised an exception", exc_entity, exc_info=ex)
594
595
 
595
596
  # Create error message
596
- reply_message = message.create_error_reply(
597
- error=Error(code=e_code, reason=reason)
597
+ reply_message = Message(
598
+ Error(code=e_code, reason=reason),
599
+ reply_to=message,
598
600
  )
599
601
  else:
600
602
  # No exception, update node state