Skip to content

Commit 478c997

Browse files
Mike ProsserMike Prosser
authored andcommitted
we don't need set_values() after all
1 parent 72c30c4 commit 478c997

File tree

13 files changed

+13
-345
lines changed

13 files changed

+13
-345
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ start docs\_build\index.html
6161
3. Open http://localhost:42001/panel-service/panels/hello_panel/ in your browser
6262
4. If there is an error about missing imports (especially nipanel), execute this
6363
command (from the nipanel-python directory) to install the dependencies into the venv:
64-
`%localappdata%\Temp\python_panel_service_venv\Scripts\python.exe -m pip install .\[examples,dev]`,
64+
`%localappdata%\Temp\python_panel_service_venv\Scripts\python.exe -m pip install . streamlit-echarts>=0.4.0`,
6565
then restart the PythonPanelService and re-run hello.py.
6666

6767
You can see all running panels (and stop them) at: http://localhost:42001/panel-service/

examples/hello/hello.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
panel_script_path = Path(__file__).with_name("hello_panel.py")
88
panel = nipanel.create_panel(panel_script_path)
99

10-
panel.set_value("hello_string", "Hello, World!")
10+
index = 0
11+
while True:
12+
panel.set_value("hello_string", f"Hello, World! {index}")
13+
index += 1
14+
print(f"...{index}")
1115

1216
print(f"Panel URL: {panel.panel_url}")

examples/simple_graph/simple_graph.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,10 @@
2525
time_points = np.linspace(0, num_points, num_points)
2626
sine_values = amplitude * np.sin(frequency * time_points)
2727

28-
panel.set_values(
29-
{
30-
"time_points": time_points.tolist(),
31-
"sine_values": sine_values.tolist(),
32-
"amplitude": amplitude,
33-
"frequency": frequency,
34-
}
35-
)
36-
37-
# panel.set_value("time_points", time_points.tolist())
38-
# panel.set_value("sine_values", sine_values.tolist())
39-
# panel.set_value("amplitude", amplitude)
40-
# panel.set_value("frequency", frequency)
28+
panel.set_value("time_points", time_points.tolist())
29+
panel.set_value("sine_values", sine_values.tolist())
30+
panel.set_value("amplitude", amplitude)
31+
panel.set_value("frequency", frequency)
4132

4233
# Slowly vary the frequency for a more dynamic visualization
4334
frequency = 1.0 + 0.5 * math.sin(time.time() / 5.0)

protos/ni/pythonpanel/v1/python_panel_service.proto

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ service PythonPanelService {
4141
// Status Codes for errors:
4242
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
4343
rpc SetValue(SetValueRequest) returns (SetValueResponse);
44-
45-
// Set values for multiple controls on the panel
46-
// Status Codes for errors:
47-
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
48-
rpc SetValues(SetValuesRequest) returns (SetValuesResponse);
4944
}
5045

5146
message StartPanelRequest {
@@ -119,26 +114,4 @@ message SetValueRequest {
119114
}
120115

121116
message SetValueResponse {
122-
}
123-
124-
message SetValuesRequest {
125-
// Unique ID of the panel
126-
string panel_id = 1;
127-
128-
// Value IDs and Values
129-
repeated ValueInformation values = 2;
130-
131-
// Notify other clients of these new values
132-
bool notify = 3;
133-
}
134-
135-
message ValueInformation {
136-
// Unique ID of the value
137-
string value_id = 1;
138-
139-
// The value
140-
google.protobuf.Any value = 2;
141-
}
142-
143-
message SetValuesResponse {
144117
}

src/ni/pythonpanel/v1/python_panel_service_pb2.py

Lines changed: 3 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: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -212,62 +212,3 @@ class SetValueResponse(google.protobuf.message.Message):
212212
) -> None: ...
213213

