Skip to content

Commit 85f9835

Browse files
Mike ProsserMike Prosser
authored andcommitted
TryGetValueRequest
1 parent 7c81ddf commit 85f9835

File tree

8 files changed

+53
-20
lines changed

8 files changed

+53
-20
lines changed

protos/ni/pythonpanel/v1/python_panel_service.proto

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ service PythonPanelService {
5050
// - INVALID_ARGUMENT:
5151
// - The panel identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
5252
// - The value identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
53-
rpc TryGetValue(GetValueRequest) returns (TryGetValueResponse);
53+
rpc TryGetValue(TryGetValueRequest) returns (TryGetValueResponse);
5454

5555
// Set a value for a control on the panel
5656
// Status Codes for errors:
@@ -119,6 +119,14 @@ message GetValueResponse {
119119
google.protobuf.Any value = 1;
120120
}
121121

122+
message TryGetValueRequest {
123+
// Unique ID of the panel
124+
string panel_id = 1;
125+
126+
// Unique ID of value
127+
string value_id = 2;
128+
}
129+
122130
message TryGetValueResponse {
123131
// The value, if it was found
124132
optional google.protobuf.Any value = 1;

src/ni/pythonpanel/v1/python_panel_service_pb2.py

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ni/pythonpanel/v1/python_panel_service_pb2.pyi

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ class GetValueResponse(google.protobuf.message.Message):
176176

177177
global___GetValueResponse = GetValueResponse
178178

179+
@typing.final
180+
class TryGetValueRequest(google.protobuf.message.Message):
181+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
182+
183+
PANEL_ID_FIELD_NUMBER: builtins.int
184+
VALUE_ID_FIELD_NUMBER: builtins.int
185+
panel_id: builtins.str
186+
"""Unique ID of the panel"""
187+
value_id: builtins.str
188+
"""Unique ID of value"""
189+
def __init__(
190+
self,
191+
*,
192+
panel_id: builtins.str = ...,
193+
value_id: builtins.str = ...,
194+
) -> None: ...
195+
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "value_id", b"value_id"]) -> None: ...
196+
197+
global___TryGetValueRequest = TryGetValueRequest
198+
179199
@typing.final
180200
class TryGetValueResponse(google.protobuf.message.Message):
181201
DESCRIPTOR: google.protobuf.descriptor.Descriptor

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, channel):
3737
)
3838
self.TryGetValue = channel.unary_unary(
3939
'/ni.pythonpanel.v1.PythonPanelService/TryGetValue',
40-
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.GetValueRequest.SerializeToString,
40+
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.TryGetValueRequest.SerializeToString,
4141
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.TryGetValueResponse.FromString,
4242
)
4343
self.SetValue = channel.unary_unary(
@@ -143,7 +143,7 @@ def add_PythonPanelServiceServicer_to_server(servicer, server):
143143
),
144144
'TryGetValue': grpc.unary_unary_rpc_method_handler(
145145
servicer.TryGetValue,
146-
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.GetValueRequest.FromString,
146+
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.TryGetValueRequest.FromString,
147147
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.TryGetValueResponse.SerializeToString,
148148
),
149149
'SetValue': grpc.unary_unary_rpc_method_handler(
@@ -242,7 +242,7 @@ def TryGetValue(request,
242242
timeout=None,
243243
metadata=None):
244244
return grpc.experimental.unary_unary(request, target, '/ni.pythonpanel.v1.PythonPanelService/TryGetValue',
245-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.GetValueRequest.SerializeToString,
245+
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.TryGetValueRequest.SerializeToString,
246246
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.TryGetValueResponse.FromString,
247247
options, channel_credentials,
248248
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class PythonPanelServiceStub:
6767
"""
6868

6969
TryGetValue: grpc.UnaryUnaryMultiCallable[
70-
ni.pythonpanel.v1.python_panel_service_pb2.GetValueRequest,
70+
ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueRequest,
7171
ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueResponse,
7272
]
7373
"""Try to get a value for a control on the panel
@@ -137,7 +137,7 @@ class PythonPanelServiceAsyncStub:
137137
"""
138138

139139
TryGetValue: grpc.aio.UnaryUnaryMultiCallable[
140-
ni.pythonpanel.v1.python_panel_service_pb2.GetValueRequest,
140+
ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueRequest,
141141
ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueResponse,
142142
]
143143
"""Try to get a value for a control on the panel
@@ -217,7 +217,7 @@ class PythonPanelServiceServicer(metaclass=abc.ABCMeta):
217217
@abc.abstractmethod
218218
def TryGetValue(
219219
self,
220-
request: ni.pythonpanel.v1.python_panel_service_pb2.GetValueRequest,
220+
request: ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueRequest,
221221
context: _ServicerContext,
222222
) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.TryGetValueResponse]]:
223223
"""Try to get a value for a control on the panel

src/nipanel/_panel_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
StopPanelRequest,
1313
EnumeratePanelsRequest,
1414
GetValueRequest,
15+
TryGetValueRequest,
1516
SetValueRequest,
1617
)
1718
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceStub
@@ -168,7 +169,7 @@ def try_get_value(self, panel_id: str, value_id: str) -> object | None:
168169
- INVALID_ARGUMENT: If the panel identifier or value identifier contains
169170
invalid characters (only alphanumeric characters and underscores are allowed).
170171
"""
171-
try_get_value_request = GetValueRequest(panel_id=panel_id, value_id=value_id)
172+
try_get_value_request = TryGetValueRequest(panel_id=panel_id, value_id=value_id)
172173
response = self._invoke_with_retry(self._get_stub().TryGetValue, try_get_value_request)
173174
if response.HasField("value"):
174175
return from_any(response.value)

