Skip to content

Commit

Permalink
Move definitions of Fwd and Bwd to client/typing.py (#2669)
Browse files Browse the repository at this point in the history
  • Loading branch information
panh99 authored Nov 30, 2023
1 parent eaa7ff9 commit 094e925
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 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)
4 changes: 2 additions & 2 deletions src/py/flwr/client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from typing import Callable, ContextManager, Optional, Tuple, Union

from flwr.client.client import Client
from flwr.client.flower import Bwd, Flower, Fwd
from flwr.client.typing import ClientFn
from flwr.client.flower import Flower
from flwr.client.typing import Bwd, ClientFn, Fwd
from flwr.common import GRPC_MAX_MESSAGE_LENGTH, EventType, event
from flwr.common.address import parse_address
from flwr.common.constant import (
Expand Down
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]
4 changes: 2 additions & 2 deletions src/py/flwr/flower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"""Flower callable package."""


from flwr.client.flower import Bwd as Bwd
from flwr.client.flower import Flower as Flower
from flwr.client.flower import Fwd as Fwd
from flwr.client.typing import Bwd as Bwd
from flwr.client.typing import Fwd as Fwd

__all__ = [
"Flower",
Expand Down

0 comments on commit 094e925

Please sign in to comment.