214214
global___SetValueResponse = SetValueResponse
215-
216-
@typing.final
217-
class SetValuesRequest(google.protobuf.message.Message):
218-
DESCRIPTOR: google.protobuf.descriptor.Descriptor
219-
220-
PANEL_ID_FIELD_NUMBER: builtins.int
221-
VALUES_FIELD_NUMBER: builtins.int
222-
NOTIFY_FIELD_NUMBER: builtins.int
223-
panel_id: builtins.str
224-
"""Unique ID of the panel"""
225-
notify: builtins.bool
226-
"""Notify other clients of these new values"""
227-
@property
228-
def values(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ValueInformation]:
229-
"""Value IDs and Values"""
230-
231-
def __init__(
232-
self,
233-
*,
234-
panel_id: builtins.str = ...,
235-
values: collections.abc.Iterable[global___ValueInformation] | None = ...,
236-
notify: builtins.bool = ...,
237-
) -> None: ...
238-
def ClearField(self, field_name: typing.Literal["notify", b"notify", "panel_id", b"panel_id", "values", b"values"]) -> None: ...
239-
240-
global___SetValuesRequest = SetValuesRequest
241-
242-
@typing.final
243-
class ValueInformation(google.protobuf.message.Message):
244-
DESCRIPTOR: google.protobuf.descriptor.Descriptor
245-
246-
VALUE_ID_FIELD_NUMBER: builtins.int
247-
VALUE_FIELD_NUMBER: builtins.int
248-
value_id: builtins.str
249-
"""Unique ID of the value"""
250-
@property
251-
def value(self) -> google.protobuf.any_pb2.Any:
252-
"""The value"""
253-
254-
def __init__(
255-
self,
256-
*,
257-
value_id: builtins.str = ...,
258-
value: google.protobuf.any_pb2.Any | None = ...,
259-
) -> None: ...
260-
def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ...
261-
def ClearField(self, field_name: typing.Literal["value", b"value", "value_id", b"value_id"]) -> None: ...
262-
263-
global___ValueInformation = ValueInformation
264-
265-
@typing.final
266-
class SetValuesResponse(google.protobuf.message.Message):
267-
DESCRIPTOR: google.protobuf.descriptor.Descriptor
268-
269-
def __init__(
270-
self,
271-
) -> None: ...
272-
273-
global___SetValuesResponse = SetValuesResponse

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ def __init__(self, channel):
4040
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueRequest.SerializeToString,
4141
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueResponse.FromString,
4242
)
43-
self.SetValues = channel.unary_unary(
44-
'/ni.pythonpanel.v1.PythonPanelService/SetValues',
45-
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValuesRequest.SerializeToString,
46-
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValuesResponse.FromString,
47-
)
4843

4944

5045
class PythonPanelServiceServicer(object):
@@ -97,15 +92,6 @@ def SetValue(self, request, context):
9792
context.set_details('Method not implemented!')
9893
raise NotImplementedError('Method not implemented!')
9994

100-
def SetValues(self, request, context):
101-
"""Set values for multiple controls on the panel
102-
Status Codes for errors:
103-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
104-
"""
105-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
106-
context.set_details('Method not implemented!')
107-
raise NotImplementedError('Method not implemented!')
108-
10995

