Skip to content

Commit f142a07

Browse files
committed
Merge remote-tracking branch 'origin/main' into users/jfriedri/lofi-support-for-builtin-sequences
2 parents d3bb400 + 34e2f07 commit f142a07

16 files changed

+569
-96
lines changed

.github/workflows/report_test_results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: List downloaded files
2525
run: ls -lR
2626
- name: Publish test results
27-
uses: EnricoMi/publish-unit-test-result-action@afb2984f4d89672b2f9d9c13ae23d53779671984 # v2.19.0
27+
uses: EnricoMi/publish-unit-test-result-action@3a74b2957438d0b6e2e61d67b05318aa25c9e6c6 # v2.20.0
2828
with:
2929
files: "test_results/**/*.xml"
3030
if: always()

examples/sample/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Sample
2+
3+
This is a nipanel example that displays an interactive Streamlit app and updates its values.
4+
5+
### Feature
6+
7+
- Supports various data types
8+
9+
### Required Software
10+
11+
- Python 3.9 or later
12+
13+
### Usage
14+
15+
Run `poetry run examples/sample/sample.py`

examples/sample/sample.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""This example demonstrates how to open/update a Streamlit application using nipanel package."""
2+
3+
import pathlib
4+
5+
import nipanel
6+
7+
script_path = pathlib.Path(__file__)
8+
panel_script_path = str(script_path.with_name("sample_panel.py"))
9+
10+
panel = nipanel.StreamlitPanel(
11+
panel_id="sample_panel",
12+
streamlit_script_uri=panel_script_path,
13+
)
14+
panel.open_panel()
15+
panel.set_value("sample_string", "Hello, World!")
16+
panel.set_value("sample_int", 42)
17+
panel.set_value("sample_float", 3.14)
18+
panel.set_value("sample_bool", True)
19+
20+
input("Press Enter to close the panel...")
21+
22+
panel.close_panel(reset=True)

examples/sample/sample_panel.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Streamlit application script for displaying values using nipanel package."""
2+
3+
import streamlit as st
4+
5+
import nipanel
6+
7+
panel = nipanel.StreamlitPanelValueAccessor(panel_id="sample_panel")
8+
9+
st.title("Sample Panel")
10+
11+
col1, col2 = st.columns([0.4, 0.6])
12+
13+
with col1:
14+
st.write("String")
15+
st.write("Integer")
16+
st.write("Float")
17+
st.write("Boolean")
18+
19+
with col2:
20+
st.write(panel.get_value("sample_string"))
21+
st.write(panel.get_value("sample_int"))
22+
st.write(panel.get_value("sample_float"))
23+
st.write(panel.get_value("sample_bool"))

poetry.lock

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

protos/ni/pythonpanel/v1/python_panel_service.proto

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,39 @@ option ruby_package = "NI::PythonPanel::V1";
1616

1717
// Service interface for interacting with python panels
1818
service PythonPanelService {
19+
// Enumerate the panels available in the system
20+
// Status Codes for errors:
21+
rpc EnumeratePanels(EnumeratePanelsRequest) returns (EnumeratePanelsResponse);
22+
1923
// Open a panel
2024
// Status Codes for errors:
25+
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
2126
// - NOT_FOUND: the file for the panel was not found
2227
rpc OpenPanel(OpenPanelRequest) returns (OpenPanelResponse);
2328

2429
// Get a value for a control on the panel
2530
// Status Codes for errors:
26-
// - NOT_FOUND: the panel with the specified id was not found
31+
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
32+
// - NOT_FOUND: The value with the specified identifier was not found
2733
rpc GetValue(GetValueRequest) returns (GetValueResponse);
2834

2935
// Set a value for a control on the panel
3036
// Status Codes for errors:
31-
// - NOT_FOUND: the panel with the specified id was not found
37+
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
3238
rpc SetValue(SetValueRequest) returns (SetValueResponse);
39+
40+
// Close a panel
41+
// Status Codes for errors:
42+
// - INVALID_ARGUMENT: The specified identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
43+
rpc ClosePanel(ClosePanelRequest) returns (ClosePanelResponse);
44+
}
45+
46+
message EnumeratePanelsRequest {
47+
}
48+
49+
message EnumeratePanelsResponse {
50+
// The list of panels available in the system
51+
repeated string panel_ids = 1;
3352
}
3453

