Skip to content

Commit

Permalink
Feature/SK-1246 | Change proto enum WORKER to CLIENT (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrede authored Dec 4, 2024
1 parent b5f0a02 commit c416b72
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions fedn/network/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def get_model_from_combiner(self, id, timeout=20):
time_start = time.time()
request = fedn.ModelRequest(id=id)
request.sender.name = self.name
request.sender.role = fedn.WORKER
request.sender.role = fedn.CLIENT

try:
for part in self.modelStub.Download(request, metadata=self.metadata):
Expand Down Expand Up @@ -388,7 +388,7 @@ def _listen_to_task_stream(self):
"""
r = fedn.ClientAvailableMessage()
r.sender.name = self.name
r.sender.role = fedn.WORKER
r.sender.role = fedn.CLIENT
r.sender.client_id = self.id
# Add client to metadata
self._add_grpc_metadata("client", self.name)
Expand Down Expand Up @@ -628,7 +628,7 @@ def process_request(self):
update = fedn.ModelUpdate()
update.sender.name = self.name
update.sender.client_id = self.id
update.sender.role = fedn.WORKER
update.sender.role = fedn.CLIENT
update.receiver.name = request.sender.name
update.receiver.role = request.sender.role
update.model_id = request.model_id
Expand Down Expand Up @@ -669,7 +669,7 @@ def process_request(self):
# Send validation
validation = fedn.ModelValidation()
validation.sender.name = self.name
validation.sender.role = fedn.WORKER
validation.sender.role = fedn.CLIENT
validation.receiver.name = request.sender.name
validation.receiver.role = request.sender.role
validation.model_id = str(request.model_id)
Expand Down Expand Up @@ -724,7 +724,7 @@ def process_request(self):
_ = self._process_prediction_request(request.model_id, request.session_id, presigned_url)
prediction = fedn.ModelPrediction()
prediction.sender.name = self.name
prediction.sender.role = fedn.WORKER
prediction.sender.role = fedn.CLIENT
prediction.receiver.name = request.sender.name
prediction.receiver.name = request.sender.name
prediction.receiver.role = request.sender.role
Expand Down Expand Up @@ -762,7 +762,7 @@ def _send_heartbeat(self, update_frequency=2.0):
:rtype: None
"""
while True:
heartbeat = fedn.Heartbeat(sender=fedn.Client(name=self.name, role=fedn.WORKER, client_id=self.id))
heartbeat = fedn.Heartbeat(sender=fedn.Client(name=self.name, role=fedn.CLIENT, client_id=self.id))
try:
self.connectorStub.SendHeartbeat(heartbeat, metadata=self.metadata)
if self._missed_heartbeat > 0:
Expand Down Expand Up @@ -812,7 +812,7 @@ def send_status(self, msg, log_level=fedn.LogLevel.INFO, type=None, request=None
status = fedn.Status()
status.timestamp.GetCurrentTime()
status.sender.name = self.name
status.sender.role = fedn.WORKER
status.sender.role = fedn.CLIENT
status.log_level = log_level
status.status = str(msg)
status.session_id = sesssion_id
Expand Down
14 changes: 7 additions & 7 deletions fedn/network/clients/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def heartbeat(self, client_name: str, client_id: str):
:return: Response from the combiner.
:rtype: fedn.Response
"""
heartbeat = fedn.Heartbeat(sender=fedn.Client(name=client_name, role=fedn.WORKER, client_id=client_id))
heartbeat = fedn.Heartbeat(sender=fedn.Client(name=client_name, role=fedn.CLIENT, client_id=client_id))

try:
logger.info("Sending heartbeat to combiner")
Expand Down Expand Up @@ -156,7 +156,7 @@ def listen_to_task_stream(self, client_name: str, client_id: str, callback: Call
"""
r = fedn.ClientAvailableMessage()
r.sender.name = client_name
r.sender.role = fedn.WORKER
r.sender.role = fedn.CLIENT
r.sender.client_id = client_id

try:
Expand Down Expand Up @@ -198,7 +198,7 @@ def send_status(self, msg: str, log_level=fedn.LogLevel.INFO, type=None, request
status = fedn.Status()
status.timestamp.GetCurrentTime()
status.sender.name = sender_name
status.sender.role = fedn.Role.WORKER
status.sender.role = fedn.CLIENT
status.log_level = log_level
status.status = str(msg)
status.session_id = sesssion_id
Expand Down Expand Up @@ -231,7 +231,7 @@ def get_model_from_combiner(self, id: str, client_id: str, timeout: int = 20) ->
time_start = time.time()
request = fedn.ModelRequest(id=id)
request.sender.client_id = client_id
request.sender.role = fedn.WORKER
request.sender.role = fedn.CLIENT

try:
logger.info("Downloading model from combiner.")
Expand Down Expand Up @@ -298,7 +298,7 @@ def create_update_message(
):
update = fedn.ModelUpdate()
update.sender.name = sender_name
update.sender.role = fedn.WORKER
update.sender.role = fedn.CLIENT
update.sender.client_id = self.metadata[0][1]
update.receiver.name = receiver_name
update.receiver.role = receiver_role
Expand All @@ -321,7 +321,7 @@ def create_validation_message(
):
validation = fedn.ModelValidation()
validation.sender.name = sender_name
validation.sender.role = fedn.WORKER
validation.sender.role = fedn.CLIENT
validation.receiver.name = receiver_name
validation.receiver.role = receiver_role
validation.model_id = model_id
Expand All @@ -344,7 +344,7 @@ def create_prediction_message(
):
prediction = fedn.ModelPrediction()
prediction.sender.name = sender_name
prediction.sender.role = fedn.WORKER
prediction.sender.role = fedn.CLIENT
prediction.receiver.name = receiver_name
prediction.receiver.role = receiver_role
prediction.model_id = model_id
Expand Down
6 changes: 3 additions & 3 deletions fedn/network/combiner/combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def role_to_proto_role(role):
if role == Role.COMBINER:
return fedn.COMBINER
if role == Role.WORKER:
return fedn.WORKER
return fedn.CLIENT
if role == Role.REDUCER:
return fedn.REDUCER
if role == Role.OTHER:
Expand Down Expand Up @@ -267,7 +267,7 @@ def _send_request_type(self, request_type, session_id, model_id, config=None, cl
request.sender.name = self.id
request.sender.role = fedn.COMBINER
request.receiver.client_id = client
request.receiver.role = fedn.WORKER
request.receiver.role = fedn.CLIENT
# Set the request data, not used in validation
if request_type == fedn.StatusType.MODEL_PREDICTION:
presigned_url = self.repository.presigned_put_url(self.repository.prediction_bucket, f"{client}/{session_id}")
Expand Down Expand Up @@ -596,7 +596,7 @@ def ListActiveClients(self, request: fedn.ListClientsRequest, context):
logger.info("grpc.Combiner.ListActiveClients: Number active clients: {}".format(nr_active_clients))

for client in active_clients:
clients.client.append(fedn.Client(name=client, role=fedn.WORKER))
clients.client.append(fedn.Client(name=client, role=fedn.CLIENT))
return clients

def AcceptingClients(self, request: fedn.ConnectionRequest, context):
Expand Down
2 changes: 1 addition & 1 deletion fedn/network/combiner/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def get_model(self, id, timeout=10):

request = fedn.ModelRequest(id=id)
request.sender.name = self.name
request.sender.role = fedn.WORKER
request.sender.role = fedn.CLIENT

parts = modelservice.Download(request)
for part in parts:
Expand Down
8 changes: 4 additions & 4 deletions fedn/network/grpc/fedn.proto
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ message ClientList {
}

enum Role {
WORKER = 0;
COMBINER = 1;
REDUCER = 2;
OTHER = 3;
OTHER = 0;
CLIENT = 1;
COMBINER = 2;
REDUCER = 3;
}

message Client {
Expand Down
Loading

0 comments on commit c416b72

Please sign in to comment.