flwr-nightly 1.10.0.dev20240713__py3-none-any.whl → 1.10.0.dev20240715__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.

Files changed (34) hide show
  1. flwr/cli/build.py +1 -1
  2. flwr/cli/config_utils.py +15 -15
  3. flwr/cli/install.py +1 -1
  4. flwr/cli/new/templates/app/code/server.hf.py.tpl +13 -11
  5. flwr/cli/new/templates/app/code/server.jax.py.tpl +12 -8
  6. flwr/cli/new/templates/app/code/server.mlx.py.tpl +8 -7
  7. flwr/cli/new/templates/app/code/server.numpy.py.tpl +12 -8
  8. flwr/cli/new/templates/app/code/server.pytorch.py.tpl +13 -14
  9. flwr/cli/new/templates/app/code/server.sklearn.py.tpl +13 -10
  10. flwr/cli/new/templates/app/code/server.tensorflow.py.tpl +13 -13
  11. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +6 -12
  12. flwr/cli/new/templates/app/pyproject.hf.toml.tpl +6 -9
  13. flwr/cli/new/templates/app/pyproject.jax.toml.tpl +8 -5
  14. flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +6 -9
  15. flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +6 -9
  16. flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +6 -9
  17. flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +6 -9
  18. flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +6 -9
  19. flwr/cli/run/run.py +98 -57
  20. flwr/client/supernode/app.py +25 -14
  21. flwr/common/config.py +1 -1
  22. flwr/server/run_serverapp.py +1 -1
  23. flwr/server/superlink/fleet/vce/vce_api.py +45 -28
  24. flwr/simulation/run_simulation.py +42 -25
  25. flwr/superexec/app.py +11 -5
  26. flwr/superexec/deployment.py +85 -21
  27. flwr/superexec/exec_grpc.py +5 -2
  28. flwr/superexec/executor.py +18 -1
  29. flwr/superexec/simulation.py +157 -0
  30. {flwr_nightly-1.10.0.dev20240713.dist-info → flwr_nightly-1.10.0.dev20240715.dist-info}/METADATA +1 -1
  31. {flwr_nightly-1.10.0.dev20240713.dist-info → flwr_nightly-1.10.0.dev20240715.dist-info}/RECORD +34 -33
  32. {flwr_nightly-1.10.0.dev20240713.dist-info → flwr_nightly-1.10.0.dev20240715.dist-info}/LICENSE +0 -0
  33. {flwr_nightly-1.10.0.dev20240713.dist-info → flwr_nightly-1.10.0.dev20240715.dist-info}/WHEEL +0 -0
  34. {flwr_nightly-1.10.0.dev20240713.dist-info → flwr_nightly-1.10.0.dev20240715.dist-info}/entry_points.txt +0 -0
