flwr-nightly 1.14.0.dev20241218__py3-none-any.whl → 1.14.0.dev20241219__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.

Potentially problematic release.


This version of flwr-nightly might be problematic. Click here for more details.

flwr/cli/utils.py CHANGED
@@ -22,7 +22,7 @@ from collections.abc import Iterator
22
22
  from contextlib import contextmanager
23
23
  from logging import DEBUG
24
24
  from pathlib import Path
25
- from typing import Any, Callable, Optional, cast
25
+ from typing import Any, Callable, Optional, Union, cast
26
26
 
27
27
  import grpc
28
28
  import typer
@@ -148,23 +148,69 @@ def sanitize_project_name(name: str) -> str:
148
148
  return sanitized_name
149
149
 
150
150
 
151
- def get_sha256_hash(file_path: Path) -> str:
151
+ def get_sha256_hash(file_path_or_int: Union[Path, int]) -> str:
152
152
  """Calculate the SHA-256 hash of a file."""
153
153
  sha256 = hashlib.sha256()
154
- with open(file_path, "rb") as f:
155
- while True:
156
- data = f.read(65536) # Read in 64kB blocks
157
- if not data:
158
- break
159
- sha256.update(data)
154
+ if isinstance(file_path_or_int, Path):
155
+ with open(file_path_or_int, "rb") as f:
156
+ while True:
157
+ data = f.read(65536) # Read in 64kB blocks
158
+ if not data:
159
+ break
160
+ sha256.update(data)
161
+ elif isinstance(file_path_or_int, int):
162
+ sha256.update(str(file_path_or_int).encode())
160
163
  return sha256.hexdigest()
161
164
 
162
165
 
163
166
  def get_user_auth_config_path(root_dir: Path, federation: str) -> Path:
164
- """Return the path to the user auth config file."""
167
+ """Return the path to the user auth config file.
168
+
169
+ Additionally, a `.gitignore` file will be created in the Flower directory to
170
+ include the `.credentials` folder to be excluded from git. If the `.gitignore`
171
+ file already exists, a warning will be displayed if the `.credentials` entry is
172
+ not found.
173
+ """
165
174
  # Locate the credentials directory
166
- credentials_dir = root_dir.absolute() / FLWR_DIR / CREDENTIALS_DIR
175
+ abs_flwr_dir = root_dir.absolute() / FLWR_DIR
176
+ credentials_dir = abs_flwr_dir / CREDENTIALS_DIR
167
177
  credentials_dir.mkdir(parents=True, exist_ok=True)
178
+
179
+ # Determine the absolute path of the Flower directory for .gitignore
180
+ gitignore_path = abs_flwr_dir / ".gitignore"
181
+ credential_entry = CREDENTIALS_DIR
182
+
183
+ try:
184
+ if gitignore_path.exists():
185
+ with open(gitignore_path, encoding="utf-8") as gitignore_file:
186
+ lines = gitignore_file.read().splitlines()
187
+
188
+ # Warn if .credentials is not already in .gitignore
189
+ if credential_entry not in lines:
190
+ typer.secho(
191
+ f"`.gitignore` exists, but `{credential_entry}` entry not found. "
192
+ "Consider adding it to your `.gitignore` to exclude Flower "
193
+ "credentials from git.",
194
+ fg=typer.colors.YELLOW,
195
+ bold=True,
196
+ )
197
+ else:
198
+ typer.secho(
199
+ f"Creating a new `.gitignore` with `{credential_entry}` entry...",
200
+ fg=typer.colors.BLUE,
201
+ )
202
+ # Create a new .gitignore with .credentials
203
+ with open(gitignore_path, "w", encoding="utf-8") as gitignore_file:
204
+ gitignore_file.write(f"{credential_entry}\n")
205
+ except Exception as err:
206
+ typer.secho(
207
+ "❌ An error occurred while handling `.gitignore.` "
208
+ f"Please check the permissions of `{gitignore_path}` and try again.",
209
+ fg=typer.colors.RED,
210
+ bold=True,
211
+ )
212
+ raise typer.Exit(code=1) from err
213
+
168
214
  return credentials_dir / f"{federation}.json"
169
215
 
170
216
 
flwr/server/app.py CHANGED
@@ -374,6 +374,7 @@ def run_superlink() -> None:
374
374
  server_public_key,
375
375
  ) = maybe_keys
376
376
  state = state_factory.state()
377
+ state.clear_supernode_auth_keys_and_credentials()
377
378
  state.store_node_public_keys(node_public_keys)
