Skip to content

Commit b19aeda

Browse files
authored
service: Regenerate gRPC stubs and update check_nims.yml to check for out-of-date gRPC stubs (#546)
* service: Regenerate gRPC stubs * github: Update check_nims.yml to regenerate gRPC stubs and check for modifications * github: Be more selective about which stubs to delete (not examples)
1 parent ae853b1 commit b19aeda

File tree

13 files changed

+435
-60
lines changed

13 files changed

+435
-60
lines changed

.github/workflows/check_nims.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,14 @@ jobs:
7474
poetry run sphinx-build _docs_source docs -b html -W --keep-going
7575
- name: Revert docs
7676
run: git clean -dfx docs/ && git restore docs/
77+
- name: Generate gRPC stubs
78+
run: |
79+
find ni_measurementlink_service/_internal/stubs/ -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
80+
find tests/assets/stubs/ -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
81+
poetry run python scripts/generate_grpc_stubs.py
82+
- name: Check for out-of-date gRPC stubs
83+
run: git diff --exit-code
84+
- name: Revert gRPC stubs
85+
run: |
86+
git clean -dfx ni_measurementlink_service/_internal/stubs/ tests/assets/stubs/
87+
git restore ni_measurementlink_service/_internal/stubs/ tests/assets/stubs/

ni_measurementlink_service/_internal/stubs/ni/measurementlink/discovery/v1/discovery_service_pb2_grpc.pyi

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,26 @@ isort:skip_file
55
---------------------------------------------------------------------
66
"""
77
import abc
8+
import collections.abc
89
import grpc
10+
import grpc.aio
911
import ni_measurementlink_service._internal.stubs.ni.measurementlink.discovery.v1.discovery_service_pb2 as ni_measurementlink_discovery_v1_discovery_service_pb2
12+
import typing
13+
14+
_T = typing.TypeVar('_T')
15+
16+
class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
17+
...
18+
19+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
20+
...
1021

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

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

70+
class DiscoveryServiceAsyncStub:
71+
"""The service used as a registry for other services. This service can be used to discover
72+
and activate other services present in the system.
73+
"""
74+
75+
RegisterService: grpc.aio.UnaryUnaryMultiCallable[
76+
ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceRequest,
77+
ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse,
78+
]
79+
"""Registers a service instance with the discovery service.
80+
Status Codes for errors:
81+
- INVALID_ARGUMENT:
82+
- ServiceDescriptor.display_name is empty
83+
- ServiceDescriptor.provided_interfaces is empty
84+
- ServiceDescriptor.service_class is empty
85+
- ServiceLocation.location is empty
86+
- Both ServiceLocation.insecure_port and ServiceLocation.ssl_authenticated_port are empty
87+
- Either ServiceLocation.insecure_port or ServiceLocation.ssl_authenticated_port contain an invalid port number
88+
"""
89+
UnregisterService: grpc.aio.UnaryUnaryMultiCallable[
90+
ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceRequest,
91+
ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse,
92+
]
93+
"""Unregisters a service instance with the discovery service."""
94+
EnumerateServices: grpc.aio.UnaryUnaryMultiCallable[
95+
ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesRequest,
96+
ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse,
97+
]
98+
"""Enumerate all services which implement a specific service interface.
99+
This is useful for plugin type systems where the possible services are not known ahead of time.
100+
"""
101+
ResolveService: grpc.aio.UnaryUnaryMultiCallable[
102+
ni_measurementlink_discovery_v1_discovery_service_pb2.ResolveServiceRequest,
103+
ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation,
104+
]
105+
"""Given a description of a service, returns information that can be used to establish communication
106+
with that service. If necessary, the service will be started by the discovery service if it has not
107+
already been started. Activation of the service is accomplished through use of a .serviceconfig file
108+
which includes information describing the service. Services that register a .serviceconfig file must
109+
call RegisterService when their service is started or this call will never complete successfully when
110+
the discovery service attempts to start it.
111+
Status Codes for errors:
112+
- INVALID_ARGUMENT: provided_interfaces is empty
113+
- NOT_FOUND: No service matching the resolve request was found
114+
- FAILED_PRECONDITION: More than one service matching the resolve request was found
115+
"""
116+
59117
class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
60118
"""The service used as a registry for other services. This service can be used to discover
61119
and activate other services present in the system.
@@ -65,8 +123,8 @@ class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
65123
def RegisterService(
66124
self,
67125
request: ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceRequest,
68-
context: grpc.ServicerContext,
69-
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse:
126+
context: _ServicerContext,
127+
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.RegisterServiceResponse]]:
70128
"""Registers a service instance with the discovery service.
71129
Status Codes for errors:
72130
- INVALID_ARGUMENT:
@@ -81,24 +139,24 @@ class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
81139
def UnregisterService(
82140
self,
83141
request: ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceRequest,
84-
context: grpc.ServicerContext,
85-
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse:
142+
context: _ServicerContext,
143+
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.UnregisterServiceResponse]]:
86144
"""Unregisters a service instance with the discovery service."""
87145
@abc.abstractmethod
88146
def EnumerateServices(
89147
self,
90148
request: ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesRequest,
91-
context: grpc.ServicerContext,
92-
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse:
149+
context: _ServicerContext,
150+
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.EnumerateServicesResponse]]:
93151
"""Enumerate all services which implement a specific service interface.
94152
This is useful for plugin type systems where the possible services are not known ahead of time.
95153
"""
96154
@abc.abstractmethod
97155
def ResolveService(
98156
self,
99157
request: ni_measurementlink_discovery_v1_discovery_service_pb2.ResolveServiceRequest,
100-
context: grpc.ServicerContext,
101-
) -> ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation:
158+
context: _ServicerContext,
159+
) -> typing.Union[ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation, collections.abc.Awaitable[ni_measurementlink_discovery_v1_discovery_service_pb2.ServiceLocation]]:
102160
"""Given a description of a service, returns information that can be used to establish communication
103161
with that service. If necessary, the service will be started by the discovery service if it has not
104162
already been started. Activation of the service is accomplished through use of a .serviceconfig file
@@ -111,4 +169,4 @@ class DiscoveryServiceServicer(metaclass=abc.ABCMeta):
111169
- FAILED_PRECONDITION: More than one service matching the resolve request was found
112170
"""
113171

114-
def add_DiscoveryServiceServicer_to_server(servicer: DiscoveryServiceServicer, server: grpc.Server) -> None: ...
172+
def add_DiscoveryServiceServicer_to_server(servicer: DiscoveryServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...

ni_measurementlink_service/_internal/stubs/ni/measurementlink/measurement/v1/measurement_service_pb2_grpc.pyi

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,26 @@ isort:skip_file
55
---------------------------------------------------------------------
66
"""
77
import abc
8+
import collections.abc
89
import grpc
10+
import grpc.aio
911
import ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v1.measurement_service_pb2 as ni_measurementlink_measurement_v1_measurement_service_pb2
12+
import typing
13+
14+
_T = typing.TypeVar('_T')
15+
16+
class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
17+
...
18+
19+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
20+
...
1021

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

