Skip to content

Commit bdd6ce9

Browse files
Mike ProsserMike Prosser
authored andcommitted
remove clear_value, has_value, and get_value_ids
1 parent c9e320e commit bdd6ce9

File tree

10 files changed

+9
-204
lines changed

10 files changed

+9
-204
lines changed

protos/ni/pythonpanel/v1/python_panel_service.proto

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ service PythonPanelService {
3737
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
3838
rpc SetValue(SetValueRequest) returns (SetValueResponse);
3939

40-
// Clear a value for a control on the panel
41-
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
42-
rpc ClearValue(ClearValueRequest) returns (ClearValueResponse);
43-
4440
// Close a panel
4541
// Status Codes for errors:
4642
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
@@ -104,17 +100,6 @@ message SetValueRequest {
104100
message SetValueResponse {
105101
}
106102

107-
message ClearValueRequest {
108-
// Unique ID of the panel
109-
string panel_id = 1;
110-
111-
// Unique ID of the value
112-
string value_id = 2;
113-
}
114-
115-
message ClearValueResponse {
116-
}
117-
118103
message ClosePanelRequest {
119104
// Unique ID of the panel
120105
string panel_id = 1;

src/ni/pythonpanel/v1/python_panel_service_pb2.py

Lines changed: 7 additions & 11 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: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -173,36 +173,6 @@ class SetValueResponse(google.protobuf.message.Message):
173173

174174
global___SetValueResponse = SetValueResponse
175175

176-
@typing.final
177-
class ClearValueRequest(google.protobuf.message.Message):
178-
DESCRIPTOR: google.protobuf.descriptor.Descriptor
179-
180-
PANEL_ID_FIELD_NUMBER: builtins.int
181-
VALUE_ID_FIELD_NUMBER: builtins.int
182-
panel_id: builtins.str
183-
"""Unique ID of the panel"""
184-
value_id: builtins.str
185-
"""Unique ID of the value"""
186-
def __init__(
187-
self,
188-
*,
189-
panel_id: builtins.str = ...,
190-
value_id: builtins.str = ...,
191-
) -> None: ...
192-
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "value_id", b"value_id"]) -> None: ...
193-
194-
global___ClearValueRequest = ClearValueRequest
195-
196-
@typing.final
197-
class ClearValueResponse(google.protobuf.message.Message):
198-
DESCRIPTOR: google.protobuf.descriptor.Descriptor
199-
200-
def __init__(
201-
self,
202-
) -> None: ...
203-
204-
global___ClearValueResponse = ClearValueResponse
205-
206176
@typing.final
207177
class ClosePanelRequest(google.protobuf.message.Message):
208178
DESCRIPTOR: google.protobuf.descriptor.Descriptor

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ def __init__(self, channel):
3535
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueRequest.SerializeToString,
3636
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueResponse.FromString,
3737
)
38-
self.ClearValue = channel.unary_unary(
39-
'/ni.pythonpanel.v1.PythonPanelService/ClearValue',
40-
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClearValueRequest.SerializeToString,
41-
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClearValueResponse.FromString,
42-
)
4338
self.ClosePanel = channel.unary_unary(
4439
'/ni.pythonpanel.v1.PythonPanelService/ClosePanel',
4540
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClosePanelRequest.SerializeToString,
@@ -88,14 +83,6 @@ def SetValue(self, request, context):
8883
context.set_details('Method not implemented!')
8984
raise NotImplementedError('Method not implemented!')
9085

91-
def ClearValue(self, request, context):
92-
"""Clear a value for a control on the panel
93-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
94-
"""
95-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
96-
context.set_details('Method not implemented!')
97-
raise NotImplementedError('Method not implemented!')
98-
9986
def ClosePanel(self, request, context):
10087
"""Close a panel
10188
Status Codes for errors:
@@ -128,11 +115,6 @@ def add_PythonPanelServiceServicer_to_server(servicer, server):
128115
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueRequest.FromString,
129116
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueResponse.SerializeToString,
130117
),
131-
'ClearValue': grpc.unary_unary_rpc_method_handler(
132-
servicer.ClearValue,
133-
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClearValueRequest.FromString,
134-
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClearValueResponse.SerializeToString,
135-
),
136118
'ClosePanel': grpc.unary_unary_rpc_method_handler(
137119
servicer.ClosePanel,
138120
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClosePanelRequest.FromString,
@@ -217,23 +199,6 @@ def SetValue(request,
217199
options, channel_credentials,
218200
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
219201

220-
@staticmethod
221-
def ClearValue(request,
222-
target,
223-
options=(),
224-
channel_credentials=None,
225-
call_credentials=None,
226-
insecure=False,
227-
compression=None,
228-
wait_for_ready=None,
229-
timeout=None,
230-
metadata=None):
231-
return grpc.experimental.unary_unary(request, target, '/ni.pythonpanel.v1.PythonPanelService/ClearValue',
232-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClearValueRequest.SerializeToString,
233-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.ClearValueResponse.FromString,
234-
options, channel_credentials,
235-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
236-
237202
@staticmethod
238203
def ClosePanel(request,
239204
target,

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.pyi

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ class PythonPanelServiceStub:
5858
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
5959
"""
6060

61-
ClearValue: grpc.UnaryUnaryMultiCallable[
62-
ni.pythonpanel.v1.python_panel_service_pb2.ClearValueRequest,
63-
ni.pythonpanel.v1.python_panel_service_pb2.ClearValueResponse,
64-
]
65-
"""Clear a value for a control on the panel
66-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
67-
"""
68-
6961
ClosePanel: grpc.UnaryUnaryMultiCallable[
7062
ni.pythonpanel.v1.python_panel_service_pb2.ClosePanelRequest,
7163
ni.pythonpanel.v1.python_panel_service_pb2.ClosePanelResponse,
@@ -115,14 +107,6 @@ class PythonPanelServiceAsyncStub:
115107
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
116108
"""
117109

118-
ClearValue: grpc.aio.UnaryUnaryMultiCallable[
119-
ni.pythonpanel.v1.python_panel_service_pb2.ClearValueRequest,
120-
ni.pythonpanel.v1.python_panel_service_pb2.ClearValueResponse,
121-
]
122-
"""Clear a value for a control on the panel
123-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
124-
"""
125-
126110
ClosePanel: grpc.aio.UnaryUnaryMultiCallable[
127111
ni.pythonpanel.v1.python_panel_service_pb2.ClosePanelRequest,
128112
ni.pythonpanel.v1.python_panel_service_pb2.ClosePanelResponse,
@@ -180,16 +164,6 @@ class PythonPanelServiceServicer(metaclass=abc.ABCMeta):
180164
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
181165
"""
182166

183-
@abc.abstractmethod
184-
def ClearValue(
185-
self,
186-
request: ni.pythonpanel.v1.python_panel_service_pb2.ClearValueRequest,
187-
context: _ServicerContext,
188-
) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.ClearValueResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.ClearValueResponse]]:
189-
"""Clear a value for a control on the panel
190-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
191-
"""
192-
193167
@abc.abstractmethod
194168
def ClosePanel(
195169
self,

src/nipanel/_panel_client.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
EnumeratePanelsRequest,
1414
GetValueRequest,
1515
SetValueRequest,
16-
ClearValueRequest,
1716
)
1817
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceStub
1918
from ni_measurement_plugin_sdk_service.discovery import DiscoveryClient
@@ -120,16 +119,6 @@ def get_value(self, panel_id: str, value_id: str) -> object:
120119
the_value = from_any(response.value)
121120
return the_value
122121

