Skip to content

Commit

Permalink
Split FlowerContext into Message and Context (#2851)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq authored Jan 25, 2024
1 parent 88f2e3e commit 3b5df2a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
38 changes: 38 additions & 0 deletions src/py/flwr/common/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 Flower Labs GmbH. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Context."""


from dataclasses import dataclass

from .recordset import RecordSet


@dataclass
class Context:
"""State of your run.
Parameters
----------
state : RecordSet
Holds records added by the entity in a given run and that will stay local.
This means that the data it holds will never leave the system it's running from.
This can be used as an intermediate storage or scratchpad when
executing middleware layers. It can also be used as a memory to access
at different points during the lifecycle of this entity (e.g. across
multiple rounds)
"""

state: RecordSet
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""FlowerContext and Metadata."""
"""Message."""


from dataclasses import dataclass
Expand Down Expand Up @@ -48,30 +48,17 @@ class Metadata:


@dataclass
class FlowerContext:
class Message:
"""State of your application from the viewpoint of the entity using it.
Parameters
----------
in_message : RecordSet
Holds records sent by another entity (e.g. sent by the server-side
logic to a client, or vice-versa)
out_message : RecordSet
Holds records added by the current entity. This `RecordSet` will
be sent out (e.g. back to the server-side for aggregation of
parameter, or to the client to perform a certain task)
local : RecordSet
Holds record added by the current entity and that will stay local.
This means that the data it holds will never leave the system it's running from.
This can be used as an intermediate storage or scratchpad when
executing middleware layers. It can also be used as a memory to access
at different points during the lifecycle of this entity (e.g. across
multiple rounds)
metadata : Metadata
A dataclass including information about the task to be executed.
message : RecordSet
Holds records either sent by another entity (e.g. sent by the server-side
logic to a client, or vice-versa) or that will be sent to it.
"""

in_message: RecordSet
out_message: RecordSet
local: RecordSet
metadata: Metadata
message: RecordSet

0 comments on commit 3b5df2a

Please sign in to comment.