Skip to content

Commit 2b971e0

Browse files
Mike ProsserMike Prosser
authored andcommitted
pass the python path into the panel client
1 parent 1727616 commit 2b971e0

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

protos/ni/pythonpanel/v1/python_panel_service.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ message StartPanelRequest {
4949

5050
// Absolute path of the panel script's file on disk, or network path to the file
5151
string panel_script_path = 2;
52+
53+
// Path to the python interpreter to use for the panel script.
54+
string python_path = 3;
5255
}
5356

5457
message StartPanelResponse {

src/ni/pythonpanel/v1/python_panel_service_pb2.py

Lines changed: 24 additions & 24 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ class StartPanelRequest(google.protobuf.message.Message):
1919

2020
PANEL_ID_FIELD_NUMBER: builtins.int
2121
PANEL_SCRIPT_PATH_FIELD_NUMBER: builtins.int
22+
PYTHON_PATH_FIELD_NUMBER: builtins.int
2223
panel_id: builtins.str
2324
"""Unique ID of the panel"""
2425
panel_script_path: builtins.str
2526
"""Absolute path of the panel script's file on disk, or network path to the file"""
27+
python_path: builtins.str
28+
"""Path to the python interpreter to use for the panel script."""
2629
def __init__(
2730
self,
2831
*,
2932
panel_id: builtins.str = ...,
3033
panel_script_path: builtins.str = ...,
34+
python_path: builtins.str = ...,
3135
) -> None: ...
32-
def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_script_path", b"panel_script_path"]) -> 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: ...
3337

3438
global___StartPanelRequest = StartPanelRequest
3539

src/nipanel/_panel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import annotations
22

3+
import sys
34
from abc import ABC
5+
from pathlib import Path
46

57
import grpc
68
from ni_measurement_plugin_sdk_service.discovery import DiscoveryClient
@@ -35,7 +37,8 @@ def __init__(
3537
grpc_channel=grpc_channel,
3638
)
3739
self._panel_script_path = panel_script_path
38-
self._panel_url = self._panel_client.start_panel(panel_id, panel_script_path)
40+
python_path = str(Path(sys.executable).resolve())
41+
self._panel_url = self._panel_client.start_panel(panel_id, panel_script_path, python_path)
3942

4043
@property
4144
def panel_script_path(self) -> str:

src/nipanel/_panel_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,19 @@ def __init__(
5959
self._grpc_channel = grpc_channel
6060
self._stub: PythonPanelServiceStub | None = None
6161

62-
def start_panel(self, panel_id: str, panel_script_path: str) -> str:
62+
def start_panel(self, panel_id: str, panel_script_path: str, python_path: str) -> str:
6363
"""Start the panel.
6464
6565
Args:
6666
panel_id: The ID of the panel to start.
6767
panel_script_path: The path of the panel script file.
68+
python_path: The path to the Python executable.
6869
6970
Returns:
7071
The URL of the panel.
7172
"""
7273
start_panel_request = StartPanelRequest(
73-
panel_id=panel_id, panel_script_path=panel_script_path
74+
panel_id=panel_id, panel_script_path=panel_script_path, python_path=python_path
7475
)
7576
response = self._invoke_with_retry(self._get_stub().StartPanel, start_panel_request)
7677
return response.panel_url

0 commit comments

Comments
 (0)