Skip to content

Commit 3657463

Browse files
Mike ProsserMike Prosser
authored andcommitted
extract StreamlitPanelConfiguration to streamlit_panel_configuration.proto
1 parent 1c94962 commit 3657463

13 files changed

+159
-80
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ See [GitHub's official documentation](https://help.github.com/articles/using-pul
2222
# Getting Started
2323

2424
This is the command to generate the files in /src/ni/panels/v1/:
25-
`poetry run python -m grpc_tools.protoc --proto_path=protos --python_out=src/ --grpc_python_out=src/ --mypy_out=src/ --mypy_grpc_out=src/ ni/panels/v1/panel_service.proto ni/panels/v1/panel_types.proto`
25+
`poetry run python -m grpc_tools.protoc --proto_path=protos --python_out=src/ --grpc_python_out=src/ --mypy_out=src/ --mypy_grpc_out=src/ ni/panels/v1/panel_service.proto ni/panels/v1/panel_types.proto ni/panels/v1/streamlit_panel_configuration.proto`
2626

2727
# Testing
2828

protos/ni/panels/v1/panel_service.proto

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,12 @@ service PanelService {
5959
rpc SetValue(SetValueRequest) returns (SetValueResponse);
6060
}
6161

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-
7162
message StartPanelRequest {
7263
// Unique ID of the panel
7364
string panel_id = 1;
7465

75-
// Configuration for the panel
76-
oneof panel_configuration {
77-
StreamlitPanelConfiguration streamlit_panel_configuration = 2;
78-
}
66+
// Configuration for the panel, packed as Any
67+
google.protobuf.Any panel_configuration = 2;
7968
}
8069

8170
message StartPanelResponse {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
syntax = "proto3";
2+
3+
package ni.panels.v1;
4+
5+
option cc_enable_arenas = true;
6+
option csharp_namespace = "NationalInstruments.Panels.V1";
7+
option go_package = "panelsv1";
8+
option java_multiple_files = true;
9+
option java_outer_classname = "StreamlitPanelConfigurationProto";
10+
option java_package = "com.ni.panels.v1";
11+
option objc_class_prefix = "NIPS";
12+
option php_namespace = "NI\\Panels\\V1";
13+
option ruby_package = "NI::Panels::V1";
14+
15+
// Pack this into PanelService.StartPanelRequest.panel_configuration to start a Streamlit panel.
16+
message StreamlitPanelConfiguration
17+
{
18+
// Absolute path of the streamlit script file on disk, or network path to the file. This must end in ".py".
19+
string panel_script_path = 1;
20+
21+
// Path to the python interpreter to use for running the streamlit script.
22+
string python_path = 2;
23+
}

src/ni/panels/v1/panel_service_pb2.py

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

src/ni/panels/v1/panel_service_pb2.pyi

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,26 @@ import typing
1313

1414
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
1515

16-
@typing.final
17-
class StreamlitPanelConfiguration(google.protobuf.message.Message):
18-
DESCRIPTOR: google.protobuf.descriptor.Descriptor
19-
20-
PANEL_SCRIPT_PATH_FIELD_NUMBER: builtins.int
21-
PYTHON_PATH_FIELD_NUMBER: builtins.int
22-
panel_script_path: builtins.str
23-
"""Absolute path of the streamlit script file on disk, or network path to the file. This must end in ".py"."""
24-
python_path: builtins.str
25-
"""Path to the python interpreter to use for running the streamlit script."""
26-
def __init__(
27-
self,
28-
*,
29-
panel_script_path: builtins.str = ...,
30-
python_path: builtins.str = ...,
31-
) -> 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-
3616
@typing.final
3717
class StartPanelRequest(google.protobuf.message.Message):
3818
DESCRIPTOR: google.protobuf.descriptor.Descriptor
3919

4020
PANEL_ID_FIELD_NUMBER: builtins.int
41-
STREAMLIT_PANEL_CONFIGURATION_FIELD_NUMBER: builtins.int
21+
PANEL_CONFIGURATION_FIELD_NUMBER: builtins.int
4222
panel_id: builtins.str
4323
"""Unique ID of the panel"""
4424
@property
45-
def streamlit_panel_configuration(self) -> global___StreamlitPanelConfiguration: ...
25+
def panel_configuration(self) -> google.protobuf.any_pb2.Any:
26+
"""Configuration for the panel, packed as Any"""
27+
4628
def __init__(
4729
self,
4830
*,
4931
panel_id: builtins.str = ...,
50-
streamlit_panel_configuration: global___StreamlitPanelConfiguration | None = ...,
32+
panel_configuration: google.protobuf.any_pb2.Any | None = ...,
5133
) -> 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: ...
34+
def HasField(self, field_name: typing.Literal["panel_configuration", b"panel_configuration"]) -> builtins.bool: ...
35+
def ClearField(self, field_name: typing.Literal["panel_configuration", b"panel_configuration", "panel_id", b"panel_id"]) -> None: ...
5536

5637
global___StartPanelRequest = StartPanelRequest
5738

src/ni/panels/v1/streamlit_panel_configuration_pb2.py

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
@generated by mypy-protobuf. Do not edit manually!
3+
isort:skip_file
4+
"""
5+
6+
import builtins
7+
import google.protobuf.descriptor
8+
import google.protobuf.message
9+
import typing
10+
11+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
12+
13+
@typing.final
14+
class StreamlitPanelConfiguration(google.protobuf.message.Message):
15+
"""Pack this into PanelService.StartPanelRequest.panel_configuration to start a Streamlit panel."""
16+
17+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
18+
19+
PANEL_SCRIPT_PATH_FIELD_NUMBER: builtins.int
20+
PYTHON_PATH_FIELD_NUMBER: builtins.int
21+
panel_script_path: builtins.str
22+
"""Absolute path of the streamlit script file on disk, or network path to the file. This must end in ".py"."""
23+
python_path: builtins.str
24+
"""Path to the python interpreter to use for running the streamlit script."""
25+
def __init__(
26+
self,
27+
*,
28+
panel_script_path: builtins.str = ...,
29+
python_path: builtins.str = ...,
30+
) -> None: ...
31+
def ClearField(self, field_name: typing.Literal["panel_script_path", b"panel_script_path", "python_path", b"python_path"]) -> None: ...
32+
33+
global___StreamlitPanelConfiguration = StreamlitPanelConfiguration
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2+
"""Client and server classes corresponding to protobuf-defined services."""
3+
import grpc
4+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
@generated by mypy-protobuf. Do not edit manually!
3+
isort:skip_file
4+
"""
5+
6+
import abc
7+
import collections.abc
8+
import grpc
9+
import grpc.aio
10+
import typing
11+
12+
_T = typing.TypeVar("_T")
13+
14+
class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ...
15+
16+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg]
17+
...

src/nipanel/_panel_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from typing import Callable, TypeVar
66

77
import grpc
8+
from google.protobuf.any_pb2 import Any
89
from ni.panels.v1.panel_service_pb2 import (
9-
StreamlitPanelConfiguration,
1010
StartPanelRequest,
1111
StopPanelRequest,
1212
EnumeratePanelsRequest,
@@ -15,6 +15,7 @@
1515
SetValueRequest,
1616
)
1717
from ni.panels.v1.panel_service_pb2_grpc import PanelServiceStub
18+
from ni.panels.v1.streamlit_panel_configuration_pb2 import StreamlitPanelConfiguration
1819
from ni_measurement_plugin_sdk_service.discovery import DiscoveryClient
1920
from ni_measurement_plugin_sdk_service.grpc.channelpool import GrpcChannelPool
2021
from typing_extensions import ParamSpec
@@ -52,8 +53,10 @@ def start_streamlit_panel(self, panel_id: str, panel_script_path: str, python_pa
5253
streamlit_panel_configuration = StreamlitPanelConfiguration(
5354
panel_script_path=panel_script_path, python_path=python_path
5455
)
56+
panel_configuration_any = Any()
57+
panel_configuration_any.Pack(streamlit_panel_configuration)
5558
start_panel_request = StartPanelRequest(
56-
panel_id=panel_id, streamlit_panel_configuration=streamlit_panel_configuration
59+
panel_id=panel_id, panel_configuration=panel_configuration_any
5760
)
5861
response = self._invoke_with_retry(self._get_stub().StartPanel, start_panel_request)
5962
return response.panel_uri

0 commit comments

Comments
 (0)