flwr/cli/build.py CHANGED
@@ -85,7 +85,7 @@ def build(
85
85
 
86
86
  # Set the name of the zip file
87
87
  fab_filename = (
88
- f"{conf['flower']['publisher']}"
88
+ f"{conf['tool']['flwr']['publisher']}"
89
89
  f".{directory.name}"
90
90
  f".{conf['project']['version'].replace('.', '-')}.fab"
91
91
  )
flwr/cli/config_utils.py CHANGED
@@ -60,7 +60,7 @@ def get_fab_metadata(fab_file: Union[Path, bytes]) -> Tuple[str, str]:
60
60
 
61
61
  return (
62
62
  conf["project"]["version"],
63
- f"{conf['flower']['publisher']}/{conf['project']['name']}",
63
+ f"{conf['tool']['flwr']['publisher']}/{conf['project']['name']}",
64
64
  )
65
65
 
66
66
 
@@ -136,20 +136,20 @@ def validate_fields(config: Dict[str, Any]) -> Tuple[bool, List[str], List[str]]
136
136
  if "authors" not in config["project"]:
137
137
  warnings.append('Recommended property "authors" missing in [project]')
138
138
 
139
- if "flower" not in config:
140
- errors.append("Missing [flower] section")
139
+ if "tool" not in config or "flwr" not in config["tool"]:
140
+ errors.append("Missing [tool.flwr] section")
141
141
  else:
142
- if "publisher" not in config["flower"]:
143
- errors.append('Property "publisher" missing in [flower]')
144
- if "config" in config["flower"]:
145
- _validate_run_config(config["flower"]["config"], errors)
146
- if "components" not in config["flower"]:
147
- errors.append("Missing [flower.components] section")
142
+ if "publisher" not in config["tool"]["flwr"]:
143
+ errors.append('Property "publisher" missing in [tool.flwr]')
144
+ if "config" in config["tool"]["flwr"]:
145
+ _validate_run_config(config["tool"]["flwr"]["config"], errors)
146
+ if "components" not in config["tool"]["flwr"]:
147
+ errors.append("Missing [tool.flwr.components] section")
148
148
  else:
149
- if "serverapp" not in config["flower"]["components"]:
150
- errors.append('Property "serverapp" missing in [flower.components]')
151
- if "clientapp" not in config["flower"]["components"]:
152
- errors.append('Property "clientapp" missing in [flower.components]')
149
+ if "serverapp" not in config["tool"]["flwr"]["components"]:
150
+ errors.append('Property "serverapp" missing in [tool.flwr.components]')
151
+ if "clientapp" not in config["tool"]["flwr"]["components"]:
152
+ errors.append('Property "clientapp" missing in [tool.flwr.components]')
153
153
 
154
154
  return len(errors) == 0, errors, warnings
155
155
 
@@ -165,14 +165,14 @@ def validate(
165
165
 
166
166
  # Validate serverapp
167
167
  is_valid, reason = object_ref.validate(
168
- config["flower"]["components"]["serverapp"], check_module
168
+ config["tool"]["flwr"]["components"]["serverapp"], check_module
169
169
  )
170
170
  if not is_valid and isinstance(reason, str):
171
171
  return False, [reason], []
172
172
 
173
173
  # Validate clientapp
174
174
  is_valid, reason = object_ref.validate(
175
- config["flower"]["components"]["clientapp"], check_module
175
+ config["tool"]["flwr"]["components"]["clientapp"], check_module
176
176
  )
177
177
 
178
178
  if not is_valid and isinstance(reason, str):
flwr/cli/install.py CHANGED
@@ -149,7 +149,7 @@ def validate_and_install(
149
149
  )
150
150
  raise typer.Exit(code=1)
151
151
 
152
- publisher = config["flower"]["publisher"]
152
+ publisher = config["tool"]["flwr"]["publisher"]
153
153
  project_name = config["project"]["name"]
154
154
  version = config["project"]["version"]
155
155
 
@@ -1,17 +1,19 @@
1
1
  """$project_name: A Flower / HuggingFace Transformers app."""
2
2
 
3
+ from flwr.common import Context
3
4
  from flwr.server.strategy import FedAvg
4
- from flwr.server import ServerApp, ServerConfig
5
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
5
6
 
6
7
 
7
- # Define strategy
8
- strategy = FedAvg(
9
- fraction_fit=1.0,
10
- fraction_evaluate=1.0,
11
- )
8
+ def server_fn(context: Context):
9
+ # Define strategy
10
+ strategy = FedAvg(
11
+ fraction_fit=1.0,
12
+ fraction_evaluate=1.0,
13
+ )
14
+ config = ServerConfig(num_rounds=3)
12
15
 
13
- # Start server
14
- app = ServerApp(
15
- config=ServerConfig(num_rounds=3),
16
- strategy=strategy,
17
- )
16
+ return ServerAppComponents(strategy=strategy, config=config)
17
+
18
+ # Create ServerApp
19
+ app = ServerApp(server_fn=server_fn)
@@ -1,12 +1,16 @@
1
1
  """$project_name: A Flower / JAX app."""
2
2
 
3
- import flwr as fl
3
+ from flwr.common import Context
4
+ from flwr.server.strategy import FedAvg
5
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
4
6
 
5
- # Configure the strategy
6
- strategy = fl.server.strategy.FedAvg()
7
7
 
8
- # Flower ServerApp
9
- app = fl.server.ServerApp(
10
- config=fl.server.ServerConfig(num_rounds=3),
11
- strategy=strategy,
12
- )
8
+ def server_fn(context: Context):
9
+ # Define strategy
10
+ strategy = FedAvg()
11
+ config = ServerConfig(num_rounds=3)
12
+
13
+ return ServerAppComponents(strategy=strategy, config=config)
14
+
15
+ # Create ServerApp
16
+ app = ServerApp(server_fn=server_fn)
@@ -1,15 +1,16 @@
1
1
  """$project_name: A Flower / MLX app."""
2
2
 
3
- from flwr.server import ServerApp, ServerConfig
3
+ from flwr.common import Context
4
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
4
5
  from flwr.server.strategy import FedAvg
5
6
 
6
7
 
7
- # Define strategy
8
- strategy = FedAvg()
8
+ def server_fn(context: Context):
9
+ # Define strategy
10
+ strategy = FedAvg()
11
+ config = ServerConfig(num_rounds=3)
9
12
 
13
+ return ServerAppComponents(strategy=strategy, config=config)
10
14
 
11
15
  # Create ServerApp
12
- app = ServerApp(
13
- config=ServerConfig(num_rounds=3),
14
- strategy=strategy,
15
- )
16
+ app = ServerApp(server_fn=server_fn)
@@ -1,12 +1,16 @@
1
1
  """$project_name: A Flower / NumPy app."""
2
2
 
3
- import flwr as fl
3
+ from flwr.common import Context
4
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
5
+ from flwr.server.strategy import FedAvg
4
6
 
5
- # Configure the strategy
6
- strategy = fl.server.strategy.FedAvg()
7
7
 
8
- # Flower ServerApp
9
- app = fl.server.ServerApp(
10
- config=fl.server.ServerConfig(num_rounds=1),
11
- strategy=strategy,
12
- )
8
+ def server_fn(context: Context):
9
+ # Define strategy
10
+ strategy = FedAvg()
11
+ config = ServerConfig(num_rounds=3)
12
+
13
+ return ServerAppComponents(strategy=strategy, config=config)
14
+
15
+ # Create ServerApp
16
+ app = ServerApp(server_fn=server_fn)
@@ -1,7 +1,7 @@
1
1
  """$project_name: A Flower / PyTorch app."""
2
2
 
3
- from flwr.common import ndarrays_to_parameters
4
- from flwr.server import ServerApp, ServerConfig
3
+ from flwr.common import Context, ndarrays_to_parameters
4
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
5
5
  from flwr.server.strategy import FedAvg
6
6
 
7
7
  from $import_name.task import Net, get_weights
@@ -11,18 +11,17 @@ from $import_name.task import Net, get_weights
11
11
  ndarrays = get_weights(Net())
12
12
  parameters = ndarrays_to_parameters(ndarrays)
13
13
 
14
+ def server_fn(context: Context):
15
+ # Define strategy
16
+ strategy = FedAvg(
17
+ fraction_fit=1.0,
18
+ fraction_evaluate=1.0,
19
+ min_available_clients=2,
20
+ initial_parameters=parameters,
21
+ )
22
+ config = ServerConfig(num_rounds=3)
14
23
 
15
- # Define strategy
16
- strategy = FedAvg(
17
- fraction_fit=1.0,
18
- fraction_evaluate=1.0,
19
- min_available_clients=2,
20
- initial_parameters=parameters,
21
- )
22
-
24
+ return ServerAppComponents(strategy=strategy, config=config)
23
25
 
24
26
  # Create ServerApp
25
- app = ServerApp(
26
- config=ServerConfig(num_rounds=3),
27
- strategy=strategy,
28
- )
27
+ app = ServerApp(server_fn=server_fn)
@@ -1,17 +1,20 @@
1
1
  """$project_name: A Flower / Scikit-Learn app."""
2
2
 
3
- from flwr.server import ServerApp, ServerConfig
3
+ from flwr.common import Context
4
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
4
5
  from flwr.server.strategy import FedAvg
5
6
 
6
7
 
7
- strategy = FedAvg(
8
- fraction_fit=1.0,
9
- fraction_evaluate=1.0,
10
- min_available_clients=2,
11
- )
8
+ def server_fn(context: Context):
9
+ # Define strategy
10
+ strategy = FedAvg(
11
+ fraction_fit=1.0,
12
+ fraction_evaluate=1.0,
13
+ min_available_clients=2,
14
+ )
15
+ config = ServerConfig(num_rounds=3)
16
+
17
+ return ServerAppComponents(strategy=strategy, config=config)
12
18
 
13
19
  # Create ServerApp
14
- app = ServerApp(
15
- config=ServerConfig(num_rounds=3),
16
- strategy=strategy,
17
- )
20
+ app = ServerApp(server_fn=server_fn)
@@ -1,7 +1,7 @@
1
1
  """$project_name: A Flower / TensorFlow app."""
2
2
 
3
- from flwr.common import ndarrays_to_parameters
4
- from flwr.server import ServerApp, ServerConfig
3
+ from flwr.common import Context, ndarrays_to_parameters
4
+ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
5
5
  from flwr.server.strategy import FedAvg
6
6
 
7
7
  from $import_name.task import load_model
@@ -11,17 +11,17 @@ config = ServerConfig(num_rounds=3)
11
11
 
12
12
  parameters = ndarrays_to_parameters(load_model().get_weights())
13
13
 
14
- # Define strategy
15
- strategy = FedAvg(
16
- fraction_fit=1.0,
17
- fraction_evaluate=1.0,
18
- min_available_clients=2,
19
- initial_parameters=parameters,
20
- )
14
+ def server_fn(context: Context):
15
+ # Define strategy
16
+ strategy = strategy = FedAvg(
17
+ fraction_fit=1.0,
18
+ fraction_evaluate=1.0,
19
+ min_available_clients=2,
20
+ initial_parameters=parameters,
21
+ )
22
+ config = ServerConfig(num_rounds=3)
21
23
 
24
+ return ServerAppComponents(strategy=strategy, config=config)
22
25
 
23
26
  # Create ServerApp
24
- app = ServerApp(
25
- config=config,
26
- strategy=strategy,
27
- )
27
+ app = ServerApp(server_fn=server_fn)
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -25,18 +22,15 @@ dependencies = [
25
22
  [tool.hatch.build.targets.wheel]
26
23
  packages = ["."]
27
24
 
28
- [flower]
25
+ [tool.flwr]
29
26
  publisher = "$username"
30
27
 
31
- [flower.components]
28
+ [tool.flwr.components]
32
29
  serverapp = "$import_name.app:server"
33
30
  clientapp = "$import_name.app:client"
34
31
 
35
- [flower.engine]
36
- name = "simulation"
37
-
38
- [flower.engine.simulation.supernode]
39
- num = $num_clients
32
+ [tool.flwr.federations]
33
+ default = "localhost"
40
34
 
41
- [flower.engine.simulation]
42
- backend_config = { client_resources = { num_cpus = 8, num_gpus = 1.0 } }
35
+ [tool.flwr.federations.localhost]
36
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -23,15 +20,15 @@ dependencies = [
23
20
  [tool.hatch.build.targets.wheel]
24
21
  packages = ["."]
25
22
 
26
- [flower]
23
+ [tool.flwr]
27
24
  publisher = "$username"
28
25
 
29
- [flower.components]
26
+ [tool.flwr.components]
30
27
  serverapp = "$import_name.server:app"
31
28
  clientapp = "$import_name.client:app"
32
29
 
33
- [flower.engine]
34
- name = "simulation"
30
+ [tool.flwr.federations]
31
+ default = "localhost"
35
32
 
36
- [flower.engine.simulation.supernode]
37
- num = 2
33
+ [tool.flwr.federations.localhost]
34
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = {text = "Apache License (2.0)"}
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -20,9 +17,15 @@ dependencies = [
20
17
  [tool.hatch.build.targets.wheel]
21
18
  packages = ["."]
22
19
 
23
- [flower]
20
+ [tool.flwr]
24
21
  publisher = "$username"
25
22
 
26
- [flower.components]
23
+ [tool.flwr.components]
27
24
  serverapp = "$import_name.server:app"
28
25
  clientapp = "$import_name.client:app"
26
+
27
+ [tool.flwr.federations]
28
+ default = "localhost"
29
+
30
+ [tool.flwr.federations.localhost]
31
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -20,15 +17,15 @@ dependencies = [
20
17
  [tool.hatch.build.targets.wheel]
21
18
  packages = ["."]
22
19
 
23
- [flower]
20
+ [tool.flwr]
24
21
  publisher = "$username"
25
22
 
26
- [flower.components]
23
+ [tool.flwr.components]
27
24
  serverapp = "$import_name.server:app"
28
25
  clientapp = "$import_name.client:app"
29
26
 
30
- [flower.engine]
31
- name = "simulation"
27
+ [tool.flwr.federations]
28
+ default = "localhost"
32
29
 
33
- [flower.engine.simulation.supernode]
34
- num = 2
30
+ [tool.flwr.federations.localhost]
31
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -18,15 +15,15 @@ dependencies = [
18
15
  [tool.hatch.build.targets.wheel]
19
16
  packages = ["."]
20
17
 
21
- [flower]
18
+ [tool.flwr]
22
19
  publisher = "$username"
23
20
 
24
- [flower.components]
21
+ [tool.flwr.components]
25
22
  serverapp = "$import_name.server:app"
26
23
  clientapp = "$import_name.client:app"
27
24
 
28
- [flower.engine]
29
- name = "simulation"
25
+ [tool.flwr.federations]
26
+ default = "localhost"
30
27
 
31
- [flower.engine.simulation.supernode]
32
- num = 2
28
+ [tool.flwr.federations.localhost]
29
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -20,15 +17,15 @@ dependencies = [
20
17
  [tool.hatch.build.targets.wheel]
21
18
  packages = ["."]
22
19
 
23
- [flower]
20
+ [tool.flwr]
24
21
  publisher = "$username"
25
22
 
26
- [flower.components]
23
+ [tool.flwr.components]
27
24
  serverapp = "$import_name.server:app"
28
25
  clientapp = "$import_name.client:app"
29
26
 
30
- [flower.engine]
31
- name = "simulation"
27
+ [tool.flwr.federations]
28
+ default = "localhost"
32
29
 
33
- [flower.engine.simulation.supernode]
34
- num = 2
30
+ [tool.flwr.federations.localhost]
31
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -19,15 +16,15 @@ dependencies = [
19
16
  [tool.hatch.build.targets.wheel]
20
17
  packages = ["."]
21
18
 
22
- [flower]
19
+ [tool.flwr]
23
20
  publisher = "$username"
24
21
 
25
- [flower.components]
22
+ [tool.flwr.components]
26
23
  serverapp = "$import_name.server:app"
27
24
  clientapp = "$import_name.client:app"
28
25
 
29
- [flower.engine]
30
- name = "simulation"
26
+ [tool.flwr.federations]
27
+ default = "localhost"
31
28
 
32
- [flower.engine.simulation.supernode]
33
- num = 2
29
+ [tool.flwr.federations.localhost]
30
+ options.num-supernodes = 10
@@ -6,9 +6,6 @@ build-backend = "hatchling.build"
6
6
  name = "$package_name"
7
7
  version = "1.0.0"
8
8
  description = ""
9
- authors = [
10
- { name = "The Flower Authors", email = "hello@flower.ai" },
11
- ]
12
9
  license = { text = "Apache License (2.0)" }
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
@@ -19,15 +16,15 @@ dependencies = [
19
16
  [tool.hatch.build.targets.wheel]
20
17
  packages = ["."]
21
18
 
22
- [flower]
19
+ [tool.flwr]
23
20
  publisher = "$username"
24
21
 
25
- [flower.components]
22
+ [tool.flwr.components]
26
23
  serverapp = "$import_name.server:app"
27
24
  clientapp = "$import_name.client:app"
28
25
 
29
- [flower.engine]
30
- name = "simulation"
26
+ [tool.flwr.federations]
27
+ default = "localhost"
31
28
 
32
- [flower.engine.simulation.supernode]
33
- num = 2
29
+ [tool.flwr.federations.localhost]
30
+ options.num-supernodes = 10