123-
def clear_value(self, panel_id: str, value_id: str) -> None:
124-
"""Clear the value for the control with value_id.
125-
126-
Args:
127-
panel_id: The ID of the panel.
128-
value_id: The ID of the control.
129-
"""
130-
clear_value_request = ClearValueRequest(panel_id=panel_id, value_id=value_id)
131-
self._invoke_with_retry(self._get_stub().ClearValue, clear_value_request)
132-
133122
def _get_stub(self) -> PythonPanelServiceStub:
134123
if self._stub is None:
135124
if self._grpc_channel is not None:

src/nipanel/_panel_value_accessor.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,3 @@ def set_value(self, value_id: str, value: object) -> None:
5858
value: The value
5959
"""
6060
self._panel_client.set_value(self._panel_id, value_id, value)
61-
62-
def clear_value(self, value_id: str) -> None:
63-
"""Clear the value for a control on the panel.
64-
65-
Args:
66-
value_id: The id of the value
67-
"""
68-
self._panel_client.clear_value(self._panel_id, value_id)
69-
70-
def has_value(self, value_id: str) -> bool:
71-
"""Check if the panel has a value with the given ID.
72-
73-
Args:
74-
value_id: The id of the value
75-
76-
Returns:
77-
True if the panel has the value, False otherwise.
78-
"""
79-
return value_id in self.get_value_ids()
80-
81-
def get_value_ids(self) -> list[str]:
82-
"""Get the value IDs that have been set for the panel.
83-
84-
Returns:
85-
A list of value IDs for the panel.
86-
"""
87-
return self._panel_client.enumerate_panels()[self._panel_id][1]

tests/unit/test_panel_client.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,6 @@ def test___set_value___enumerate_panels_shows_value(
6868
assert client.enumerate_panels() == {"panel1": (False, ["val1"])}
6969

7070

71-
def test___set_value___clear_value___enumerate_panels_shows_no_value(
72-
fake_panel_channel: grpc.Channel,
73-
) -> None:
74-
client = create_panel_client(fake_panel_channel)
75-
client.set_value("panel1", "val1", "value1")
76-
77-
client.clear_value("panel1", "val1")
78-
79-
assert client.enumerate_panels() == {"panel1": (False, [])}
80-
81-
82-
def test___set_values___clear_value_2___enumerate_panels_has_value_1(
83-
fake_panel_channel: grpc.Channel,
84-
) -> None:
85-
client = create_panel_client(fake_panel_channel)
86-
client.set_value("panel1", "val1", "value1")
87-
client.set_value("panel1", "val2", "value2")
88-
89-
client.clear_value("panel1", "val2")
90-
91-
assert client.enumerate_panels() == {"panel1": (False, ["val1"])}
92-
93-
9471
def test___set_value___gets_value(fake_panel_channel: grpc.Channel) -> None:
9572
client = create_panel_client(fake_panel_channel)
9673

tests/unit/test_streamlit_panel.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test___first_open_panel_fails___open_panel___gets_value(
111111
assert panel.get_value(value_id) == string_value
112112

113113

114-
def test___unopened_panel___set_value___has_value(
114+
def test___unopened_panel___set_value___client_has_value(
115115
fake_panel_channel: grpc.Channel,
116116
) -> None:
117117
"""Test that set_value() succeeds before the user opens the panel."""
@@ -121,21 +121,7 @@ def test___unopened_panel___set_value___has_value(
121121
string_value = "test_value"
122122
panel.set_value(value_id, string_value)
123123

124-
assert panel.has_value(value_id)
125-
126-
127-
def test___set_value___clear_value___does_not_have_value(
128-
fake_panel_channel: grpc.Channel,
129-
) -> None:
130-
"""Test that set_value() succeeds before the user opens the panel."""
131-
panel = StreamlitPanel("my_panel", "path/to/script", grpc_channel=fake_panel_channel)
132-
value_id = "test_id"
133-
string_value = "test_value"
134-
panel.set_value(value_id, string_value)
135-
136-
panel.clear_value(value_id)
137-
138-
assert not panel.has_value(value_id)
124+
assert panel._panel_client.enumerate_panels() == {"my_panel": (False, [value_id])}
139125

140126

141127
def test___unopened_panel___get_unset_value___raises_exception(

tests/utils/_fake_python_panel_servicer.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
GetValueResponse,
1414
SetValueRequest,
1515
SetValueResponse,
16-
ClearValueRequest,
17-
ClearValueResponse,
1816
)
1917
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceServicer
2018

@@ -69,14 +67,6 @@ def SetValue(self, request: SetValueRequest, context: Any) -> SetValueResponse:
6967
self._panel_value_ids[request.panel_id][request.value_id] = request.value
7068
return SetValueResponse()
7169

72-
def ClearValue( # noqa: N802
73-
self, request: ClearValueRequest, context: Any
74-
) -> ClearValueResponse:
75-
"""Trivial implementation for testing."""
76-
if request.panel_id in self._panel_value_ids:
77-
self._panel_value_ids[request.panel_id].pop(request.value_id, None)
78-
return ClearValueResponse()
79-
8070
def fail_next_open_panel(self) -> None:
8171
"""Set whether the OpenPanel method should fail the next time it is called."""
8272
self._fail_next_open_panel = True

0 commit comments

Comments
 (0)