tests/unit/test_python_panel_service_stub.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
StopPanelRequest,
77
EnumeratePanelsRequest,
88
GetValueRequest,
9+
TryGetValueRequest,
910
SetValueRequest,
1011
)
1112
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceStub
@@ -81,7 +82,7 @@ def test___set_value___try_get_value___gets_response(
8182
set_request = SetValueRequest(panel_id="test_panel", value_id="test_value", value=test_value)
8283
python_panel_service_stub.SetValue(set_request)
8384

84-
request = GetValueRequest(panel_id="test_panel", value_id="test_value")
85+
request = TryGetValueRequest(panel_id="test_panel", value_id="test_value")
8586
response = python_panel_service_stub.TryGetValue(request)
8687

8788
assert response is not None # Ensure response is returned
@@ -91,7 +92,7 @@ def test___set_value___try_get_value___gets_response(
9192
def test___no_value___try_get_value___gets_no_value(
9293
python_panel_service_stub: PythonPanelServiceStub,
9394
) -> None:
94-
request = GetValueRequest(panel_id="test_panel", value_id="test_value")
95+
request = TryGetValueRequest(panel_id="test_panel", value_id="test_value")
9596
response = python_panel_service_stub.TryGetValue(request)
9697

9798
assert response is not None # Ensure response is returned

tests/utils/_fake_python_panel_servicer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PanelInformation,
1212
GetValueRequest,
1313
GetValueResponse,
14+
TryGetValueRequest,
1415
TryGetValueResponse,
1516
SetValueRequest,
1617
SetValueResponse,
@@ -69,7 +70,7 @@ def GetValue(self, request: GetValueRequest, context: Any) -> GetValueResponse:
6970
return GetValueResponse(value=value)
7071

7172
def TryGetValue( # noqa: N802
72-
self, request: GetValueRequest, context: Any
73+
self, request: TryGetValueRequest, context: Any
7374
) -> TryGetValueResponse:
7475
"""Trivial implementation for testing."""
7576
if request.value_id not in self._panel_value_ids.get(request.panel_id, {}):

0 commit comments

Comments
 (0)