flwr-nightly 1.13.0.dev20241112__py3-none-any.whl → 1.13.0.dev20241113__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/common/date.py CHANGED
@@ -21,3 +21,21 @@ import datetime
21
21
  def now() -> datetime.datetime:
22
22
  """Construct a datetime from time.time() with time zone set to UTC."""
23
23
  return datetime.datetime.now(tz=datetime.timezone.utc)
24
+
25
+
26
+ def format_timedelta(td: datetime.timedelta) -> str:
27
+ """Format a timedelta as a string."""
28
+ days = td.days
29
+ hours, remainder = divmod(td.seconds, 3600)
30
+ minutes, seconds = divmod(remainder, 60)
31
+
32
+ if days > 0:
33
+ return f"{days}d {hours:02}:{minutes:02}:{seconds:02}"
34
+ return f"{hours:02}:{minutes:02}:{seconds:02}"
35
+
36
+
37
+ def isoformat8601_utc(dt: datetime.datetime) -> str:
38
+ """Return the datetime formatted as an ISO 8601 string with a trailing 'Z'."""
39
+ if dt.tzinfo != datetime.timezone.utc:
40
+ raise ValueError("Expected datetime with timezone set to UTC")
41
+ return dt.isoformat(timespec="seconds").replace("+00:00", "Z")
@@ -21,6 +21,7 @@ from typing import Optional
21
21
 
22
22
  from typing_extensions import override
23
23
 
24
+ from flwr.cli.config_utils import get_fab_metadata
24
25
  from flwr.common import ConfigsRecord, Context, RecordSet
25
26
  from flwr.common.constant import SERVERAPPIO_API_DEFAULT_ADDRESS, Status, SubStatus
26
27
  from flwr.common.logger import log
@@ -132,9 +133,10 @@ class DeploymentEngine(Executor):
132
133
  raise RuntimeError(
133
134
  f"FAB ({fab.hash_str}) hash from request doesn't match contents"
134
135
  )
136
+ fab_id, fab_version = get_fab_metadata(fab.content)
135
137
 
136
138
  run_id = self.linkstate.create_run(
137
- None, None, fab_hash, override_config, ConfigsRecord()
139
+ fab_id, fab_version, fab_hash, override_config, ConfigsRecord()
138
140
  )
139
141
  return run_id
140
142
 
@@ -21,6 +21,7 @@ from typing import Optional
21
21
 
22
22
  from typing_extensions import override
23
23
 
24
+ from flwr.cli.config_utils import get_fab_metadata
24
25
  from flwr.common import ConfigsRecord, Context, RecordSet
25
26
  from flwr.common.logger import log
26
27
  from flwr.common.typing import Fab, UserConfig
@@ -32,21 +33,11 @@ from .executor import Executor
32
33
 
33
34
 
34
35
  class SimulationEngine(Executor):
35
- """Simulation engine executor.
36
-
37
- Parameters
38
- ----------
39
- num_supernodes: Opitonal[str] (default: None)
40
- Total number of nodes to involve in the simulation.
41
- """
36
+ """Simulation engine executor."""
42
37
 
43
38
  def __init__(
44
39
  self,
45
- num_supernodes: Optional[int] = None,
46
- verbose: Optional[bool] = False,
47
40
  ) -> None:
48
- self.num_supernodes = num_supernodes
49
- self.verbose = verbose
50
41
  self.linkstate_factory: Optional[LinkStateFactory] = None
51
42
  self.ffs_factory: Optional[FfsFactory] = None
52
43
 
@@ -77,40 +68,7 @@ class SimulationEngine(Executor):
77
68
  self,
78
69
  config: UserConfig,
79
70
  ) -> None:
80
- """Set executor config arguments.
81
-
82
- Parameters
83
- ----------
84
- config : UserConfig
85
- A dictionary for configuration values.
86
- Supported configuration key/value pairs:
87
- - "num-supernodes": int
88
- Number of nodes to register for the simulation.
89
- - "verbose": bool
90
- Set verbosity of logs.
91
- """
92
- if num_supernodes := config.get("num-supernodes"):
93
- if not isinstance(num_supernodes, int):
94
- raise ValueError("The `num-supernodes` value should be of type `int`.")
95
- self.num_supernodes = num_supernodes
96
- elif self.num_supernodes is None:
97
- log(
98
- ERROR,
99
- "To start a run with the simulation plugin, please specify "
100
- "the number of SuperNodes. This can be done by using the "
101
- "`--executor-config` argument when launching the SuperExec.",
102
- )
103
- raise ValueError(
104
- "`num-supernodes` must not be `None`, it must be a valid "
105
- "positive integer."
106
- )
107
-
108
- if verbose := config.get("verbose"):
109
- if not isinstance(verbose, bool):
110
- raise ValueError(
111
- "The `verbose` value must be a string `true` or `false`."
112
- )
113
- self.verbose = verbose
71
+ """Set executor config arguments."""
114
72
 
115
73
  # pylint: disable=too-many-locals
116
74
  @override
@@ -122,6 +80,12 @@ class SimulationEngine(Executor):
122
80
  ) -> Optional[int]:
123
81
  """Start run using the Flower Simulation Engine."""
124
82
  try:
83
+ # Check that num-supernodes is set
84
+ if "num-supernodes" not in federation_options:
85
+ raise ValueError(
86
+ "Federation options doesn't contain key `num-supernodes`."
87
+ )
88
+
125
89
  # Create run
