Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service: Regenerate gRPC stubs and update check_nims.yml to check for out-of-date gRPC stubs #546

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/check_nims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,14 @@ jobs:
poetry run sphinx-build _docs_source docs -b html -W --keep-going
- name: Revert docs
run: git clean -dfx docs/ && git restore docs/
- name: Generate gRPC stubs
run: |
find ni_measurementlink_service/_internal/stubs/ -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
find tests/assets/stubs/ -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
poetry run python scripts/generate_grpc_stubs.py
- name: Check for out-of-date gRPC stubs
run: git diff --exit-code
- name: Revert gRPC stubs
run: |
git clean -dfx ni_measurementlink_service/_internal/stubs/ tests/assets/stubs/
git restore ni_measurementlink_service/_internal/stubs/ tests/assets/stubs/
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@ isort:skip_file
---------------------------------------------------------------------
"""
import abc
import collections.abc
import grpc
import grpc.aio
import ni_measurementlink_service._internal.stubs.ni.measurementlink.discovery.v1.discovery_service_pb2 as ni_measurementlink_discovery_v1_discovery_service_pb2
import typing

_T = typing.TypeVar('_T')

class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
...

class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
...

class DiscoveryServiceStub:
"""The service used as a registry for other services. This service can be used to discover
and activate other services present in the system.
"""

def __init__(self, channel: grpc.Channel) -> None: ...
def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ...
RegisterService: grpc.UnaryUnaryMultiCallable[
ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceRequest,
ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse,
Expand Down Expand Up @@ -56,6 +67,53 @@ class DiscoveryServiceStub:
- FAILED_PRECONDITION: More than one service matching the resolve request was found
"""

class DiscoveryServiceAsyncStub:
"""The service used as a registry for other services. This service can be used to discover
and activate other services present in the system.
"""

RegisterService: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceRequest,
ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse,
]
"""Registers a service instance with the discovery service.
Status Codes for errors:
- INVALID_ARGUMENT:
- ServiceDescriptor.display_name is empty
- ServiceDescriptor.provided_interfaces is empty
- ServiceDescriptor.service_class is empty
- ServiceLocation.location is empty
- Both ServiceLocation.insecure_port and ServiceLocation.ssl_authenticated_port are empty
- Either ServiceLocation.insecure_port or ServiceLocation.ssl_authenticated_port contain an invalid port number
"""
UnregisterService: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceRequest,
ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse,
]
"""Unregisters a service instance with the discovery service."""
EnumerateServices: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesRequest,
ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse,
]
"""Enumerate all services which implement a specific service interface.
This is useful for plugin type systems where the possible services are not known ahead of time.
"""
ResolveService: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_discovery_v1_discovery_service_pb2.ResolveServiceRequest,
ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation,
]
"""Given a description of a service, returns information that can be used to establish communication
with that service. If necessary, the service will be started by the discovery service if it has not
already been started. Activation of the service is accomplished through use of a .serviceconfig file
which includes information describing the service. Services that register a .serviceconfig file must
call RegisterService when their service is started or this call will never complete successfully when
the discovery service attempts to start it.
Status Codes for errors:
- INVALID_ARGUMENT: provided_interfaces is empty
- NOT_FOUND: No service matching the resolve request was found
- FAILED_PRECONDITION: More than one service matching the resolve request was found
"""

class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
"""The service used as a registry for other services. This service can be used to discover
and activate other services present in the system.
Expand All @@ -65,8 +123,8 @@ class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
def RegisterService(
self,
request: ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse]]:
"""Registers a service instance with the discovery service.
Status Codes for errors:
- INVALID_ARGUMENT:
Expand All @@ -81,24 +139,24 @@ class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
def UnregisterService(
self,
request: ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse]]:
"""Unregisters a service instance with the discovery service."""
@abc.abstractmethod
def EnumerateServices(
self,
request: ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse]]:
"""Enumerate all services which implement a specific service interface.
This is useful for plugin type systems where the possible services are not known ahead of time.
"""
@abc.abstractmethod
def ResolveService(
self,
request: ni_measurementlink_discovery_v1_discovery_service_pb2.ResolveServiceRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation]]:
"""Given a description of a service, returns information that can be used to establish communication
with that service. If necessary, the service will be started by the discovery service if it has not
already been started. Activation of the service is accomplished through use of a .serviceconfig file
Expand All @@ -111,4 +169,4 @@ class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
- FAILED_PRECONDITION: More than one service matching the resolve request was found
"""

