flwr-nightly 1.10.0.dev20240714__py3-none-any.whl → 1.10.0.dev20240716__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 (32) hide show
  1. flwr/cli/build.py +16 -2
  2. flwr/cli/config_utils.py +23 -15
  3. flwr/cli/install.py +1 -1
  4. flwr/cli/new/templates/app/code/server.hf.py.tpl +4 -1
  5. flwr/cli/new/templates/app/code/server.jax.py.tpl +4 -1
  6. flwr/cli/new/templates/app/code/server.mlx.py.tpl +4 -1
  7. flwr/cli/new/templates/app/code/server.numpy.py.tpl +4 -1
  8. flwr/cli/new/templates/app/code/server.pytorch.py.tpl +4 -1
  9. flwr/cli/new/templates/app/code/server.sklearn.py.tpl +4 -1
  10. flwr/cli/new/templates/app/code/server.tensorflow.py.tpl +4 -1
  11. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +9 -12
  12. flwr/cli/new/templates/app/pyproject.hf.toml.tpl +10 -10
  13. flwr/cli/new/templates/app/pyproject.jax.toml.tpl +12 -6
  14. flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +10 -10
  15. flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +10 -10
  16. flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +10 -10
  17. flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +10 -10
  18. flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +10 -10
  19. flwr/cli/run/run.py +110 -57
  20. flwr/client/app.py +3 -3
  21. flwr/client/node_state.py +17 -3
  22. flwr/client/supernode/app.py +26 -15
  23. flwr/common/config.py +13 -4
  24. flwr/server/run_serverapp.py +1 -1
  25. flwr/server/superlink/fleet/vce/vce_api.py +52 -28
  26. flwr/simulation/run_simulation.py +184 -33
  27. flwr/superexec/simulation.py +157 -0
  28. {flwr_nightly-1.10.0.dev20240714.dist-info → flwr_nightly-1.10.0.dev20240716.dist-info}/METADATA +2 -1
  29. {flwr_nightly-1.10.0.dev20240714.dist-info → flwr_nightly-1.10.0.dev20240716.dist-info}/RECORD +32 -31
  30. {flwr_nightly-1.10.0.dev20240714.dist-info → flwr_nightly-1.10.0.dev20240716.dist-info}/LICENSE +0 -0
  31. {flwr_nightly-1.10.0.dev20240714.dist-info → flwr_nightly-1.10.0.dev20240716.dist-info}/WHEEL +0 -0
  32. {flwr_nightly-1.10.0.dev20240714.dist-info → flwr_nightly-1.10.0.dev20240716.dist-info}/entry_points.txt +0 -0
flwr/cli/build.py CHANGED
@@ -20,6 +20,7 @@ from pathlib import Path
20
20
  from typing import Optional
21
21
 
22
22
  import pathspec
23
+ import tomli_w
23
24
  import typer
24
25
  from typing_extensions import Annotated
25
26
 
@@ -85,7 +86,7 @@ def build(
85
86
 
86
87
  # Set the name of the zip file
87
88
  fab_filename = (
88
- f"{conf['flower']['publisher']}"
89
+ f"{conf['tool']['flwr']['app']['publisher']}"
89
90
  f".{directory.name}"
90
91
  f".{conf['project']['version'].replace('.', '-')}.fab"
91
92
  )
@@ -93,15 +94,28 @@ def build(
93
94
 
94
95
  allowed_extensions = {".py", ".toml", ".md"}
95
96
 
97
+ # Remove the 'federations' field from 'tool.flwr' if it exists
98
+ if (
99
+ "tool" in conf
100
+ and "flwr" in conf["tool"]
101
+ and "federations" in conf["tool"]["flwr"]
102
+ ):
103
+ del conf["tool"]["flwr"]["federations"]
104
+
105
+ toml_contents = tomli_w.dumps(conf)
106
+
96
107
  with zipfile.ZipFile(fab_filename, "w", zipfile.ZIP_DEFLATED) as fab_file:
108
+ fab_file.writestr("pyproject.toml", toml_contents)
109
+
110
+ # Continue with adding other files
97
111
  for root, _, files in os.walk(directory, topdown=True):
98
- # Filter directories and files based on .gitignore
99
112
  files = [
100
113
  f
101
114
  for f in files
102
115
  if not ignore_spec.match_file(Path(root) / f)
103
116
  and f != fab_filename
104
117
  and Path(f).suffix in allowed_extensions
118
+ and f != "pyproject.toml" # Exclude the original pyproject.toml
105
119
  ]
106
120
 
107
121
  for file in files:
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']['app']['publisher']}/{conf['project']['name']}",
64
64
  )
65
65
 
66
66
 
@@ -136,20 +136,28 @@ 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 (
140
+ "tool" not in config
141
+ or "flwr" not in config["tool"]
142
+ or "app" not in config["tool"]["flwr"]
143
+ ):
144
+ errors.append("Missing [tool.flwr.app] section")
141
145
  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")
146
+ if "publisher" not in config["tool"]["flwr"]["app"]:
147
+ errors.append('Property "publisher" missing in [tool.flwr.app]')
148
+ if "config" in config["tool"]["flwr"]["app"]:
149
+ _validate_run_config(config["tool"]["flwr"]["app"]["config"], errors)
150
+ if "components" not in config["tool"]["flwr"]["app"]:
151
+ errors.append("Missing [tool.flwr.app.components] section")
148
152
  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]')
