Skip to content

Commit

Permalink
mv fwd and bwd to client/typing.py
Browse files Browse the repository at this point in the history
  • Loading branch information
panh99 committed Nov 30, 2023
1 parent eaa7ff9 commit b67702f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/vertical-fl/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def client_fn(cid):

results_dir = Path("_static/results")
results_dir.mkdir(exist_ok=True)
np.save(str(results_dir/"hist.npy"), hist)
np.save(str(results_dir / "hist.npy"), hist)
26 changes: 2 additions & 24 deletions src/py/flwr/client/flower.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,10 @@


import importlib
from dataclasses import dataclass
from typing import Callable, cast
from typing import cast

from flwr.client.message_handler.message_handler import handle
from flwr.client.typing import ClientFn
from flwr.client.workload_state import WorkloadState
from flwr.proto.task_pb2 import TaskIns, TaskRes


@dataclass
class Fwd:
"""."""

task_ins: TaskIns
state: WorkloadState


@dataclass
class Bwd:
"""."""

task_res: TaskRes
state: WorkloadState


FlowerCallable = Callable[[Fwd], Bwd]
from flwr.client.typing import Bwd, ClientFn, Fwd


class Flower:
Expand Down
22 changes: 22 additions & 0 deletions src/py/flwr/client/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,30 @@
# ==============================================================================
"""Custom types for Flower clients."""

from dataclasses import dataclass
from typing import Callable

from flwr.client.workload_state import WorkloadState
from flwr.proto.task_pb2 import TaskIns, TaskRes

from .client import Client as Client


@dataclass
class Fwd:
"""."""

task_ins: TaskIns
state: WorkloadState


@dataclass
class Bwd:
"""."""

task_res: TaskRes
state: WorkloadState


FlowerCallable = Callable[[Fwd], Bwd]
ClientFn = Callable[[str], Client]

0 comments on commit b67702f

Please sign in to comment.