flwr-nightly 1.18.0.dev20250412__py3-none-any.whl → 1.18.0.dev20250415__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/app.py CHANGED
@@ -14,10 +14,11 @@
14
14
  # ==============================================================================
15
15
  """Flower command line interface."""
16
16
 
17
-
18
17
  import typer
19
18
  from typer.main import get_command
20
19
 
20
+ from flwr.common.version import package_version
21
+
21
22
  from .build import build
22
23
  from .install import install
23
24
  from .log import log
@@ -34,6 +35,7 @@ app = typer.Typer(
34
35
  bold=True,
35
36
  ),
36
37
  no_args_is_help=True,
38
+ context_settings={"help_option_names": ["-h", "--help"]},
37
39
  )
38
40
 
39
41
  app.command()(new)
@@ -47,5 +49,22 @@ app.command()(login)
47
49
 
48
50
  typer_click_object = get_command(app)
49
51
 
52
+
53
+ @app.callback(invoke_without_command=True)
54
+ def version_callback(
55
+ ver: bool = typer.Option(
56
+ None,
57
+ "-V",
58
+ "--version",
59
+ is_eager=True,
60
+ help="Show the version and exit.",
61
+ ),
62
+ ) -> None:
63
+ """Print version."""
64
+ if ver:
65
+ typer.secho(f"Flower version: {package_version}", fg="blue")
66
+ raise typer.Exit()
67
+
68
+
50
69
  if __name__ == "__main__":
51
70
  app()
