Skip to content

Mismatched function signature #211

@eric-carlsson

Description

@eric-carlsson

What happened?

The serve function accepts a grpcv1.FunctionRunnerService, when it should accept a grpcv1.FunctionRunnerServiceServicer.

def serve(
function: grpcv1.FunctionRunnerService,
address: str,
*,
creds: grpc.ServerCredentials,
insecure: bool,
options: Sequence[tuple[str, Any]] | None = None,
) -> None:

This results in a type mismatch:

Method "RunFunction" overrides class "FunctionRunnerService" in an incompatible manner
  Base method is declared as a staticmethod but override is not
  Positional parameter count mismatch; base method has 10, but override has 3
...

Similarly, a class that implements a RunFunction(Service) servicer, should really implement grpcv1. FunctionRunnerServiceServicer instead.

class BetaFunctionRunner(grpcv1beta1.FunctionRunnerService):
"""A BetaFunctionRunner handles beta gRPC RunFunctionRequests.
It handles requests by passing them to a wrapped v1.FunctionRunnerService.
Incoming v1beta1 requests are converted to v1 by round-tripping them through
serialization. Outgoing requests are converted from v1 to v1beta1 the same
way.
"""
def __init__(self, wrapped: grpcv1.FunctionRunnerService):
"""Create a new BetaFunctionRunner."""
self.wrapped = wrapped

See gRPC docs for details: https://grpc.io/docs/languages/python/quickstart/#update-the-server

How can we reproduce it?

Look at the signature of respective class and you'll see the mismatch.

What environment did it happen in?

Function version: v0.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions