Skip to content

Commit

Permalink
feat(framework) Add proto files for SuperExec service
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll committed Jun 13, 2024
1 parent c16cd75 commit 912d9e7
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/proto/flwr/proto/exec.proto
Original file line number Diff line number Diff line change
@@ -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; }
30 changes: 30 additions & 0 deletions src/py/flwr/proto/exec_pb2.py

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

32 changes: 32 additions & 0 deletions src/py/flwr/proto/exec_pb2.pyi
Original file line number Diff line number Diff line change
@@ -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
67 changes: 67 additions & 0 deletions src/py/flwr/proto/exec_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions src/py/flwr/proto/exec_pb2_grpc.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
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) == 9
assert len(PROTO_FILES) == 10

0 comments on commit 912d9e7

Please sign in to comment.