def add_DiscoveryServiceServicer_to_server(servicer: DiscoveryServiceServicer, server: grpc.Server) -> None: ...
def add_DiscoveryServiceServicer_to_server(servicer: DiscoveryServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@ isort:skip_file
---------------------------------------------------------------------
"""
import abc
import collections.abc
import grpc
import grpc.aio
import ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v1.measurement_service_pb2 as ni_measurementlink_measurement_v1_measurement_service_pb2
import typing

_T = typing.TypeVar('_T')

class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
...

class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
...

class MeasurementServiceStub:
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
where there can be multiple implementations of the service that provide different measurement capabilities.
"""

def __init__(self, channel: grpc.Channel) -> None: ...
def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ...
GetMetadata: grpc.UnaryUnaryMultiCallable[
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataRequest,
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse,
Expand All @@ -25,6 +36,22 @@ class MeasurementServiceStub:
]
"""API used to perform a measurement."""

class MeasurementServiceAsyncStub:
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
where there can be multiple implementations of the service that provide different measurement capabilities.
"""

GetMetadata: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataRequest,
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse,
]
"""Returns information that describes the measurement."""
Measure: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureRequest,
ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse,
]
"""API used to perform a measurement."""

class MeasurementServiceServicer(metaclass=abc.ABCMeta):
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
where there can be multiple implementations of the service that provide different measurement capabilities.
Expand All @@ -34,15 +61,15 @@ class MeasurementServiceServicer(metaclass=abc.ABCMeta):
def GetMetadata(
self,
request: ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse, collections.abc.Awaitable[ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse]]:
"""Returns information that describes the measurement."""
@abc.abstractmethod
def Measure(
self,
request: ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse, collections.abc.Awaitable[ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse]]:
"""API used to perform a measurement."""

def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: grpc.Server) -> None: ...
def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ isort:skip_file
import abc
import collections.abc
import grpc
import grpc.aio
import ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v2.measurement_service_pb2 as ni_measurementlink_measurement_v2_measurement_service_pb2
import typing

_T = typing.TypeVar('_T')

class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
...

class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
...

class MeasurementServiceStub:
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
where there can be multiple implementations of the service that provide different measurement capabilities.
"""

def __init__(self, channel: grpc.Channel) -> None: ...
def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ...
GetMetadata: grpc.UnaryUnaryMultiCallable[
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataRequest,
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse,
Expand All @@ -26,6 +36,22 @@ class MeasurementServiceStub:
]
"""API used to perform a measurement."""

class MeasurementServiceAsyncStub:
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
where there can be multiple implementations of the service that provide different measurement capabilities.
"""

GetMetadata: grpc.aio.UnaryUnaryMultiCallable[
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataRequest,
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse,
]
"""Returns information that describes the measurement."""
Measure: grpc.aio.UnaryStreamMultiCallable[
ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureRequest,
ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse,
]
"""API used to perform a measurement."""

class MeasurementServiceServicer(metaclass=abc.ABCMeta):
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
where there can be multiple implementations of the service that provide different measurement capabilities.
Expand All @@ -35,15 +61,15 @@ class MeasurementServiceServicer(metaclass=abc.ABCMeta):
def GetMetadata(
self,
request: ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataRequest,
context: grpc.ServicerContext,
) -> ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse:
context: _ServicerContext,
) -> typing.Union[ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse, collections.abc.Awaitable[ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse]]:
"""Returns information that describes the measurement."""
@abc.abstractmethod
def Measure(
self,
request: ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureRequest,
context: grpc.ServicerContext,
) -> collections.abc.Iterator[ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse]:
context: _ServicerContext,
) -> typing.Union[collections.abc.Iterator[ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse], collections.abc.AsyncIterator[ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse]]:
"""API used to perform a measurement."""

def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: grpc.Server) -> None: ...
def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,16 @@
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
import abc
import collections.abc
import grpc
import grpc.aio
import typing

_T = typing.TypeVar('_T')

class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
...

class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
...
Loading