diff --git a/src/proto/flwr/proto/exec.proto b/src/proto/flwr/proto/exec.proto new file mode 100644 index 000000000000..05885c9ceed3 --- /dev/null +++ b/src/proto/flwr/proto/exec.proto @@ -0,0 +1,26 @@ +// 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; + +service Exec { + // Start run upon request + rpc StartRun(StartRunRequest) returns (StartRunResponse) {} +} + +message StartRunRequest { bytes fab_file = 1; } +message StartRunResponse { sint64 run_id = 1; } diff --git a/src/py/flwr/proto/exec_pb2.py b/src/py/flwr/proto/exec_pb2.py new file mode 100644 index 000000000000..a1d1f24af7d0 --- /dev/null +++ b/src/py/flwr/proto/exec_pb2.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: flwr/proto/exec.proto +# Protobuf Python Version: 4.25.0 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15\x66lwr/proto/exec.proto\x12\nflwr.proto\"#\n\x0fStartRunRequest\x12\x10\n\x08\x66\x61\x62_file\x18\x01 \x01(\x0c\"\"\n\x10StartRunResponse\x12\x0e\n\x06run_id\x18\x01 \x01(\x12\x32O\n\x04\x45xec\x12G\n\x08StartRun\x12\x1b.flwr.proto.StartRunRequest\x1a\x1c.flwr.proto.StartRunResponse\"\x00\x62\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'flwr.proto.exec_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + _globals['_STARTRUNREQUEST']._serialized_start=37 + _globals['_STARTRUNREQUEST']._serialized_end=72 + _globals['_STARTRUNRESPONSE']._serialized_start=74 + _globals['_STARTRUNRESPONSE']._serialized_end=108 + _globals['_EXEC']._serialized_start=110 + _globals['_EXEC']._serialized_end=189 +# @@protoc_insertion_point(module_scope) diff --git a/src/py/flwr/proto/exec_pb2.pyi b/src/py/flwr/proto/exec_pb2.pyi new file mode 100644 index 000000000000..8a0122062dcf --- /dev/null +++ b/src/py/flwr/proto/exec_pb2.pyi @@ -0,0 +1,32 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" +import builtins +import google.protobuf.descriptor +import google.protobuf.message +import typing_extensions + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +class StartRunRequest(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + FAB_FILE_FIELD_NUMBER: builtins.int + fab_file: builtins.bytes + def __init__(self, + *, + fab_file: builtins.bytes = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["fab_file",b"fab_file"]) -> None: ... +global___StartRunRequest = StartRunRequest + +class StartRunResponse(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + RUN_ID_FIELD_NUMBER: builtins.int + run_id: builtins.int + def __init__(self, + *, + run_id: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["run_id",b"run_id"]) -> None: ... +global___StartRunResponse = StartRunResponse diff --git a/src/py/flwr/proto/exec_pb2_grpc.py b/src/py/flwr/proto/exec_pb2_grpc.py new file mode 100644 index 000000000000..349148eb9926 --- /dev/null +++ b/src/py/flwr/proto/exec_pb2_grpc.py @@ -0,0 +1,67 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from flwr.proto import exec_pb2 as flwr_dot_proto_dot_exec__pb2 + + +class ExecStub(object): + """Missing associated documentation comment in .proto file.""" + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.StartRun = channel.unary_unary( + '/flwr.proto.Exec/StartRun', + request_serializer=flwr_dot_proto_dot_exec__pb2.StartRunRequest.SerializeToString, + response_deserializer=flwr_dot_proto_dot_exec__pb2.StartRunResponse.FromString, + ) + + +class ExecServicer(object): + """Missing associated documentation comment in .proto file.""" + + def StartRun(self, request, context): + """Start run upon request + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_ExecServicer_to_server(servicer, server): + rpc_method_handlers = { + 'StartRun': grpc.unary_unary_rpc_method_handler( + servicer.StartRun, + request_deserializer=flwr_dot_proto_dot_exec__pb2.StartRunRequest.FromString, + response_serializer=flwr_dot_proto_dot_exec__pb2.StartRunResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'flwr.proto.Exec', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class Exec(object): + """Missing associated documentation comment in .proto file.""" + + @staticmethod + def StartRun(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/flwr.proto.Exec/StartRun', + flwr_dot_proto_dot_exec__pb2.StartRunRequest.SerializeToString, + flwr_dot_proto_dot_exec__pb2.StartRunResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/src/py/flwr/proto/exec_pb2_grpc.pyi b/src/py/flwr/proto/exec_pb2_grpc.pyi new file mode 100644 index 000000000000..6cab594babd9 --- /dev/null +++ b/src/py/flwr/proto/exec_pb2_grpc.pyi @@ -0,0 +1,27 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" +import abc +import flwr.proto.exec_pb2 +import grpc + +class ExecStub: + def __init__(self, channel: grpc.Channel) -> None: ... + StartRun: grpc.UnaryUnaryMultiCallable[ + flwr.proto.exec_pb2.StartRunRequest, + flwr.proto.exec_pb2.StartRunResponse] + """Start run upon request""" + + +class ExecServicer(metaclass=abc.ABCMeta): + @abc.abstractmethod + def StartRun(self, + request: flwr.proto.exec_pb2.StartRunRequest, + context: grpc.ServicerContext, + ) -> flwr.proto.exec_pb2.StartRunResponse: + """Start run upon request""" + pass + + +def add_ExecServicer_to_server(servicer: ExecServicer, server: grpc.Server) -> None: ... diff --git a/src/py/flwr_tool/protoc_test.py b/src/py/flwr_tool/protoc_test.py index 6aec4251c384..0c43ed0b0811 100644 --- a/src/py/flwr_tool/protoc_test.py +++ b/src/py/flwr_tool/protoc_test.py @@ -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) == 9 + assert len(PROTO_FILES) == 10