16-
def __init__(self, channel: grpc.Channel) -> None: ...
27+
def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ...
1728
GetMetadata: grpc.UnaryUnaryMultiCallable[
1829
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataRequest,
1930
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse,
@@ -25,6 +36,22 @@ class MeasurementServiceStub:
2536
]
2637
"""API used to perform a measurement."""
2738

39+
class MeasurementServiceAsyncStub:
40+
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
41+
where there can be multiple implementations of the service that provide different measurement capabilities.
42+
"""
43+
44+
GetMetadata: grpc.aio.UnaryUnaryMultiCallable[
45+
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataRequest,
46+
ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse,
47+
]
48+
"""Returns information that describes the measurement."""
49+
Measure: grpc.aio.UnaryUnaryMultiCallable[
50+
ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureRequest,
51+
ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse,
52+
]
53+
"""API used to perform a measurement."""
54+
2855
class MeasurementServiceServicer(metaclass=abc.ABCMeta):
2956
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
3057
where there can be multiple implementations of the service that provide different measurement capabilities.
@@ -34,15 +61,15 @@ class MeasurementServiceServicer(metaclass=abc.ABCMeta):
3461
def GetMetadata(
3562
self,
3663
request: ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataRequest,
37-
context: grpc.ServicerContext,
38-
) -> ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse:
64+
context: _ServicerContext,
65+
) -> typing.Union[ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse, collections.abc.Awaitable[ni_measurementlink_measurement_v1_measurement_service_pb2.GetMetadataResponse]]:
3966
"""Returns information that describes the measurement."""
4067
@abc.abstractmethod
4168
def Measure(
4269
self,
4370
request: ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureRequest,
44-
context: grpc.ServicerContext,
45-
) -> ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse:
71+
context: _ServicerContext,
72+
) -> typing.Union[ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse, collections.abc.Awaitable[ni_measurementlink_measurement_v1_measurement_service_pb2.MeasureResponse]]:
4673
"""API used to perform a measurement."""
4774

48-
def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: grpc.Server) -> None: ...
75+
def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...

ni_measurementlink_service/_internal/stubs/ni/measurementlink/measurement/v2/measurement_service_pb2_grpc.pyi

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@ isort:skip_file
77
import abc
88
import collections.abc
99
import grpc
10+
import grpc.aio
1011
import ni_measurementlink_service._internal.stubs.ni.measurementlink.measurement.v2.measurement_service_pb2 as ni_measurementlink_measurement_v2_measurement_service_pb2
12+
import typing
13+
14+
_T = typing.TypeVar('_T')
15+
16+
class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
17+
...
18+
19+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
20+
...
1121

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

17-
def __init__(self, channel: grpc.Channel) -> None: ...
27+
def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ...
1828
GetMetadata: grpc.UnaryUnaryMultiCallable[
1929
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataRequest,
2030
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse,
@@ -26,6 +36,22 @@ class MeasurementServiceStub:
2636
]
2737
"""API used to perform a measurement."""
2838

39+
class MeasurementServiceAsyncStub:
40+
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
41+
where there can be multiple implementations of the service that provide different measurement capabilities.
42+
"""
43+
44+
GetMetadata: grpc.aio.UnaryUnaryMultiCallable[
45+
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataRequest,
46+
ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse,
47+
]
48+
"""Returns information that describes the measurement."""
49+
Measure: grpc.aio.UnaryStreamMultiCallable[
50+
ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureRequest,
51+
ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse,
52+
]
53+
"""API used to perform a measurement."""
54+
2955
class MeasurementServiceServicer(metaclass=abc.ABCMeta):
3056
"""Service that implements a measurement. Unlike other services, a MeasurementService is designed to be a plugin
3157
where there can be multiple implementations of the service that provide different measurement capabilities.
@@ -35,15 +61,15 @@ class MeasurementServiceServicer(metaclass=abc.ABCMeta):
3561
def GetMetadata(
3662
self,
3763
request: ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataRequest,
38-
context: grpc.ServicerContext,
39-
) -> ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse:
64+
context: _ServicerContext,
65+
) -> typing.Union[ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse, collections.abc.Awaitable[ni_measurementlink_measurement_v2_measurement_service_pb2.GetMetadataResponse]]:
4066
"""Returns information that describes the measurement."""
4167
@abc.abstractmethod
4268
def Measure(
4369
self,
4470
request: ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureRequest,
45-
context: grpc.ServicerContext,
46-
) -> collections.abc.Iterator[ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse]:
71+
context: _ServicerContext,
72+
) -> typing.Union[collections.abc.Iterator[ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse], collections.abc.AsyncIterator[ni_measurementlink_measurement_v2_measurement_service_pb2.MeasureResponse]]:
4773
"""API used to perform a measurement."""
4874

49-
def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: grpc.Server) -> None: ...
75+
def add_MeasurementServiceServicer_to_server(servicer: MeasurementServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...

ni_measurementlink_service/_internal/stubs/ni/measurementlink/pin_map_context_pb2_grpc.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,16 @@
22
@generated by mypy-protobuf. Do not edit manually!
33
isort:skip_file
44
"""
5+
import abc
6+
import collections.abc
7+
import grpc
8+
import grpc.aio
9+
import typing
10+
11+
_T = typing.TypeVar('_T')
12+
13+
class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
14+
...
15+
16+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
17+
...

0 commit comments

Comments
 (0)