153
+ if "serverapp" not in config["tool"]["flwr"]["app"]["components"]:
154
+ errors.append(
155
+ 'Property "serverapp" missing in [tool.flwr.app.components]'
156
+ )
157
+ if "clientapp" not in config["tool"]["flwr"]["app"]["components"]:
158
+ errors.append(
159
+ 'Property "clientapp" missing in [tool.flwr.app.components]'
160
+ )
153
161
 
154
162
  return len(errors) == 0, errors, warnings
155
163
 
@@ -165,14 +173,14 @@ def validate(
165
173
 
166
174
  # Validate serverapp
167
175
  is_valid, reason = object_ref.validate(
168
- config["flower"]["components"]["serverapp"], check_module
176
+ config["tool"]["flwr"]["app"]["components"]["serverapp"], check_module
169
177
  )
170
178
  if not is_valid and isinstance(reason, str):
171
179
  return False, [reason], []
172
180
 
173
181
  # Validate clientapp
174
182
  is_valid, reason = object_ref.validate(
175
- config["flower"]["components"]["clientapp"], check_module
183
+ config["tool"]["flwr"]["app"]["components"]["clientapp"], check_module
176
184
  )
177
185
 
178
186
  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"]["app"]["publisher"]
153
153
  project_name = config["project"]["name"]
154
154
  version = config["project"]["version"]
155
155
 
@@ -6,12 +6,15 @@ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
6
6
 
7
7
 
8
8
  def server_fn(context: Context):
9
+ # Read from config
10
+ num_rounds = int(context.run_config["num-server-rounds"])
11
+
9
12
  # Define strategy
10
13
  strategy = FedAvg(
11
14
  fraction_fit=1.0,
12
15
  fraction_evaluate=1.0,
13
16
  )
14
- config = ServerConfig(num_rounds=3)
17
+ config = ServerConfig(num_rounds=num_rounds)
15
18
 
16
19
  return ServerAppComponents(strategy=strategy, config=config)
17
20
 
@@ -6,9 +6,12 @@ from flwr.server import ServerApp, ServerAppComponents, ServerConfig
6
6
 
7
7
 
8
8
  def server_fn(context: Context):
9
+ # Read from config
10
+ num_rounds = int(context.run_config["num-server-rounds"])
11
+
9
12
  # Define strategy
10
13
  strategy = FedAvg()
11
- config = ServerConfig(num_rounds=3)
14
+ config = ServerConfig(num_rounds=num_rounds)
12
15
 
13
16
  return ServerAppComponents(strategy=strategy, config=config)
14
17
 
@@ -6,9 +6,12 @@ from flwr.server.strategy import FedAvg
6
6
 
7
7
 
8
8
  def server_fn(context: Context):
9
+ # Read from config
10
+ num_rounds = int(context.run_config["num-server-rounds"])
11
+
9
12
  # Define strategy
10
13
  strategy = FedAvg()
11
- config = ServerConfig(num_rounds=3)
14
+ config = ServerConfig(num_rounds=num_rounds)
12
15
 
13
16
  return ServerAppComponents(strategy=strategy, config=config)
14
17
 
@@ -6,9 +6,12 @@ from flwr.server.strategy import FedAvg
6
6
 
7
7
 
8
8
  def server_fn(context: Context):
9
+ # Read from config
10
+ num_rounds = int(context.run_config["num-server-rounds"])
11
+
9
12
  # Define strategy
10
13
  strategy = FedAvg()
11
- config = ServerConfig(num_rounds=3)
14
+ config = ServerConfig(num_rounds=num_rounds)
12
15
 
13
16
  return ServerAppComponents(strategy=strategy, config=config)
14
17
 
@@ -12,6 +12,9 @@ ndarrays = get_weights(Net())
12
12
  parameters = ndarrays_to_parameters(ndarrays)
13
13
 
14
14
  def server_fn(context: Context):
15
+ # Read from config
16
+ num_rounds = int(context.run_config["num-server-rounds"])
17
+
15
18
  # Define strategy
16
19
  strategy = FedAvg(
17
20
  fraction_fit=1.0,
@@ -19,7 +22,7 @@ def server_fn(context: Context):
19
22
  min_available_clients=2,
20
23
  initial_parameters=parameters,
21
24
  )
22
- config = ServerConfig(num_rounds=3)
25
+ config = ServerConfig(num_rounds=num_rounds)
23
26
 
24
27
  return ServerAppComponents(strategy=strategy, config=config)
25
28
 
@@ -6,13 +6,16 @@ from flwr.server.strategy import FedAvg
6
6
 
7
7
 
8
8
  def server_fn(context: Context):
9
+ # Read from config
10
+ num_rounds = int(context.run_config["num-server-rounds"])
11
+
9
12
  # Define strategy
10
13
  strategy = FedAvg(
11
14
  fraction_fit=1.0,
12
15
  fraction_evaluate=1.0,
13
16
  min_available_clients=2,
14
17
  )
15
- config = ServerConfig(num_rounds=3)
18
+ config = ServerConfig(num_rounds=num_rounds)
16
19
 
17
20
  return ServerAppComponents(strategy=strategy, config=config)
18
21
 
@@ -12,6 +12,9 @@ config = ServerConfig(num_rounds=3)
12
12
  parameters = ndarrays_to_parameters(load_model().get_weights())
13
13
 
14
14
  def server_fn(context: Context):
15
+ # Read from config
16
+ num_rounds = int(context.run_config["num-server-rounds"])
17
+
15
18
  # Define strategy
16
19
  strategy = strategy = FedAvg(
17
20
  fraction_fit=1.0,
@@ -19,7 +22,7 @@ def server_fn(context: Context):
19
22
  min_available_clients=2,
20
23
  initial_parameters=parameters,
21
24
  )
22
- config = ServerConfig(num_rounds=3)
25
+ config = ServerConfig(num_rounds=num_rounds)
23
26
 
24
27
  return ServerAppComponents(strategy=strategy, config=config)
25
28
 
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "flwr-datasets>=0.1.0,<1.0.0",
@@ -25,18 +22,18 @@ dependencies = [
25
22
  [tool.hatch.build.targets.wheel]
26
23
  packages = ["."]
27
24
 
28
- [flower]
25
+ [tool.flwr.app]
29
26
  publisher = "$username"
30
27
 
31
- [flower.components]
28
+ [tool.flwr.app.components]
32
29
  serverapp = "$import_name.app:server"
33
30
  clientapp = "$import_name.app:client"
34
31
 
35
- [flower.engine]
36
- name = "simulation"
32
+ [tool.flwr.app.config]
33
+ num-server-rounds = "3"
37
34
 
38
- [flower.engine.simulation.supernode]
39
- num = $num_clients
35
+ [tool.flwr.federations]
36
+ default = "localhost"
40
37
 
41
- [flower.engine.simulation]
42
- backend_config = { client_resources = { num_cpus = 8, num_gpus = 1.0 } }
38
+ [tool.flwr.federations.localhost]
39
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "flwr-datasets>=0.0.2,<1.0.0",
@@ -23,15 +20,18 @@ dependencies = [
23
20
  [tool.hatch.build.targets.wheel]
24
21
  packages = ["."]
25
22
 
26
- [flower]
23
+ [tool.flwr.app]
27
24
  publisher = "$username"
28
25
 
29
- [flower.components]
26
+ [tool.flwr.app.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.app.config]
31
+ num-server-rounds = "3"
32
+
33
+ [tool.flwr.federations]
34
+ default = "localhost"
35
35
 
36
- [flower.engine.simulation.supernode]
37
- num = 2
36
+ [tool.flwr.federations.localhost]
37
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = {text = "Apache License (2.0)"}
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "jax==0.4.26",
@@ -20,9 +17,18 @@ dependencies = [
20
17
  [tool.hatch.build.targets.wheel]
21
18
  packages = ["."]
22
19
 
23
- [flower]
20
+ [tool.flwr.app]
24
21
  publisher = "$username"
25
22
 
26
- [flower.components]
23
+ [tool.flwr.app.components]
27
24
  serverapp = "$import_name.server:app"
28
25
  clientapp = "$import_name.client:app"
26
+
27
+ [tool.flwr.app.config]
28
+ num-server-rounds = "3"
29
+
30
+ [tool.flwr.federations]
31
+ default = "localhost"
32
+
33
+ [tool.flwr.federations.localhost]
34
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "flwr-datasets[vision]>=0.0.2,<1.0.0",
@@ -20,15 +17,18 @@ dependencies = [
20
17
  [tool.hatch.build.targets.wheel]
21
18
  packages = ["."]
22
19
 
23
- [flower]
20
+ [tool.flwr.app]
24
21
  publisher = "$username"
25
22
 
26
- [flower.components]
23
+ [tool.flwr.app.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.app.config]
28
+ num-server-rounds = "3"
29
+
30
+ [tool.flwr.federations]
31
+ default = "localhost"
32
32
 
33
- [flower.engine.simulation.supernode]
34
- num = 2
33
+ [tool.flwr.federations.localhost]
34
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "numpy>=1.21.0",
@@ -18,15 +15,18 @@ dependencies = [
18
15
  [tool.hatch.build.targets.wheel]
19
16
  packages = ["."]
20
17
 
21
- [flower]
18
+ [tool.flwr.app]
22
19
  publisher = "$username"
23
20
 
24
- [flower.components]
21
+ [tool.flwr.app.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.app.config]
26
+ num-server-rounds = "3"
27
+
28
+ [tool.flwr.federations]
29
+ default = "localhost"
30
30
 
31
- [flower.engine.simulation.supernode]
32
- num = 2
31
+ [tool.flwr.federations.localhost]
32
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "flwr-datasets[vision]>=0.0.2,<1.0.0",
@@ -20,15 +17,18 @@ dependencies = [
20
17
  [tool.hatch.build.targets.wheel]
21
18
  packages = ["."]
22
19
 
23
- [flower]
20
+ [tool.flwr.app]
24
21
  publisher = "$username"
25
22
 
26
- [flower.components]
23
+ [tool.flwr.app.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.app.config]
28
+ num-server-rounds = "3"
29
+
30
+ [tool.flwr.federations]
31
+ default = "localhost"
32
32
 
33
- [flower.engine.simulation.supernode]
34
- num = 2
33
+ [tool.flwr.federations.localhost]
34
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "flwr-datasets[vision]>=0.0.2,<1.0.0",
@@ -19,15 +16,18 @@ dependencies = [
19
16
  [tool.hatch.build.targets.wheel]
20
17
  packages = ["."]
21
18
 
22
- [flower]
19
+ [tool.flwr.app]
23
20
  publisher = "$username"
24
21
 
25
- [flower.components]
22
+ [tool.flwr.app.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.app.config]
27
+ num-server-rounds = "3"
28
+
29
+ [tool.flwr.federations]
30
+ default = "localhost"
31
31
 
32
- [flower.engine.simulation.supernode]
33
- num = 2
32
+ [tool.flwr.federations.localhost]
33
+ options.num-supernodes = 10
@@ -6,10 +6,7 @@ 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
- license = { text = "Apache License (2.0)" }
9
+ license = "Apache-2.0"
13
10
  dependencies = [
14
11
  "flwr[simulation]>=1.9.0,<2.0",
15
12
  "flwr-datasets[vision]>=0.0.2,<1.0.0",
@@ -19,15 +16,18 @@ dependencies = [
19
16
  [tool.hatch.build.targets.wheel]
20
17
  packages = ["."]
21
18
 
22
- [flower]
19
+ [tool.flwr.app]
23
20
  publisher = "$username"
24
21
 
25
- [flower.components]
22
+ [tool.flwr.app.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.app.config]
27
+ num-server-rounds = "3"
28
+
29
+ [tool.flwr.federations]
30
+ default = "localhost"
31
31
 
32
- [flower.engine.simulation.supernode]
33
- num = 2
32
+ [tool.flwr.federations.localhost]
33
+ options.num-supernodes = 10