126
90
  fab = Fab(hashlib.sha256(fab_file).hexdigest(), fab_file)
127
91
  fab_hash = self.ffs.put(fab.content, {})
@@ -129,9 +93,10 @@ class SimulationEngine(Executor):
129
93
  raise RuntimeError(
130
94
  f"FAB ({fab.hash_str}) hash from request doesn't match contents"
131
95
  )
96
+ fab_id, fab_version = get_fab_metadata(fab.content)
132
97
 
133
98
  run_id = self.linkstate.create_run(
134
- None, None, fab_hash, override_config, federation_options
99
+ fab_id, fab_version, fab_hash, override_config, federation_options
135
100
  )
136
101
 
137
102
  # Create an empty context for the Run
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.13.0.dev20241112
3
+ Version: 1.13.0.dev20241113
4
4
  Summary: Flower: A Friendly Federated Learning Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -109,7 +109,7 @@ flwr/common/args.py,sha256=y9qtPIwyijegNi0GbQT5ddRtMUITM-DlgilC1Co-nvw,6133
109
109
  flwr/common/config.py,sha256=qC1QvGAGr4faBtg3Y5dWhfyK5FggyWUMjPqg-Rx_FW4,8083
110
110
  flwr/common/constant.py,sha256=D7MNLl1u-P7tJAMdT67xIujSeCibc2QzqtFoqCagoco,4731
111
111
  flwr/common/context.py,sha256=uJ-mnoC_8y_udEb3kAX-r8CPphNTWM72z1AlsvQEu54,2403
112
- flwr/common/date.py,sha256=uTvLmCkd3uVQuD4MviPHnIXMGyheL16mEI_UlOsv_R8,894
112
+ flwr/common/date.py,sha256=NHHpESce5wYqEwoDXf09gp9U9l_5Bmlh2BsOcwS-kDM,1554
113
113
  flwr/common/differential_privacy.py,sha256=XwcJ3rWr8S8BZUocc76vLSJAXIf6OHnWkBV6-xlIRuw,6106
114
114
  flwr/common/differential_privacy_constants.py,sha256=c7b7tqgvT7yMK0XN9ndiTBs4mQf6d3qk6K7KBZGlV4Q,1074
115
115
  flwr/common/dp.py,sha256=vddkvyjV2FhRoN4VuU2LeAM1UBn7dQB8_W-Qdiveal8,1978
@@ -315,13 +315,13 @@ flwr/simulation/run_simulation.py,sha256=BoG0lwaixe3g-xL4RZPl_6P47PKj2TiPHsDUtcN
315
315
  flwr/simulation/simulationio_connection.py,sha256=Uqtm2pRuZqEM8SxKS2TdBgsMUABSabhVIx9zzCPb_qc,3195
316
316
  flwr/superexec/__init__.py,sha256=fcj366jh4RFby_vDwLroU4kepzqbnJgseZD_jUr_Mko,715
317
317
  flwr/superexec/app.py,sha256=Tt3GonnTwHrMmicwx9XaP-crP78-bf4DUWl-N5cG6zY,1841
318
- flwr/superexec/deployment.py,sha256=C-NNclLE9OVJST6VRemtXv5N_vOoZeb77AQcMptCP6M,6511
318
+ flwr/superexec/deployment.py,sha256=e4yU0HSOEn0MqLnOwg8X1ViRJEJWUpD4u8pLAV_DU14,6631
319
319
  flwr/superexec/exec_grpc.py,sha256=OuhBAk7hiky9rjGceinLGIXqchtzGPQThZnwyYv6Ei0,2241
320
320
  flwr/superexec/exec_servicer.py,sha256=zNcdPkqLXgJIANKvE9uGIzgxocIs31WAj1YDnwqI6jo,3958
321
321
  flwr/superexec/executor.py,sha256=zH3_53il6Jh0ZscIVEB9f4GNnXMeBbCGyCoBCxLgiG0,3114
322
- flwr/superexec/simulation.py,sha256=NDFMDRidvp3Gz2MlgcWzkTrFHNAFfS94fTAdX_g7WzY,5370
323
- flwr_nightly-1.13.0.dev20241112.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
324
- flwr_nightly-1.13.0.dev20241112.dist-info/METADATA,sha256=yeDED4-E_qBqp8i2KaDoCQHr-gv2M3LAmo5oOT-MCR4,15701
325
- flwr_nightly-1.13.0.dev20241112.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
326
- flwr_nightly-1.13.0.dev20241112.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
327
- flwr_nightly-1.13.0.dev20241112.dist-info/RECORD,,
322
+ flwr/superexec/simulation.py,sha256=WQDon15oqpMopAZnwRZoTICYCfHqtkvFSqiTQ2hLD_g,4088
323
+ flwr_nightly-1.13.0.dev20241113.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
324
+ flwr_nightly-1.13.0.dev20241113.dist-info/METADATA,sha256=nGtH2E9gPhSSJlsVtTmf2iXu26szJ5s-iMXhkeDPIwg,15701
325
+ flwr_nightly-1.13.0.dev20241113.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
326
+ flwr_nightly-1.13.0.dev20241113.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
327
+ flwr_nightly-1.13.0.dev20241113.dist-info/RECORD,,