Skip to content

Commit

Permalink
Add Error protobuf definition (#3033)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq authored Feb 29, 2024
1 parent 42f13ad commit e960a21
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 10 deletions.
23 changes: 23 additions & 0 deletions src/proto/flwr/proto/error.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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.
// ==============================================================================

syntax = "proto3";

package flwr.proto;

message Error {
sint64 code = 1;
string reason = 2;
}
2 changes: 2 additions & 0 deletions src/proto/flwr/proto/task.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package flwr.proto;
import "flwr/proto/node.proto";
import "flwr/proto/recordset.proto";
import "flwr/proto/transport.proto";
import "flwr/proto/error.proto";

message Task {
Node producer = 1;
Expand All @@ -30,6 +31,7 @@ message Task {
repeated string ancestry = 6;
string task_type = 7;
RecordSet recordset = 8;
Error error = 9;
}

message TaskIns {
Expand Down
26 changes: 26 additions & 0 deletions src/py/flwr/proto/error_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/py/flwr/proto/error_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
import builtins
import google.protobuf.descriptor
import google.protobuf.message
import typing
import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

class Error(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
CODE_FIELD_NUMBER: builtins.int
REASON_FIELD_NUMBER: builtins.int
code: builtins.int
reason: typing.Text
def __init__(self,
*,
code: builtins.int = ...,
reason: typing.Text = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["code",b"code","reason",b"reason"]) -> None: ...
global___Error = Error
4 changes: 4 additions & 0 deletions src/py/flwr/proto/error_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

4 changes: 4 additions & 0 deletions src/py/flwr/proto/error_pb2_grpc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
15 changes: 8 additions & 7 deletions src/py/flwr/proto/task_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/py/flwr/proto/task_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
isort:skip_file
"""
import builtins
import flwr.proto.error_pb2
import flwr.proto.node_pb2
import flwr.proto.recordset_pb2
import google.protobuf.descriptor
Expand All @@ -23,6 +24,7 @@ class Task(google.protobuf.message.Message):
ANCESTRY_FIELD_NUMBER: builtins.int
TASK_TYPE_FIELD_NUMBER: builtins.int
RECORDSET_FIELD_NUMBER: builtins.int
ERROR_FIELD_NUMBER: builtins.int
@property
def producer(self) -> flwr.proto.node_pb2.Node: ...
@property
Expand All @@ -35,6 +37,8 @@ class Task(google.protobuf.message.Message):
task_type: typing.Text
@property
def recordset(self) -> flwr.proto.recordset_pb2.RecordSet: ...
@property
def error(self) -> flwr.proto.error_pb2.Error: ...
def __init__(self,
*,
producer: typing.Optional[flwr.proto.node_pb2.Node] = ...,
Expand All @@ -45,9 +49,10 @@ class Task(google.protobuf.message.Message):
ancestry: typing.Optional[typing.Iterable[typing.Text]] = ...,
task_type: typing.Text = ...,
recordset: typing.Optional[flwr.proto.recordset_pb2.RecordSet] = ...,
error: typing.Optional[flwr.proto.error_pb2.Error] = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["consumer",b"consumer","producer",b"producer","recordset",b"recordset"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["ancestry",b"ancestry","consumer",b"consumer","created_at",b"created_at","delivered_at",b"delivered_at","producer",b"producer","recordset",b"recordset","task_type",b"task_type","ttl",b"ttl"]) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["consumer",b"consumer","error",b"error","producer",b"producer","recordset",b"recordset"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["ancestry",b"ancestry","consumer",b"consumer","created_at",b"created_at","delivered_at",b"delivered_at","error",b"error","producer",b"producer","recordset",b"recordset","task_type",b"task_type","ttl",b"ttl"]) -> None: ...
global___Task = Task

class TaskIns(google.protobuf.message.Message):
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr_tool/protoc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def test_directories() -> None:

def test_proto_file_count() -> None:
"""Test if the correct number of proto files were captured by the glob."""
assert len(PROTO_FILES) == 6
assert len(PROTO_FILES) == 7

0 comments on commit e960a21

Please sign in to comment.