Skip to content

Commit 4834bfe

Browse files
Mike ProsserMike Prosser
authored andcommitted
StreamlitPanelConfiguration
1 parent 0cb6e3f commit 4834bfe

File tree

9 files changed

+157
-129
lines changed

9 files changed

+157
-129
lines changed

protos/ni/pythonpanel/v1/python_panel_service.proto

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ option ruby_package = "NI::PythonPanel::V1";
1616

1717
// Service interface for interacting with python panels
1818
service PythonPanelService {
19-
// Start a panel using a streamlit script (or connect to if it has already been started)
19+
// Start a panel using the provided configuration (or connect to if it has already been started)
2020
// Status Codes for errors:
2121
// - INVALID_ARGUMENT:
22-
// - The panel script filename doesn't end in .py.
2322
// - The panel identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
23+
// - The panel configuration has an invalid argument.
2424
// - NOT_FOUND:
25-
// - The panel script file was not found.
26-
// - The python executable file was not found.
27-
rpc StartStreamlitPanel(StartStreamlitPanelRequest) returns (StartStreamlitPanelResponse);
25+
// - The panel configuration includes a file that was not found.
26+
rpc StartPanel(StartPanelRequest) returns (StartPanelResponse);
2827

2928
// Stop a panel
3029
// Status Codes for errors:
@@ -60,20 +59,28 @@ service PythonPanelService {
6059
rpc SetValue(SetValueRequest) returns (SetValueResponse);
6160
}
6261

63-
message StartStreamlitPanelRequest {
62+
message StreamlitPanelConfiguration
63+
{
64+
// Absolute path of the streamlit script file on disk, or network path to the file. This must end in ".py".
65+
string panel_script_path = 1;
66+
67+
// Path to the python interpreter to use for running the streamlit script.
68+
string python_path = 2;
69+
}
70+
71+
message StartPanelRequest {
6472
// Unique ID of the panel
6573
string panel_id = 1;
6674

67-
// Absolute path of the streamlit script file on disk, or network path to the file
68-
string panel_script_path = 2;
69-
70-
// Path to the python interpreter to use for running the streamlit script.
71-
string python_path = 3;
75+
// Configuration for the panel
76+
oneof panel_configuration {
77+
StreamlitPanelConfiguration streamlit_panel_configuration = 2;
78+
}
7279
}
7380

74-
message StartStreamlitPanelResponse {
75-
// Location of the panel's webpage
76-
string panel_url = 1;
81+
message StartPanelResponse {
82+
// Location of the panel
83+
string panel_uri = 1;
7784
}
7885

7986
message StopPanelRequest {
@@ -94,8 +101,8 @@ message PanelInformation {
94101
// Unique ID of the panel
95102
string panel_id = 1;
96103

97-
// Location of the panel's webpage
98-
string panel_url = 2;
104+
// Location of the panel
105+
string panel_uri = 2;
99106

100107
// IDs of all of the values associated with the panel
101108
repeated string value_ids = 3;

src/ni/pythonpanel/v1/python_panel_service_pb2.py

Lines changed: 31 additions & 29 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: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,62 @@ import typing
1414
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1515

1616
@typing.final
17-
class StartStreamlitPanelRequest(google.protobuf.message.Message):
17+
class StreamlitPanelConfiguration(google.protobuf.message.Message):
1818
DESCRIPTOR: google.protobuf.descriptor.Descriptor
1919

20-
PANEL_ID_FIELD_NUMBER: builtins.int
2120
PANEL_SCRIPT_PATH_FIELD_NUMBER: builtins.int
2221
PYTHON_PATH_FIELD_NUMBER: builtins.int
23-
panel_id: builtins.str
24-
"""Unique ID of the panel"""
2522
panel_script_path: builtins.str
26-
"""Absolute path of the streamlit script file on disk, or network path to the file"""
23+
"""Absolute path of the streamlit script file on disk, or network path to the file. This must end in ".py"."""
2724
python_path: builtins.str
2825
"""Path to the python interpreter to use for running the streamlit script."""
2926
def __init__(
3027
self,
3128
*,
32-
panel_id: builtins.str = ...,
3329
panel_script_path: builtins.str = ...,
3430
python_path: builtins.str = ...,
3531
) -> None: ...
36-
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_script_path", b"panel_script_path", "python_path", b"python_path"]) -> None: ...
32+
def ClearField(self, field_name: typing.Literal["panel_script_path", b"panel_script_path", "python_path", b"python_path"]) -> None: ...
33+
34+
global___StreamlitPanelConfiguration = StreamlitPanelConfiguration
35+
36+
@typing.final
37+
class StartPanelRequest(google.protobuf.message.Message):
38+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
39+
40+
PANEL_ID_FIELD_NUMBER: builtins.int
41+
STREAMLIT_PANEL_CONFIGURATION_FIELD_NUMBER: builtins.int
42+
panel_id: builtins.str
43+
"""Unique ID of the panel"""
44+
@property
45+
def streamlit_panel_configuration(self) -> global___StreamlitPanelConfiguration: ...
46+
def __init__(
47+
self,
48+
*,
49+
panel_id: builtins.str = ...,
50+
streamlit_panel_configuration: global___StreamlitPanelConfiguration | None = ...,
51+
) -> None: ...
52+
def HasField(self, field_name: typing.Literal["panel_configuration", b"panel_configuration", "streamlit_panel_configuration", b"streamlit_panel_configuration"]) -> builtins.bool: ...
53+
def ClearField(self, field_name: typing.Literal["panel_configuration", b"panel_configuration", "panel_id", b"panel_id", "streamlit_panel_configuration", b"streamlit_panel_configuration"]) -> None: ...
54+
def WhichOneof(self, oneof_group: typing.Literal["panel_configuration", b"panel_configuration"]) -> typing.Literal["streamlit_panel_configuration"] | None: ...
3755

38-
global___StartStreamlitPanelRequest = StartStreamlitPanelRequest
56+
global___StartPanelRequest = StartPanelRequest
3957

4058
@typing.final
41-
class StartStreamlitPanelResponse(google.protobuf.message.Message):
59+
class StartPanelResponse(google.protobuf.message.Message):
4260
DESCRIPTOR: google.protobuf.descriptor.Descriptor
4361

44-
PANEL_URL_FIELD_NUMBER: builtins.int
45-
panel_url: builtins.str
46-
"""Location of the panel's webpage"""
62+
PANEL_URI_FIELD_NUMBER: builtins.int
63+
panel_uri: builtins.str
64+
"""Location of the panel"""
4765
def __init__(
4866
self,
4967
*,
50-
panel_url: builtins.str = ...,
68+
panel_uri: builtins.str = ...,
5169
) -> None: ...
52-
def ClearField(self, field_name: typing.Literal["panel_url", b"panel_url"]) -> None: ...
70+
def ClearField(self, field_name: typing.Literal["panel_uri", b"panel_uri"]) -> None: ...
5371

54-
global___StartStreamlitPanelResponse = StartStreamlitPanelResponse
72+
global___StartPanelResponse = StartPanelResponse
5573

5674
@typing.final
5775
class StopPanelRequest(google.protobuf.message.Message):
@@ -98,12 +116,12 @@ class PanelInformation(google.protobuf.message.Message):
98116
DESCRIPTOR: google.protobuf.descriptor.Descriptor
99117

100118
PANEL_ID_FIELD_NUMBER: builtins.int
101-
PANEL_URL_FIELD_NUMBER: builtins.int
119+
PANEL_URI_FIELD_NUMBER: builtins.int
102120
VALUE_IDS_FIELD_NUMBER: builtins.int
103121
panel_id: builtins.str
104122
"""Unique ID of the panel"""
105-
panel_url: builtins.str
106-
"""Location of the panel's webpage"""
123+
panel_uri: builtins.str
124+
"""Location of the panel"""
107125
@property
108126
def value_ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
109127
"""IDs of all of the values associated with the panel"""
@@ -112,10 +130,10 @@ class PanelInformation(google.protobuf.message.Message):
112130
self,
113131
*,
114132
panel_id: builtins.str = ...,
115-
panel_url: builtins.str = ...,
133+
panel_uri: builtins.str = ...,
116134
value_ids: collections.abc.Iterable[builtins.str] | None = ...,
117135
) -> None: ...
118-
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_url", b"panel_url", "value_ids", b"value_ids"]) -> None: ...
136+
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_uri", b"panel_uri", "value_ids", b"value_ids"]) -> None: ...
119137

120138
global___PanelInformation = PanelInformation
121139

src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def __init__(self, channel):
1515
Args:
1616
channel: A grpc.Channel.
1717
"""
18-
self.StartStreamlitPanel = channel.unary_unary(
19-
'/ni.pythonpanel.v1.PythonPanelService/StartStreamlitPanel',
20-
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartStreamlitPanelRequest.SerializeToString,
21-
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartStreamlitPanelResponse.FromString,
18+
self.StartPanel = channel.unary_unary(
19+
'/ni.pythonpanel.v1.PythonPanelService/StartPanel',
20+
request_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartPanelRequest.SerializeToString,
21+
response_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartPanelResponse.FromString,
2222
)
2323
self.StopPanel = channel.unary_unary(
2424
'/ni.pythonpanel.v1.PythonPanelService/StopPanel',
@@ -51,15 +51,14 @@ class PythonPanelServiceServicer(object):
5151
"""Service interface for interacting with python panels
5252
"""
5353

54-
def StartStreamlitPanel(self, request, context):
55-
"""Start a panel using a streamlit script (or connect to if it has already been started)
54+
def StartPanel(self, request, context):
55+
"""Start a panel using the provided configuration (or connect to if it has already been started)
5656
Status Codes for errors:
5757
- INVALID_ARGUMENT:
58-
- The panel script filename doesn't end in .py.
5958
- The panel identifier contains invalid characters. Only alphanumeric characters and underscores are allowed.
59+
- The panel configuration has an invalid argument.
6060
- NOT_FOUND:
61-
- The panel script file was not found.
62-
- The python executable file was not found.
61+
- The panel configuration includes a file that was not found.
6362
"""
6463
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
6564
context.set_details('Method not implemented!')
@@ -121,10 +120,10 @@ def SetValue(self, request, context):
121120

122121
def add_PythonPanelServiceServicer_to_server(servicer, server):
123122
rpc_method_handlers = {
124-
'StartStreamlitPanel': grpc.unary_unary_rpc_method_handler(
125-
servicer.StartStreamlitPanel,
126-
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartStreamlitPanelRequest.FromString,
127-
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartStreamlitPanelResponse.SerializeToString,
123+
'StartPanel': grpc.unary_unary_rpc_method_handler(
124+
servicer.StartPanel,
125+
request_deserializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartPanelRequest.FromString,
126+
response_serializer=ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartPanelResponse.SerializeToString,
128127
),
129128
'StopPanel': grpc.unary_unary_rpc_method_handler(
130129
servicer.StopPanel,
@@ -163,7 +162,7 @@ class PythonPanelService(object):
163162
"""
164163

165164
@staticmethod
166-
def StartStreamlitPanel(request,
165+
def StartPanel(request,
167166
target,
168167
options=(),
169168
channel_credentials=None,
@@ -173,9 +172,9 @@ def StartStreamlitPanel(request,
173172
wait_for_ready=None,
174173
timeout=None,
175174
metadata=None):
176-
return grpc.experimental.unary_unary(request, target, '/ni.pythonpanel.v1.PythonPanelService/StartStreamlitPanel',
177-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartStreamlitPanelRequest.SerializeToString,
178-
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartStreamlitPanelResponse.FromString,
175+
return grpc.experimental.unary_unary(request, target, '/ni.pythonpanel.v1.PythonPanelService/StartPanel',
176+
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartPanelRequest.SerializeToString,
177+
ni_dot_pythonpanel_dot_v1_dot_python__panel__service__pb2.StartPanelResponse.FromString,
179178
options, channel_credentials,
180179
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
181180

0 commit comments

Comments
 (0)