flwr-nightly 1.15.0.dev20250123__py3-none-any.whl → 1.15.0.dev20250124__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/cli/config_utils.py CHANGED
@@ -182,7 +182,7 @@ def validate_certificate_in_federation_config(
182
182
  root_certificates_bytes = (app / root_certificates).read_bytes()
183
183
  if insecure := bool(insecure_str):
184
184
  typer.secho(
185
- "❌ `root_certificates` were provided but the `insecure` parameter "
185
+ "❌ `root-certificates` were provided but the `insecure` parameter "
186
186
  "is set to `True`.",
187
187
  fg=typer.colors.RED,
188
188
  bold=True,
flwr/cli/log.py CHANGED
@@ -187,7 +187,7 @@ def _log_with_exec_api(
187
187
  run_id: int,
188
188
  stream: bool,
189
189
  ) -> None:
190
- auth_plugin = try_obtain_cli_auth_plugin(app, federation)
190
+ auth_plugin = try_obtain_cli_auth_plugin(app, federation, federation_config)
191
191
  channel = init_channel(app, federation_config, auth_plugin)
192
192
 
193
193
  if stream:
flwr/cli/login/login.py CHANGED
@@ -65,6 +65,18 @@ def login( # pylint: disable=R0914
65
65
  federation, config, federation_config_overrides
66
66
  )
67
67
  exit_if_no_address(federation_config, "login")
68
+
69
+ # Check if `enable-user-auth` is set to `true`
70
+ if not federation_config.get("enable-user-auth", False):
71
+ typer.secho(
72
+ f"❌ User authentication is not enabled for the federation '{federation}'. "
73
+ "To enable it, set `enable-user-auth = true` in the federation "
74
+ "configuration.",
75
+ fg=typer.colors.RED,
76
+ bold=True,
77
+ )
78
+ raise typer.Exit(code=1)
79
+
68
80
  channel = init_channel(app, federation_config, None)
69
81
  stub = ExecStub(channel)
70
82
 
@@ -73,7 +85,9 @@ def login( # pylint: disable=R0914
73
85
 
74
86
  # Get the auth plugin
75
87
  auth_type = login_response.auth_type
76
- auth_plugin = try_obtain_cli_auth_plugin(app, federation, auth_type)
88
+ auth_plugin = try_obtain_cli_auth_plugin(
89
+ app, federation, federation_config, auth_type
90
+ )
77
91
  if auth_plugin is None:
78
92
  typer.secho(
79
93
  f'❌ Authentication type "{auth_type}" not found',
flwr/cli/ls.py CHANGED
@@ -123,7 +123,7 @@ def ls( # pylint: disable=too-many-locals, too-many-branches, R0913, R0917
123
123
  raise ValueError(
124
124
  "The options '--runs' and '--run-id' are mutually exclusive."
125
125
  )
126
- auth_plugin = try_obtain_cli_auth_plugin(app, federation)
126
+ auth_plugin = try_obtain_cli_auth_plugin(app, federation, federation_config)
127
127
  channel = init_channel(app, federation_config, auth_plugin)
128
128
  stub = ExecStub(channel)
129
129
 
flwr/cli/run/run.py CHANGED
@@ -158,7 +158,7 @@ def _run_with_exec_api(
158
158
  stream: bool,
159
159
  output_format: str,
160
160
  ) -> None:
161
- auth_plugin = try_obtain_cli_auth_plugin(app, federation)
161
+ auth_plugin = try_obtain_cli_auth_plugin(app, federation, federation_config)
162
162
  channel = init_channel(app, federation_config, auth_plugin)
163
163
  stub = ExecStub(channel)
164
164
 
flwr/cli/stop.py CHANGED
@@ -86,7 +86,7 @@ def stop( # pylint: disable=R0914
86
86
  exit_if_no_address(federation_config, "stop")
87
87
 
88
88
  try:
89
- auth_plugin = try_obtain_cli_auth_plugin(app, federation)
89
+ auth_plugin = try_obtain_cli_auth_plugin(app, federation, federation_config)
90
90
  channel = init_channel(app, federation_config, auth_plugin)
91
91
  stub = ExecStub(channel) # pylint: disable=unused-variable # noqa: F841
92
92
 
flwr/cli/utils.py CHANGED
@@ -217,25 +217,42 @@ def get_user_auth_config_path(root_dir: Path, federation: str) -> Path:
217
217
  def try_obtain_cli_auth_plugin(
218
218
  root_dir: Path,
219
219
  federation: str,
220
+ federation_config: dict[str, Any],
220
221
  auth_type: Optional[str] = None,
221
222
  ) -> Optional[CliAuthPlugin]:
222
223
  """Load the CLI-side user auth plugin for the given auth type."""
223
- config_path = get_user_auth_config_path(root_dir, federation)
224
-
225
- # Load the config file if it exists
226
- json_file: dict[str, Any] = {}
227
- if config_path.exists():
228
- with config_path.open("r", encoding="utf-8") as file:
229
- json_file = json.load(file)
230
- # This is the case when the user auth is not enabled
231
- elif auth_type is None:
224
+ # Check if user auth is enabled
225
+ if not federation_config.get("enable-user-auth", False):
232
226
  return None
233
227
 
228
+ # Check if TLS is enabled. If not, raise an error
229
+ if federation_config.get("root-certificates") is None:
230
+ typer.secho(
231
+ "❌ User authentication requires TLS to be enabled. "
232
+ "Please provide 'root-certificates' in the federation"
233
+ " configuration.",
234
+ fg=typer.colors.RED,
235
+ bold=True,
236
+ )
237
+ raise typer.Exit(code=1)
238
+
239
+ config_path = get_user_auth_config_path(root_dir, federation)
240
+
234
241
  # Get the auth type from the config if not provided
242
+ # auth_type will be None for all CLI commands except login
235
243
  if auth_type is None:
236
- if AUTH_TYPE not in json_file:
237
- return None
238
- auth_type = json_file[AUTH_TYPE]
244
+ try:
245
+ with config_path.open("r", encoding="utf-8") as file:
246
+ json_file = json.load(file)
247
+ auth_type = json_file[AUTH_TYPE]
248
+ except (FileNotFoundError, KeyError):
249
+ typer.secho(
250
+ "❌ Missing or invalid credentials for user authentication. "
251
+ "Please run `flwr login` to authenticate.",
252
+ fg=typer.colors.RED,
253
+ bold=True,
254
+ )
255
+ raise typer.Exit(code=1) from None
239
256
 
240
257
  # Retrieve auth plugin class and instantiate it
241
258
  try:
@@ -31,20 +31,20 @@ from flwr.common.constant import (
31
31
  from flwr.common.grpc import create_channel
32
32
  from flwr.common.logger import log
33
33
  from flwr.common.retry_invoker import _make_simple_grpc_retry_invoker, _wrap_stub
34
- from flwr.common.serde import message_from_taskres, message_to_taskins, run_from_proto
34
+ from flwr.common.serde import message_from_proto, message_to_proto, run_from_proto
35
35
  from flwr.common.typing import Run
36
+ from flwr.proto.message_pb2 import Message as ProtoMessage # pylint: disable=E0611
36
37
  from flwr.proto.node_pb2 import Node # pylint: disable=E0611
37
38
  from flwr.proto.run_pb2 import GetRunRequest, GetRunResponse # pylint: disable=E0611
38
39
  from flwr.proto.serverappio_pb2 import ( # pylint: disable=E0611
39
40
  GetNodesRequest,
40
41
  GetNodesResponse,
41
- PullTaskResRequest,
42
- PullTaskResResponse,
43
- PushTaskInsRequest,
44
- PushTaskInsResponse,
42
+ PullResMessagesRequest,
43
+ PullResMessagesResponse,
44
+ PushInsMessagesRequest,
45
+ PushInsMessagesResponse,
45
46
  )
46
47
  from flwr.proto.serverappio_pb2_grpc import ServerAppIoStub # pylint: disable=E0611
47
- from flwr.proto.task_pb2 import TaskIns # pylint: disable=E0611
48
48
 
49
49
  from .driver import Driver
50
50
 
@@ -196,22 +196,22 @@ class GrpcDriver(Driver):
196
196
  This method takes an iterable of messages and sends each message
197
197
  to the node specified in `dst_node_id`.
198
198
  """
199
- # Construct TaskIns
200
- task_ins_list: list[TaskIns] = []
199
+ # Construct Messages
200
+ message_proto_list: list[ProtoMessage] = []
201
201
  for msg in messages:
202
202
  # Check message
203
203
  self._check_message(msg)
204
- # Convert Message to TaskIns
205
- taskins = message_to_taskins(msg)
204
+ # Convert to proto
205
+ msg_proto = message_to_proto(msg)
206
206
  # Add to list
207
- task_ins_list.append(taskins)
207
+ message_proto_list.append(msg_proto)
208
208
  # Call GrpcDriverStub method
209
- res: PushTaskInsResponse = self._stub.PushTaskIns(
210
- PushTaskInsRequest(
211
- task_ins_list=task_ins_list, run_id=cast(Run, self._run).run_id
209
+ res: PushInsMessagesResponse = self._stub.PushMessages(
210
+ PushInsMessagesRequest(
211
+ messages_list=message_proto_list, run_id=cast(Run, self._run).run_id
212
212
  )
213
213
  )
214
- return list(res.task_ids)
214
+ return list(res.message_ids)
215
215
 
216
216
  def pull_messages(self, message_ids: Iterable[str]) -> Iterable[Message]:
217
217
  """Pull messages based on message IDs.
@@ -219,14 +219,15 @@ class GrpcDriver(Driver):
219
219
  This method is used to collect messages from the SuperLink that correspond to a
220
220
  set of given message IDs.
221
221
  """
222
- # Pull TaskRes
223
- res: PullTaskResResponse = self._stub.PullTaskRes(
224
- PullTaskResRequest(
225
- node=self.node, task_ids=message_ids, run_id=cast(Run, self._run).run_id
222
+ # Pull Messages
223
+ res: PullResMessagesResponse = self._stub.PullMessages(
224
+ PullResMessagesRequest(
225
+ message_ids=message_ids,
226
+ run_id=cast(Run, self._run).run_id,
226
227
  )
227
228
  )
228
- # Convert TaskRes to Message
229
- msgs = [message_from_taskres(taskres) for taskres in res.task_res_list]
229
+ # Convert Message from Protobuf representation
230
+ msgs = [message_from_proto(msg_proto) for msg_proto in res.messages_list]
230
231
  return msgs
231
232
 
232
233
  def send_and_receive(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.15.0.dev20250123
3
+ Version: 1.15.0.dev20250124
4
4
  Summary: Flower: A Friendly Federated AI Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -3,14 +3,14 @@ flwr/cli/__init__.py,sha256=cZJVgozlkC6Ni2Hd_FAIrqefrkCGOV18fikToq-6iLw,720
3
3
  flwr/cli/app.py,sha256=UeXrW5gxrUnFViDjAMIxGNZZKwu3a1oAj83v53IWIWM,1382
4
4
  flwr/cli/build.py,sha256=4P70i_FnUs0P21aTwjTXtFQSAfY-C04hUDF-2npfJdo,6345
5
5
  flwr/cli/cli_user_auth_interceptor.py,sha256=aZepPA298s-HjGmkJGMvI_uZe72O5aLC3jri-ilG53o,3126
6
- flwr/cli/config_utils.py,sha256=V1s5s6-r5GINYe__yA33wkPOGjnmdaM9faEuIRMOrd4,7518
6
+ flwr/cli/config_utils.py,sha256=LelRR960I36n1IPw7BIu79fKoOh0JePA58kAtoXSTH0,7518
7
7
  flwr/cli/constant.py,sha256=g7Ad7o3DJDkJNrWS0T3SSJETWSTkkVJWGpLM8zlbpcY,1289
8
8
  flwr/cli/example.py,sha256=uk5CoD0ZITgpY_ffsTbEKf8XOOCSUzByjHPcMSPqV18,2216
9
9
  flwr/cli/install.py,sha256=-RnrYGejN_zyXXp_CoddSQwoQfRTWWyt9WYlxphJzyU,8180
10
- flwr/cli/log.py,sha256=biR4Oz6C4ixwEjp2ybw_5QHtRO1Mip9Eb0FtQL3it_U,6652
10
+ flwr/cli/log.py,sha256=vcO-r5EIc127mOQ26uxKVITX-w_Zib7AxSVuuN70_JY,6671
11
11
  flwr/cli/login/__init__.py,sha256=6_9zOzbPOAH72K2wX3-9dXTAbS7Mjpa5sEn2lA6eHHI,800
12
- flwr/cli/login/login.py,sha256=JfqkSO9TGzbPlJ_znh9DQY9neQIzxyW60fOwX85fGQc,3319
13
- flwr/cli/ls.py,sha256=7oA-EIHm5LBKtdqV5rwwv3QnEoKXMDfIciKDbY-A9gs,11364
12
+ flwr/cli/login/login.py,sha256=EOU1E-89VPn5Ns7ytaDdGNVVeOoC4ULFjtNPogjXGGQ,3783
13
+ flwr/cli/ls.py,sha256=5KCHdctN5f5GkCAkbZSC1OuKdhmLzobINpltsdtDtQU,11383
14
14
  flwr/cli/new/__init__.py,sha256=pOQtPT9W4kCIttcKne5m-FtJbvTqdjTVJxzQ9AUYK8I,790
15
15
  flwr/cli/new/new.py,sha256=scyyKt8mzkc3El1bypgkHjKwVQEc2-q4I50PxriPFdI,9922
16
16
  flwr/cli/new/templates/__init__.py,sha256=4luU8RL-CK8JJCstQ_ON809W9bNTkY1l9zSaPKBkgwY,725
@@ -66,9 +66,9 @@ flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl,sha256=PA_dEtWkY6Wf3Ektc9D
66
66
  flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl,sha256=d7TwWH-QJN0j-9rs9zHnng_bHeHV7mk138KXqdv5BoE,686
67
67
  flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=r0SZnvoR5a5mEWKJIvQ3rW8C6-2DkhaC8A1fTA0avm0,710
68
68
  flwr/cli/run/__init__.py,sha256=cCsKVB0SFzh2b3QmGba6BHckB85xlhjh3mh4pBpACtY,790
69
- flwr/cli/run/run.py,sha256=l1RupVypUc51EoupUbnAxVLckFGkaGqanOY9zWHVfsY,8280
70
- flwr/cli/stop.py,sha256=qTRuU_fQgDlQKUOiWCKD7-vxFHBM8TJssrXGnkbaojo,4907
71
- flwr/cli/utils.py,sha256=RXozds-T7HN8yH0mMj67q-0YktdNNm83N9Ptu_pdhsc,10604
69
+ flwr/cli/run/run.py,sha256=kEOYKin9qPJy8SODxcAvIWk-OskKPsxvcbvhDhf2VD4,8299
70
+ flwr/cli/stop.py,sha256=DBCKg9AhB1WcJsyqfkHKR1_V_yT7D32zqa9QhmX9IAU,4926
71
+ flwr/cli/utils.py,sha256=z5WFbh2RwMirFcv6QtV_4rJlK7ad2XrUJUsinNhqE28,11310
72
72
  flwr/client/__init__.py,sha256=DGDoO0AEAfz-0CUFmLdyUUweAS64-07AOnmDfWUefK4,1192
73
73
  flwr/client/app.py,sha256=tNnef5wGVfqMiiGiWzAuULyy1QpvCKukiRmNi_a2cQc,34261
74
74
  flwr/client/client.py,sha256=8o58nd9o6ZFcMIaVYPGcV4MSjBG4H0oFgWiv8ZEO3oA,7895
@@ -226,7 +226,7 @@ flwr/server/compat/legacy_context.py,sha256=wBzBcfV6YO6IQGriM_FdJ5XZfiBBEEJdS_Od
226
226
  flwr/server/criterion.py,sha256=ypbAexbztzGUxNen9RCHF91QeqiEQix4t4Ih3E-42MM,1061
227
227
  flwr/server/driver/__init__.py,sha256=bikRv6CjTwSvYh7tf10gziU5o2YotOWhhftz2tr3KDc,886
228
228
  flwr/server/driver/driver.py,sha256=u_fMfqLYTroTafGCNwKPHI4lttRL-Z5CqeT3_FHSq-Q,5701
229
- flwr/server/driver/grpc_driver.py,sha256=jJBQOlbPXT-qn1MzjReyFGFPTA6WpiJQoiXISrkAVsc,9668
229
+ flwr/server/driver/grpc_driver.py,sha256=VYIbYavkJO2m6TcqStHr-pQLiyEoWlX8lsOsWfljZRQ,9758
230
230
  flwr/server/driver/inmemory_driver.py,sha256=b1U1PrB_Vpn--vav8SX-sn0THD9BTlV9UFIpuWTWLro,6665
231
231
  flwr/server/history.py,sha256=qSb5_pPTrwofpSYGsZWzMPkl_4uJ4mJFWesxXDrEvDU,5026
232
232
  flwr/server/run_serverapp.py,sha256=vIPhvJx0i5sEZO4IKM6ruCXmx4ncat76rh0B4KhdhhM,2446
@@ -325,8 +325,8 @@ flwr/superexec/exec_servicer.py,sha256=X10ILT-AoGMrB3IgI2mBe9i-QcIVUAl9bucuqVOPY
325
325
  flwr/superexec/exec_user_auth_interceptor.py,sha256=K06OU-l4LnYhTDg071hGJuOaQWEJbZsYi5qxUmmtiG0,3704
326
326
  flwr/superexec/executor.py,sha256=_B55WW2TD1fBINpabSSDRenVHXYmvlfhv-k8hJKU4lQ,3115
327
327
  flwr/superexec/simulation.py,sha256=WQDon15oqpMopAZnwRZoTICYCfHqtkvFSqiTQ2hLD_g,4088
328
- flwr_nightly-1.15.0.dev20250123.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
329
- flwr_nightly-1.15.0.dev20250123.dist-info/METADATA,sha256=K4ljj0Gg-RaK9xT0KwslcS2JTLR44qgOAo0_3W-2k_0,15864
330
- flwr_nightly-1.15.0.dev20250123.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
331
- flwr_nightly-1.15.0.dev20250123.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
332
- flwr_nightly-1.15.0.dev20250123.dist-info/RECORD,,
328
+ flwr_nightly-1.15.0.dev20250124.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
329
+ flwr_nightly-1.15.0.dev20250124.dist-info/METADATA,sha256=tr-JyBTsXNIUah1qY_BnD7Uhtsukv8Ktq5edbetabJs,15864
330
+ flwr_nightly-1.15.0.dev20250124.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
331
+ flwr_nightly-1.15.0.dev20250124.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
332
+ flwr_nightly-1.15.0.dev20250124.dist-info/RECORD,,