3554
message OpenPanelRequest {
@@ -40,12 +59,12 @@ message OpenPanelRequest {
4059
string panel_uri = 2;
4160
}
4261

43-
message OpenPanelResponse {
62+
message OpenPanelResponse {
4463
}
4564

4665
message GetValueRequest {
4766
// Unique ID of the panel
48-
string panel_id = 1;
67+
string panel_id = 1;
4968

5069
// Unique ID of value
5170
string value_id = 2;
@@ -58,14 +77,25 @@ message GetValueResponse {
5877

5978
message SetValueRequest {
6079
// Unique ID of the panel
61-
string panel_id = 1;
62-
80+
string panel_id = 1;
81+
6382
// Unique ID of the value
6483
string value_id = 2;
6584

6685
// The value
6786
google.protobuf.Any value = 3;
6887
}
6988

70-
message SetValueResponse {
89+
message SetValueResponse {
90+
}
91+
92+
message ClosePanelRequest {
93+
// Unique ID of the panel
94+
string panel_id = 1;
95+
96+
// Reset all storage associated with panel
97+
bool reset = 2;
98+
}
99+
100+
message ClosePanelResponse {
71101
}

src/ni/pythonpanel/v1/python_panel_service_pb2.py

Lines changed: 23 additions & 15 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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,43 @@ isort:skip_file
44
"""
55

66
import builtins
7+
import collections.abc
78
import google.protobuf.any_pb2
89
import google.protobuf.descriptor
10+
import google.protobuf.internal.containers
911
import google.protobuf.message
1012
import typing
1113

1214
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1315

16+
@typing.final
17+
class EnumeratePanelsRequest(google.protobuf.message.Message):
18+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
19+
20+
def __init__(
21+
self,
22+
) -> None: ...
23+
24+
global___EnumeratePanelsRequest = EnumeratePanelsRequest
25+
26+
@typing.final
27+
class EnumeratePanelsResponse(google.protobuf.message.Message):
28+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
29+
30+
PANEL_IDS_FIELD_NUMBER: builtins.int
31+
@property
32+
def panel_ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
33+
"""The list of panels available in the system"""
34+
35+
def __init__(
36+
self,
37+
*,
38+
panel_ids: collections.abc.Iterable[builtins.str] | None = ...,
39+
) -> None: ...
40+
def ClearField(self, field_name: typing.Literal["panel_ids", b"panel_ids"]) -> None: ...
41+
42+
global___EnumeratePanelsResponse = EnumeratePanelsResponse
43+
1444
@typing.final
1545
class OpenPanelRequest(google.protobuf.message.Message):
1646
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -116,3 +146,33 @@ class SetValueResponse(google.protobuf.message.Message):
116146
) -> None: ...
117147

118148
global___SetValueResponse = SetValueResponse
149+
150+
@typing.final
151+
class ClosePanelRequest(google.protobuf.message.Message):
152+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
153+
154+
PANEL_ID_FIELD_NUMBER: builtins.int
155+
RESET_FIELD_NUMBER: builtins.int
156+
panel_id: builtins.str
157+
"""Unique ID of the panel"""
158+
reset: builtins.bool
159+
"""Reset all storage associated with panel"""
160+
def __init__(
161+
self,
162+
*,
163+
panel_id: builtins.str = ...,
164+
reset: builtins.bool = ...,
165+
) -> None: ...
166+
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "reset", b"reset"]) -> None: ...
167+
168+
global___ClosePanelRequest = ClosePanelRequest
169+
170+
@typing.final
171+
class ClosePanelResponse(google.protobuf.message.Message):
172+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
173+
174+
def __init__(
175+
self,
176+
) -> None: ...
177+
178+
global___ClosePanelResponse = ClosePanelResponse

0 commit comments

Comments
 (0)