Skip to content

Commit a78b15a

Browse files
Mike ProsserMike Prosser
authored andcommitted
remove service class since it is not needed by the discovery service, provided interface is enough
1 parent 3657463 commit a78b15a

File tree

5 files changed

+3
-15
lines changed

5 files changed

+3
-15
lines changed

src/nipanel/_panel_client.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@
3030

3131
_logger = logging.getLogger(__name__)
3232

33-
PANEL_INTERFACE = "ni.panels.v1.PanelService"
33+
PANEL_SERVICE = "ni.panels.v1.PanelService"
3434

3535

3636
class _PanelClient:
3737
def __init__(
3838
self,
3939
*,
40-
service_class: str | None = None,
4140
discovery_client: DiscoveryClient | None = None,
4241
grpc_channel_pool: GrpcChannelPool | None = None,
4342
grpc_channel: grpc.Channel | None = None,
4443
) -> None:
4544
self._initialization_lock = threading.Lock()
46-
self._service_class = service_class
4745
self._discovery_client = discovery_client
4846
self._grpc_channel_pool = grpc_channel_pool
4947
self._grpc_channel = grpc_channel
@@ -98,7 +96,7 @@ def _get_stub(self) -> PanelServiceStub:
9896
if self._stub is None:
9997
if self._grpc_channel is not None:
10098
self._stub = PanelServiceStub(self._grpc_channel)
101-
elif self._service_class is not None:
99+
else:
102100
with self._initialization_lock:
103101
if self._grpc_channel_pool is None:
104102
_logger.debug("Creating unshared GrpcChannelPool.")
@@ -110,13 +108,10 @@ def _get_stub(self) -> PanelServiceStub:
110108
)
111109

112110
service_location = self._discovery_client.resolve_service(
113-
provided_interface=PANEL_INTERFACE,
114-
service_class=self._service_class,
111+
provided_interface=PANEL_SERVICE
115112
)
116113
channel = self._grpc_channel_pool.get_channel(service_location.insecure_address)
117114
self._stub = PanelServiceStub(channel)
118-
else:
119-
raise TypeError("Either grpc_channel or service_class must be provided.")
120115
return self._stub
121116

122117
def _invoke_with_retry(

src/nipanel/_panel_value_accessor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ def __init__(
2929
self,
3030
*,
3131
panel_id: str,
32-
service_class: str | None = None,
3332
notify_on_set_value: bool = True,
3433
discovery_client: DiscoveryClient | None = None,
3534
grpc_channel_pool: GrpcChannelPool | None = None,
3635
grpc_channel: grpc.Channel | None = None,
3736
) -> None:
3837
"""Initialize the accessor."""
3938
self._panel_client = _PanelClient(
40-
service_class=service_class,
4139
discovery_client=discovery_client,
4240
grpc_channel_pool=grpc_channel_pool,
4341
grpc_channel=grpc_channel,
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
STREAMLIT_PYTHON_PANEL_SERVICE = "ni.panels.v1.PanelService"
21
STREAMLIT_REFRESH_COMPONENT_URL = "http://localhost:42001/panel-service/refresh"

src/nipanel/_streamlit_panel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from ni_measurement_plugin_sdk_service.grpc.channelpool import GrpcChannelPool
1010

1111
from nipanel._panel_value_accessor import PanelValueAccessor
12-
from nipanel._streamlit_constants import STREAMLIT_PYTHON_PANEL_SERVICE
1312

1413

1514
@final
@@ -41,7 +40,6 @@ def __init__(
4140
"""
4241
super().__init__(
4342
panel_id=panel_id,
44-
service_class=STREAMLIT_PYTHON_PANEL_SERVICE,
4543
discovery_client=discovery_client,
4644
grpc_channel_pool=grpc_channel_pool,
4745
grpc_channel=grpc_channel,

src/nipanel/_streamlit_panel_initializer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from nipanel._convert import is_supported_type
77
from nipanel._panel_value_accessor import PanelValueAccessor
8-
from nipanel._streamlit_constants import STREAMLIT_PYTHON_PANEL_SERVICE
98
from nipanel._streamlit_panel import StreamlitPanel
109
from nipanel.streamlit_refresh import initialize_refresh_component
1110

@@ -84,7 +83,6 @@ def _initialize_panel_from_base_path() -> PanelValueAccessor:
8483
return PanelValueAccessor(
8584
panel_id=panel_id,
8685
notify_on_set_value=False,
87-
service_class=STREAMLIT_PYTHON_PANEL_SERVICE,
8886
)
8987

9088

0 commit comments

Comments
 (0)