flwr/cli/config_utils.py CHANGED
@@ -176,11 +176,46 @@ def validate_federation_in_project_config(
176
176
  def validate_certificate_in_federation_config(
177
177
  app: Path, federation_config: dict[str, Any]
178
178
  ) -> tuple[bool, Optional[bytes]]:
179
- """Validate the certificates in the Flower project configuration."""
180
- insecure_str = federation_config.get("insecure")
179
+ """Validate the certificates in the Flower project configuration.
180
+
181
+ Accepted configurations:
182
+ 1. TLS enabled and gRPC will load(*) the trusted certificate bundle:
183
+ - Only `address` is provided. `root-certificates` and `insecure` not set.
184
+ - `address` is provided and `insecure` set to `false`. `root-certificates` not
185
+ set.
186
+ (*)gRPC uses a multi-step fallback mechanism to load the trusted certificate
187
+ bundle in the following sequence:
188
+ a. A configured file path (if set via configuration or environment),
189
+ b. An override callback (if registered via
190
+ `grpc_set_ssl_roots_override_callback`),
191
+ c. The OS trust store (if available),
192
+ d. A bundled default certificate file.
193
+ 2. TLS enabled with self-signed certificates:
194
+ - `address` and `root-certificates` are provided. `insecure` not set.
195
+ - `address` and `root-certificates` are provided. `insecure` set to `false`.
196
+ 3. TLS disabled. This is not recommended and should only be used for prototyping:
197
+ - `address` is provided and `insecure = true`. If `root-certificates` is
198
+ set, exit with an error.
199
+ """
200
+ insecure_value = federation_config.get("insecure")
201
+ # Determine the insecure flag
202
+ if insecure_value is None:
203
+ # Not provided, default to False (TLS enabled)
204
+ insecure = False
205
+ elif isinstance(insecure_value, bool):
206
+ insecure = insecure_value
207
+ else:
208
+ typer.secho(
209
+ "❌ Invalid type for `insecure`: expected a boolean if provided. "
210
+ "(`insecure = true` or `insecure = false`)",
211
+ fg=typer.colors.RED,
212
+ bold=True,
213
+ )
214
+ raise typer.Exit(code=1)
215
+
216
+ # Process root certificates
181
217
  if root_certificates := federation_config.get("root-certificates"):
182
- root_certificates_bytes = (app / root_certificates).read_bytes()
183
- if insecure := bool(insecure_str):
218
+ if insecure:
184
219
  typer.secho(
185
220
  "❌ `root-certificates` were provided but the `insecure` parameter "
186
221
  "is set to `True`.",
@@ -188,22 +223,19 @@ def validate_certificate_in_federation_config(
188
223
  bold=True,
189
224
  )
190
225
  raise typer.Exit(code=1)
191
- else:
192
- root_certificates_bytes = None
193
- if insecure_str is None:
194
- typer.secho(
195
- "❌ To disable TLS, set `insecure = true` in `pyproject.toml`.",
196
- fg=typer.colors.RED,
197
- bold=True,
198
- )
199
- raise typer.Exit(code=1)
200
- if not (insecure := bool(insecure_str)):
226
+
227
+ # TLS is enabled with self-signed certificates: attempt to read the file
228
+ try:
229
+ root_certificates_bytes = (app / root_certificates).read_bytes()
230
+ except Exception as e:
201
231
  typer.secho(
202
- "❌ No certificate were given yet `insecure` is set to `False`.",
232
+ f"❌ Failed to read certificate file `{root_certificates}`: {e}",
203
233
  fg=typer.colors.RED,
204
234
  bold=True,
205
235
  )
206
- raise typer.Exit(code=1)
236
+ raise typer.Exit(code=1) from e
237
+ else:
238
+ root_certificates_bytes = None
207
239
 
208
240
  return insecure, root_certificates_bytes
209
241
 
flwr/common/telemetry.py CHANGED
@@ -124,7 +124,7 @@ class EventType(str, Enum):
124
124
  # This method combined with auto() will set the property value to
125
125
  # the property name e.g.
126
126
  # `START_CLIENT = auto()` becomes `START_CLIENT = "START_CLIENT"`
127
- # The type signature is not compatible with mypy, pylint and flake8
127
+ # The type signature is not compatible with mypy and pylint
128
128
  # so each of those needs to be disabled for this line.
129
129
  # pylint: disable-next=no-self-argument,arguments-differ,line-too-long
130
130
  def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: # type: ignore # noqa: E501
@@ -37,7 +37,7 @@ from .aggregate import aggregate_bulyan, aggregate_krum
37
37
  from .fedavg import FedAvg
38
38
 
39
39
 
40
- # flake8: noqa: E501
40
+ # noqa: E501
41
41
  # pylint: disable=line-too-long
42
42
  class Bulyan(FedAvg):
43
43
  """Bulyan strategy.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.18.0.dev20250412
3
+ Version: 1.18.0.dev20250415
4
4
  Summary: Flower: A Friendly Federated AI Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -1,11 +1,11 @@
1
1
  flwr/__init__.py,sha256=5JdNd_I_ZxHJv2tbnM_Ug2_LQ4DkhZ2FiA7l23V13hU,937
2
2
  flwr/cli/__init__.py,sha256=EfMGmHoobET6P2blBt_eOByXL8299MgFfB7XNdaPQ6I,720
3
- flwr/cli/app.py,sha256=6ay_prkUbb0GmN0mvd-s-CCj8QAGAdHjiAFjZn5z7Yo,1382
3
+ flwr/cli/app.py,sha256=AKCP45Dkbpvdil_4Ir9S93L3HP3iUOnHmcZjscoM8uU,1856
4
4
  flwr/cli/auth_plugin/__init__.py,sha256=FyaoqPzcxlBTFfJ2sBRC5USwQLmAhFr5KuBwfMO4bmo,1052
5
5
  flwr/cli/auth_plugin/oidc_cli_plugin.py,sha256=gIhW6Jg9QAo-jL43LYPpw_kn7pdUZZae0s0H8dEgjLM,5384
6
6
  flwr/cli/build.py,sha256=sPzCAZC0gDytpDqMO3aHBcdCzQVXqRhts4TJYSZNu1E,6375
7
7
  flwr/cli/cli_user_auth_interceptor.py,sha256=-JqDXpeZNQVwoSG7hMKsiS5qY5k5oklNSlQOVpM0-aY,3126
8
- flwr/cli/config_utils.py,sha256=dkUXjaRPXAUlj5tFbnQWIhZCV7y4BryCbV4su9WypS0,7518
8
+ flwr/cli/config_utils.py,sha256=Si9nKXULxhk0qk5S-ocbu_Shh_EcIKtKrJ5zqb_Xwtg,8998
9
9
  flwr/cli/constant.py,sha256=g7Ad7o3DJDkJNrWS0T3SSJETWSTkkVJWGpLM8zlbpcY,1289
10
10
  flwr/cli/example.py,sha256=SNTorkKPrx1rOryGREUyZu8TcOc1-vFv1zEddaysdY0,2216
11
11
  flwr/cli/install.py,sha256=Jr883qR7qssVpUr3hEOEcLK-dfW67Rsve3lZchjA9RU,8180
@@ -152,7 +152,7 @@ flwr/common/secure_aggregation/quantization.py,sha256=ssFZpiRyj9ltIh0Ai3vGkDqWFO
152
152
  flwr/common/secure_aggregation/secaggplus_constants.py,sha256=dGYhWOBMMDJcQH4_tQNC8-Efqm-ecEUNN9ANz59UnCk,2182
153
153
  flwr/common/secure_aggregation/secaggplus_utils.py,sha256=E_xU-Zd45daO1em7M6C2wOjFXVtJf-6tl7fp-7xq1wo,3214
154
154
  flwr/common/serde.py,sha256=Paik5W4uAAfW1iVER8uKtxwc2Jdg7J86mnIdRbsZfrU,27082
155
- flwr/common/telemetry.py,sha256=pvrMSsjEHNglFBoVzH5TKcBrC9VtuaSwSIhifwy63-Y,8770
155
+ flwr/common/telemetry.py,sha256=jF47v0SbnBd43XamHtl3wKxs3knFUY2p77cm_2lzZ8M,8762
156
156
  flwr/common/typing.py,sha256=97QRfRRS7sQnjkAI5FDZ01-38oQUSz4i1qqewQmBWRg,6886
157
157
  flwr/common/version.py,sha256=7GAGzPn73Mkh09qhrjbmjZQtcqVhBuzhFBaK4Mk4VRk,1325
158
158
  flwr/proto/__init__.py,sha256=S3VbQzVwNC1P-3_9EdrXuwgptO-BVuuAe20Z_OUc1cQ,683
@@ -238,7 +238,7 @@ flwr/server/serverapp/app.py,sha256=6qdcXfkieNUS_ot16zntJHaJ570IiiyxtcdCGSOGiSs,
238
238
  flwr/server/serverapp_components.py,sha256=dfSqmrsVy3arKXpl3ZIBQWdV8rehfIms8aJooyzdmEM,2118
239
239
  flwr/server/strategy/__init__.py,sha256=HhsSWMWaC7oCb2g7Kqn1MBKdrfvgi8VxACy9ZL706Q0,2836
240
240
  flwr/server/strategy/aggregate.py,sha256=smlKKy-uFUuuFR12vlclucnwSQWRz78R79-Km4RWqbw,13978
241
- flwr/server/strategy/bulyan.py,sha256=iFmkqkWiZ73GVCOTOXDMECj2M-VGq-KnlUlV0vIn01Y,6513
241
+ flwr/server/strategy/bulyan.py,sha256=_QimaddzbAppHJHygKkzDQ_HmGEuZEs9wXtTl6NUWdg,6505
242
242
  flwr/server/strategy/dp_adaptive_clipping.py,sha256=txpJ8LmRRPe_exCeLkq2fKQmwSJDIyiJZ434b-exNXE,17453
243
243
  flwr/server/strategy/dp_fixed_clipping.py,sha256=dQrYm8kNnjZmNJUMjHCCHJGFOTmq9mxuaE04SptA8WM,12840
244
244
  flwr/server/strategy/dpfedavg_adaptive.py,sha256=VvZv2SzYP1S3Of-zA3XZY74P0BTP-Ag6ketspyZss3o,4888
@@ -326,7 +326,7 @@ flwr/superexec/exec_servicer.py,sha256=Z0YYfs6eNPhqn8rY0x_R04XgR2mKFpggt07IH0EhU
326
326
  flwr/superexec/exec_user_auth_interceptor.py,sha256=iqygALkOMBUu_s_R9G0mFThZA7HTUzuXCLgxLCefiwI,4440
327
327
  flwr/superexec/executor.py,sha256=M5ucqSE53jfRtuCNf59WFLqQvA1Mln4741TySeZE7qQ,3112
328
328
  flwr/superexec/simulation.py,sha256=j6YwUvBN7EQ09ID7MYOCVZ70PGbuyBy8f9bXU0EszEM,4088
329
- flwr_nightly-1.18.0.dev20250412.dist-info/METADATA,sha256=1w57LFnjgaPMyopGKYKpcJf1drxAkIzACgZgokIqE4s,15868
330
- flwr_nightly-1.18.0.dev20250412.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
331
- flwr_nightly-1.18.0.dev20250412.dist-info/entry_points.txt,sha256=2-1L-GNKhwGw2_7_RoH55vHw2SIHjdAQy3HAVAWl9PY,374
332
- flwr_nightly-1.18.0.dev20250412.dist-info/RECORD,,
329
+ flwr_nightly-1.18.0.dev20250415.dist-info/METADATA,sha256=M_-UYV8N42fp9WXUyTZUWUIOlKQlpZvNtaKjnb_2wDU,15868
330
+ flwr_nightly-1.18.0.dev20250415.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
331
+ flwr_nightly-1.18.0.dev20250415.dist-info/entry_points.txt,sha256=2-1L-GNKhwGw2_7_RoH55vHw2SIHjdAQy3HAVAWl9PY,374
332
+ flwr_nightly-1.18.0.dev20250415.dist-info/RECORD,,