Skip to content

Commit

Permalink
feat(framework:skip) Update the LegacyContext to align with `Contex…
Browse files Browse the repository at this point in the history
…t` (#3858)

Co-authored-by: Daniel J. Beutel <[email protected]>
  • Loading branch information
panh99 and danieljanes authored Jul 22, 2024
1 parent fbb70c7 commit df1084f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion e2e/bare-client-auth/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def main(driver, context):
# Construct the LegacyContext
context = fl.server.LegacyContext(
state=context.state,
context=context,
config=fl.server.ServerConfig(num_rounds=3),
)

Expand Down
2 changes: 1 addition & 1 deletion e2e/bare-https/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def main(driver, context):
# Construct the LegacyContext
context = fl.server.LegacyContext(
state=context.state,
context=context,
config=fl.server.ServerConfig(num_rounds=3),
)

Expand Down
2 changes: 1 addition & 1 deletion e2e/framework-pandas/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def main(driver, context):
# Construct the LegacyContext
context = fl.server.LegacyContext(
state=context.state,
context=context,
config=fl.server.ServerConfig(num_rounds=3),
strategy=FedAnalytics(),
)
Expand Down
2 changes: 1 addition & 1 deletion e2e/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def record_state_metrics(metrics):
def main(driver, context):
# Construct the LegacyContext
context = fl.server.LegacyContext(
state=context.state,
context=context,
config=fl.server.ServerConfig(num_rounds=3),
)

Expand Down
2 changes: 1 addition & 1 deletion examples/app-pytorch/server_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def weighted_average(metrics: List[Tuple[int, Metrics]]) -> Metrics:
def main(driver: Driver, context: Context) -> None:
# Construct the LegacyContext
context = LegacyContext(
state=context.state,
context=context,
config=fl.server.ServerConfig(num_rounds=3),
strategy=strategy,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/app-secure-aggregation/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def main(driver: Driver, context: Context) -> None:
# Construct the LegacyContext
context = LegacyContext(
state=context.state,
context=context,
config=ServerConfig(num_rounds=3),
strategy=strategy,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/fl-dp-sa/fl_dp_sa/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def weighted_average(metrics: List[Tuple[int, Metrics]]) -> Metrics:
def main(driver: Driver, context: Context) -> None:
# Construct the LegacyContext
context = LegacyContext(
state=context.state,
context=context,
config=ServerConfig(num_rounds=3),
strategy=strategy,
)
Expand Down
9 changes: 5 additions & 4 deletions src/py/flwr/server/compat/legacy_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from dataclasses import dataclass
from typing import Optional

from flwr.common import Context, RecordSet
from flwr.common import Context

from ..client_manager import ClientManager, SimpleClientManager
from ..history import History
Expand All @@ -35,9 +35,9 @@ class LegacyContext(Context):
client_manager: ClientManager
history: History

def __init__(
def __init__( # pylint: disable=too-many-arguments
self,
state: RecordSet,
context: Context,
config: Optional[ServerConfig] = None,
strategy: Optional[Strategy] = None,
client_manager: Optional[ClientManager] = None,
Expand All @@ -52,4 +52,5 @@ def __init__(
self.strategy = strategy
self.client_manager = client_manager
self.history = History()
super().__init__(node_id=0, node_config={}, state=state, run_config={})

super().__init__(**vars(context))

0 comments on commit df1084f

Please sign in to comment.