11096
def add_PythonPanelServiceServicer_to_server(servicer, server):
11197
rpc_method_handlers = {
@@ -134,11 +120,6 @@ def add_PythonPanelServiceServicer_to_server(servicer, server):
134120
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueRequest.FromString,
135121
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueResponse.SerializeToString,
136122
),
137-
'SetValues': grpc.unary_unary_rpc_method_handler(
138-
servicer.SetValues,
139-
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValuesRequest.FromString,
140-
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValuesResponse.SerializeToString,
141-
),
142123
}
143124
generic_handler = grpc.method_handlers_generic_handler(
144125
'ni.pythonpanel.v1.PythonPanelService', rpc_method_handlers)
@@ -234,20 +215,3 @@ def SetValue(request,
234215
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValueResponse.FromString,
235216
options, channel_credentials,
236217
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
237-
238-
@staticmethod
239-
def SetValues(request,
240-
target,
241-
options=(),
242-
channel_credentials=None,
243-
call_credentials=None,
244-
insecure=False,
245-
compression=None,
246-
wait_for_ready=None,
247-
timeout=None,
248-
metadata=None):
249-
return grpc.experimental.unary_unary(request, target, '/ni.pythonpanel.v1.PythonPanelService/SetValues',
250-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValuesRequest.SerializeToString,
251-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.SetValuesResponse.FromString,
252-
options, channel_credentials,
253-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.pyi

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ class PythonPanelServiceStub:
6767
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
6868
"""
6969

70-
SetValues: grpc.UnaryUnaryMultiCallable[
71-
ni.pythonpanel.v1.python_panel_service_pb2.SetValuesRequest,
72-
ni.pythonpanel.v1.python_panel_service_pb2.SetValuesResponse,
73-
]
74-
"""Set values for multiple controls on the panel
75-
Status Codes for errors:
76-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
77-
"""
78-
7970
class PythonPanelServiceAsyncStub:
8071
"""Service interface for interacting with python panels"""
8172

@@ -125,15 +116,6 @@ class PythonPanelServiceAsyncStub:
125116
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
126117
"""
127118

128-
SetValues: grpc.aio.UnaryUnaryMultiCallable[
129-
ni.pythonpanel.v1.python_panel_service_pb2.SetValuesRequest,
130-
ni.pythonpanel.v1.python_panel_service_pb2.SetValuesResponse,
131-
]
132-
"""Set values for multiple controls on the panel
133-
Status Codes for errors:
134-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
135-
"""
136-
137119
class PythonPanelServiceServicer(metaclass=abc.ABCMeta):
138120
"""Service interface for interacting with python panels"""
139121

@@ -193,15 +175,4 @@ class PythonPanelServiceServicer(metaclass=abc.ABCMeta):
193175
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
194176
"""
195177

196-
@abc.abstractmethod
197-
def SetValues(
198-
self,
199-
request: ni.pythonpanel.v1.python_panel_service_pb2.SetValuesRequest,
200-
context: _ServicerContext,
201-
) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.SetValuesResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.SetValuesResponse]]:
202-
"""Set values for multiple controls on the panel
203-
Status Codes for errors:
204-
- INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
205-
"""
206-
207178
def add_PythonPanelServiceServicer_to_server(servicer: PythonPanelServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...

src/nipanel/_panel_client.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
EnumeratePanelsRequest,
1515
GetValueRequest,
1616
SetValueRequest,
17-
SetValuesRequest,
18-
ValueInformation,
1917
)
2018
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceStub
2119
from ni_measurement_plugin_sdk_service.discovery import DiscoveryClient
@@ -118,24 +116,6 @@ def set_value(self, panel_id: str, value_id: str, value: object, notify: bool) -
118116
)
119117
self._invoke_with_retry(self._get_stub().SetValue, set_value_request)
120118

121-
def set_values(self, panel_id: str, values: dict[str, object], notify: bool) -> None:
122-
"""Set multiple values for controls in a panel at once.
123-
124-
Args:
125-
panel_id: The ID of the panel.
126-
values: A dictionary mapping value IDs to their corresponding values.
127-
notify: Whether to notify other clients of the new values.
128-
"""
129-
value_informations = []
130-
for value_id, value in values.items():
131-
new_any = to_any(value)
132-
value_informations.append(ValueInformation(value_id=value_id, value=new_any))
133-
134-
set_values_request = SetValuesRequest(
135-
panel_id=panel_id, values=value_informations, notify=notify
136-
)
137-
self._invoke_with_retry(self._get_stub().SetValues, set_values_request)
138-
139119
def get_value(self, panel_id: str, value_id: str) -> object:
140120
"""Get the value for the control with value_id.
141121

src/nipanel/_panel_value_accessor.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,3 @@ def set_value(self, value_id: str, value: object) -> None:
8282
self._panel_client.set_value(
8383
self._panel_id, value_id, value, notify=self._notify_on_set_value
8484
)
85-
86-
def set_values(self, values: dict[str, object]) -> None:
87-
"""Set multiple values for controls on the panel.
88-
89-
Args:
90-
values: A dictionary mapping value IDs to their corresponding values.
91-
"""
92-
self._panel_client.set_values(self._panel_id, values, notify=self._notify_on_set_value)

0 commit comments

Comments
 (0)