Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(framework) Send federation config to SuperExec #3838

Merged
merged 13 commits into from
Jul 23, 2024
Prev Previous commit
Next Next commit
Merge branch 'main' of https://github.com/adap/flower into add-option…
…s-config
charlesbvll committed Jul 22, 2024
commit d0bd69b6f9b58b02c89d4d04a1a23221574114e3
4 changes: 2 additions & 2 deletions src/proto/flwr/proto/exec.proto
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@ service Exec {

message StartRunRequest {
bytes fab_file = 1;
map<string, string> override_config = 2;
map<string, string> federation_config = 3;
map<string, Scalar> override_config = 2;
map<string, Scalar> federation_config = 3;
}
message StartRunResponse { sint64 run_id = 1; }
message StreamLogsRequest { sint64 run_id = 1; }
4 changes: 3 additions & 1 deletion src/py/flwr/cli/run/run.py
Original file line number Diff line number Diff line change
@@ -165,7 +165,9 @@ def on_channel_state_change(channel_connectivity: str) -> None:

req = StartRunRequest(
fab_file=Path(fab_path).read_bytes(),
override_config=parse_config_args(config_overrides, separator=","),
override_config=user_config_to_proto(
parse_config_args(config_overrides, separator=",")
),
federation_config=flatten_dict(federation.get("options")),
)
res = stub.StartRun(req)
6 changes: 2 additions & 4 deletions src/py/flwr/common/config.py
Original file line number Diff line number Diff line change
@@ -113,14 +113,12 @@ def get_fused_config(run: Run, flwr_dir: Optional[Path]) -> UserConfig:
return get_fused_config_from_dir(project_dir, run.override_config)


def flatten_dict(
raw_dict: Optional[Dict[str, Any]], parent_key: str = ""
) -> Dict[str, str]:
def flatten_dict(raw_dict: Dict[str, Any], parent_key: str = "") -> UserConfig:
"""Flatten dict by joining nested keys with a given separator."""
if raw_dict is None:
return {}

items: List[Tuple[str, str]] = []
items: List[Tuple[str, UserConfigValue]] = []
separator: str = "."
for k, v in raw_dict.items():
new_key = f"{parent_key}{separator}{k}" if parent_key else k
1 change: 0 additions & 1 deletion src/py/flwr/proto/exec_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/py/flwr/proto/exec_pb2.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
isort:skip_file
"""
import builtins
import flwr.proto.transport_pb2
import google.protobuf.descriptor
import google.protobuf.internal.containers
import google.protobuf.message
@@ -19,14 +18,12 @@ class StartRunRequest(google.protobuf.message.Message):
KEY_FIELD_NUMBER: builtins.int
VALUE_FIELD_NUMBER: builtins.int
key: typing.Text
@property
def value(self) -> flwr.proto.transport_pb2.Scalar: ...
value: typing.Text
def __init__(self,
*,
key: typing.Text = ...,
value: typing.Optional[flwr.proto.transport_pb2.Scalar] = ...,
value: typing.Text = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["value",b"value"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...

class FederationConfigEntry(google.protobuf.message.Message):
4 changes: 2 additions & 2 deletions src/py/flwr/superexec/deployment.py
Original file line number Diff line number Diff line change
@@ -134,8 +134,8 @@ def _create_run(
def start_run(
self,
fab_file: bytes,
override_config: Dict[str, str],
federation_config: Dict[str, str],
override_config: UserConfig,
federation_config: UserConfig,
) -> Optional[RunTracker]:
"""Start run using the Flower Deployment Engine."""
try:
4 changes: 2 additions & 2 deletions src/py/flwr/superexec/exec_servicer.py
Original file line number Diff line number Diff line change
@@ -48,8 +48,8 @@ def StartRun(

run = self.executor.start_run(
request.fab_file,
dict(request.override_config.items()),
dict(request.federation_config.items()),
user_config_from_proto(request.override_config),
user_config_from_proto(request.federation_config),
)

if run is None:
4 changes: 2 additions & 2 deletions src/py/flwr/superexec/executor.py
Original file line number Diff line number Diff line change
@@ -50,8 +50,8 @@ def set_config(
def start_run(
self,
fab_file: bytes,
override_config: Dict[str, str],
federation_config: Dict[str, str],
override_config: UserConfig,
federation_config: UserConfig,
) -> Optional[RunTracker]:
"""Start a run using the given Flower FAB ID and version.

4 changes: 2 additions & 2 deletions src/py/flwr/superexec/simulation.py
Original file line number Diff line number Diff line change
@@ -84,8 +84,8 @@ def set_config(
def start_run(
self,
fab_file: bytes,
override_config: Dict[str, str],
federation_config: Dict[str, str],
override_config: UserConfig,
federation_config: UserConfig,
) -> Optional[RunTracker]:
"""Start run using the Flower Simulation Engine."""
try:
You are viewing a condensed version of this merge commit. You can view the full changes here.