Skip to content

Commit

Permalink
Merge branch 'main' into change-override-config-type
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll authored Jul 17, 2024
2 parents b040fbe + e737515 commit 0ba8cfe
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/py/flwr/client/supernode/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def run_supernode() -> None:
authentication_keys=authentication_keys,
max_retries=args.max_retries,
max_wait_time=args.max_wait_time,
node_config=parse_config_args(args.node_config),
node_config=parse_config_args([args.node_config]),
flwr_path=get_flwr_dir(args.flwr_dir),
)

Expand Down Expand Up @@ -107,7 +107,7 @@ def run_client_app() -> None:

_start_client_internal(
server_address=args.superlink,
node_config=parse_config_args(args.node_config),
node_config=parse_config_args([args.node_config]),
load_client_app_fn=load_fn,
transport=args.transport,
root_certificates=root_certificates,
Expand Down
23 changes: 12 additions & 11 deletions src/py/flwr/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,17 @@ def parse_config_args(
return overrides

for config_line in config:
overrides_list = config_line.split(separator)
if (
len(overrides_list) == 1
and "=" not in overrides_list
and overrides_list[0].endswith(".toml")
):
with Path(overrides_list[0]).open("rb") as config_file:
overrides = flatten_dict(tomli.load(config_file))
else:
toml_str = "\n".join(overrides_list)
overrides.update(tomli.loads(toml_str))
if config_line:
overrides_list = config_line.split(separator)
if (
len(overrides_list) == 1
and "=" not in overrides_list
and overrides_list[0].endswith(".toml")
):
with Path(overrides_list[0]).open("rb") as config_file:
overrides = flatten_dict(tomli.load(config_file))
else:
toml_str = "\n".join(overrides_list)
overrides.update(tomli.loads(toml_str))

return overrides
2 changes: 1 addition & 1 deletion src/py/flwr/simulation/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def run_simulation_from_cli() -> None:
client_app_attr = app_components["clientapp"]
server_app_attr = app_components["serverapp"]

override_config = parse_config_args(args.run_config)
override_config = parse_config_args([args.run_config])
fused_config = get_fused_config_from_dir(app_path, override_config)
app_dir = args.app
is_app = True
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/superexec/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run_superexec() -> None:
address=address,
executor=_load_executor(args),
certificates=certificates,
config=parse_config_args(args.executor_config),
config=parse_config_args([args.executor_config]),
)

grpc_servers = [superexec_server]
Expand Down
14 changes: 5 additions & 9 deletions src/py/flwr/superexec/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,24 @@ def start_run(
"Config extracted from FAB's pyproject.toml is not valid"
)

# Get ClientApp and SeverApp components
flower_components = config["tool"]["flwr"]["app"]["components"]
clientapp = flower_components["clientapp"]
serverapp = flower_components["serverapp"]

# In Simulation there is no SuperLink, still we create a run_id
run_id = generate_rand_int_from_bytes(RUN_ID_NUM_BYTES)
log(INFO, "Created run %s", str(run_id))

# Prepare commnand
command = [
"flower-simulation",
"--client-app",
f"{clientapp}",
"--server-app",
f"{serverapp}",
"--app",
f"{str(fab_path)}",
"--num-supernodes",
f"{self.num_supernodes}",
"--run-id",
str(run_id),
]

if override_config:
command.extend(["--run-config", f"{override_config}"])

# Start Simulation
proc = subprocess.Popen( # pylint: disable=consider-using-with
command,
Expand Down

0 comments on commit 0ba8cfe

Please sign in to comment.