378
379
  state.store_server_private_public_key(
379
380
  private_key_to_bytes(server_private_key),
@@ -430,6 +430,13 @@ class InMemoryLinkState(LinkState): # pylint: disable=R0902,R0904
430
430
  """Retrieve `server_public_key` in urlsafe bytes."""
431
431
  return self.server_public_key
432
432
 
433
+ def clear_supernode_auth_keys_and_credentials(self) -> None:
434
+ """Clear stored `node_public_keys` and credentials in the link state if any."""
435
+ with self.lock:
436
+ self.server_private_key = None
437
+ self.server_public_key = None
438
+ self.node_public_keys.clear()
439
+
433
440
  def store_node_public_keys(self, public_keys: set[bytes]) -> None:
434
441
  """Store a set of `node_public_keys` in the link state."""
435
442
  with self.lock:
@@ -284,6 +284,10 @@ class LinkState(abc.ABC): # pylint: disable=R0904
284
284
  def get_server_public_key(self) -> Optional[bytes]:
285
285
  """Retrieve `server_public_key` in urlsafe bytes."""
286
286
 
287
+ @abc.abstractmethod
288
+ def clear_supernode_auth_keys_and_credentials(self) -> None:
289
+ """Clear stored `node_public_keys` and credentials in the link state if any."""
290
+
287
291
  @abc.abstractmethod
288
292
  def store_node_public_keys(self, public_keys: set[bytes]) -> None:
289
293
  """Store a set of `node_public_keys` in the link state."""
@@ -818,6 +818,12 @@ class SqliteLinkState(LinkState): # pylint: disable=R0904
818
818
  public_key = None
819
819
  return public_key
820
820
 
821
+ def clear_supernode_auth_keys_and_credentials(self) -> None:
822
+ """Clear stored `node_public_keys` and credentials in the link state if any."""
823
+ queries = ["DELETE FROM public_key;", "DELETE FROM credential;"]
824
+ for query in queries:
825
+ self.query(query)
826
+
821
827
  def store_node_public_keys(self, public_keys: set[bytes]) -> None:
822
828
  """Store a set of `node_public_keys` in the link state."""
823
829
  query = "INSERT INTO public_key (public_key) VALUES (?)"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.14.0.dev20241218
3
+ Version: 1.14.0.dev20241219
4
4
  Summary: Flower: A Friendly Federated AI Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -67,7 +67,7 @@ flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=KVCIOEYNWnq6j7XO
67
67
  flwr/cli/run/__init__.py,sha256=cCsKVB0SFzh2b3QmGba6BHckB85xlhjh3mh4pBpACtY,790
68
68
  flwr/cli/run/run.py,sha256=BvpjYyUvDhVMvO5cG711ihtdeSbls9p8zVAuFGETLA8,7893
69
69
  flwr/cli/stop.py,sha256=1T9RNRCH8dxjmBT38hFtKAWY9Gb7RMCMCML7kex9WzE,4613
70
- flwr/cli/utils.py,sha256=kko38Sci_yy5V5f8ZXwKyAzG-7BRlkKi2l2vlFOx5ug,8626
70
+ flwr/cli/utils.py,sha256=d15VkwxVK-NC1X-LVXXW3_O4-A38ZrlevwSNKNYpJCY,10592
71
71
  flwr/client/__init__.py,sha256=DGDoO0AEAfz-0CUFmLdyUUweAS64-07AOnmDfWUefK4,1192
72
72
  flwr/client/app.py,sha256=XJWu-kPswM52oLYXaOLKr0gj87KPNRI7M0Na9oBsDK4,34784
73
73
  flwr/client/client.py,sha256=8o58nd9o6ZFcMIaVYPGcV4MSjBG4H0oFgWiv8ZEO3oA,7895
@@ -211,7 +211,7 @@ flwr/proto/transport_pb2_grpc.py,sha256=vLN3EHtx2aEEMCO4f1Upu-l27BPzd3-5pV-u8wPc
211
211
  flwr/proto/transport_pb2_grpc.pyi,sha256=AGXf8RiIiW2J5IKMlm_3qT3AzcDa4F3P5IqUjve_esA,766
212
212
  flwr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
213
213
  flwr/server/__init__.py,sha256=cEg1oecBu4cKB69iJCqWEylC8b5XW47bl7rQiJsdTvM,1528
214
- flwr/server/app.py,sha256=t2N5Q2CEOptaCBxmos397Re9UDPDvNvgnXxNy7xqj-g,30944
214
+ flwr/server/app.py,sha256=qn5gdsDqvJ7o4ZiWpbNBHtYKSZiUJ7SiGfdkUEczTd4,31010
215
215
  flwr/server/client_manager.py,sha256=7Ese0tgrH-i-ms363feYZJKwB8gWnXSmg_hYF2Bju4U,6227
216
216
  flwr/server/client_proxy.py,sha256=4G-oTwhb45sfWLx2uZdcXD98IZwdTS6F88xe3akCdUg,2399
217
217
  flwr/server/compat/__init__.py,sha256=VxnJtJyOjNFQXMNi9hIuzNlZM5n0Hj1p3aq_Pm2udw4,892
@@ -285,10 +285,10 @@ flwr/server/superlink/fleet/vce/backend/backend.py,sha256=LBAQxnbfPAphVOVIvYMj0Q
285
285
  flwr/server/superlink/fleet/vce/backend/raybackend.py,sha256=jsUkFEVQTnrucK1jNQ_cUM8YwL7W4MQNA1GAf8ibRdg,7156
286
286
  flwr/server/superlink/fleet/vce/vce_api.py,sha256=VL6e_Jwf4uxA-X1EelxJZMv6Eji-_p2J9D0MdHG10a4,13029
287
287
  flwr/server/superlink/linkstate/__init__.py,sha256=v-2JyJlCB3qyhMNwMjmcNVOq4rkooqFU0LHH8Zo1jls,1064
288
- flwr/server/superlink/linkstate/in_memory_linkstate.py,sha256=haJiQ0TkinyVH4vOG-EUuEhhI78YESgjKYU6qVgXics,21638
289
- flwr/server/superlink/linkstate/linkstate.py,sha256=sbI7JLAZNMtVH1ZRjRjWDrws4mL0fjvrywxAKgCw9Mw,12936
288
+ flwr/server/superlink/linkstate/in_memory_linkstate.py,sha256=aGrowGU4mT3XxVbSiLVVzZUWJGvJq8esUucVvpL1lU0,21943
289
+ flwr/server/superlink/linkstate/linkstate.py,sha256=ayQY5eb-2InSldQUnVcx5ABjPU4QhQRV2lEVPVM_818,13114
290
290
  flwr/server/superlink/linkstate/linkstate_factory.py,sha256=ISSMjDlwuN7swxjOeYlTNpI_kuZ8PGkMcJnf1dbhUSE,2069
291
- flwr/server/superlink/linkstate/sqlite_linkstate.py,sha256=q_XyGRxL6vTT-fe0L6dKnPEZq0ARIT4D_ytGajU9Zzk,42592
291
+ flwr/server/superlink/linkstate/sqlite_linkstate.py,sha256=svP5Vj6Jaq1iazd6q0wWQU0lJslfIJT0XBw8mA1SABs,42879
292
292
  flwr/server/superlink/linkstate/utils.py,sha256=d5uqqIOCKfd54X8CFNfUr3AWqPLpgmzsC_RagRwFugM,13321
293
293
  flwr/server/superlink/simulation/__init__.py,sha256=mg-oapC9dkzEfjXPQFior5lpWj4g9kwbLovptyYM_g0,718
294
294
  flwr/server/superlink/simulation/simulationio_grpc.py,sha256=5wflYW_TS0mjmPG6OYuHMJwXD2_cYmUNhFkdOU0jMWQ,2237
@@ -321,8 +321,8 @@ flwr/superexec/exec_servicer.py,sha256=8tFwj1fDBF6PzwLhByTlxM-KNZc83bG1UdE92-8DS
321
321
  flwr/superexec/exec_user_auth_interceptor.py,sha256=K06OU-l4LnYhTDg071hGJuOaQWEJbZsYi5qxUmmtiG0,3704
322
322
  flwr/superexec/executor.py,sha256=_B55WW2TD1fBINpabSSDRenVHXYmvlfhv-k8hJKU4lQ,3115
323
323
  flwr/superexec/simulation.py,sha256=WQDon15oqpMopAZnwRZoTICYCfHqtkvFSqiTQ2hLD_g,4088
324
- flwr_nightly-1.14.0.dev20241218.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
325
- flwr_nightly-1.14.0.dev20241218.dist-info/METADATA,sha256=OSYXFna7UXZ--z0ROCP7Y6Nd9nUIn1HQoy1KzRu-Wm4,15799
326
- flwr_nightly-1.14.0.dev20241218.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
327
- flwr_nightly-1.14.0.dev20241218.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
328
- flwr_nightly-1.14.0.dev20241218.dist-info/RECORD,,
324
+ flwr_nightly-1.14.0.dev20241219.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
325
+ flwr_nightly-1.14.0.dev20241219.dist-info/METADATA,sha256=MrzB3rgo1I9lerAuVmhkHS8hWfQ7nf2tnRYSdrk4I58,15799
326
+ flwr_nightly-1.14.0.dev20241219.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
327
+ flwr_nightly-1.14.0.dev20241219.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
328
+ flwr_nightly-1.14.0.dev20241219.dist-info/RECORD,,