Skip to content

Conversation

@mikeprosserni
Copy link
Collaborator

@mikeprosserni mikeprosserni commented Jun 26, 2025

What does this Pull Request accomplish?

We need to send the measurement script's python environment to the PythonPanelServer, so that it can reuse it for the Streamlit script as well. See the ASW PR for the full explanation.

On the python side here, we need to:

  • Update python_panel_service.proto to include python_path in the StartPanelRequest
  • Use str(Path(sys.executable).resolve()) to get the python_path in Panel.__init__
  • Pass the python_path through PanelClient.start_panel()

Additional Changes:

  • Tweaked the pyproject.toml to remove streamlit-echarts as a required dependency (it's only needed for examples), and fix an issue I was getting with numpy when running poetry lock
  • Updated CONTRIBUTING.md with new instructions
  • Made some tweaks in the nidaqmx example
  • In all the examples, I moved panel = nipanel.get_panel_accessor() below st.set_page_config(), because in older versions of streamlit, set_page_config needs to be the first thing in the script (and get_panel_accessor adds the refresh component)

Why should this Pull Request be merged?

Addresses AB#3171565

What testing has been done?

See ASW PR for description and animations of testing

@github-actions
Copy link
Contributor

github-actions bot commented Jun 26, 2025

Test Results

   10 files  ± 0     10 suites  ±0   18s ⏱️ ±0s
  190 tests + 1    190 ✅ + 1  0 💤 ±0  0 ❌ ±0 
1 850 runs  +10  1 850 ✅ +10  0 💤 ±0  0 ❌ ±0 

Results for commit a62eb88. ± Comparison against base commit 1727616.

♻️ This comment has been updated with latest results.

@mikeprosserni mikeprosserni marked this pull request as ready for review June 27, 2025 15:11
@mikeprosserni mikeprosserni requested a review from csjall as a code owner June 27, 2025 15:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures the Streamlit panel uses the same Python interpreter as the measurement script by adding a python_path field throughout the service stack, cleans up dependencies and example scripts, and updates documentation.

  • Propagate python_path from Panel initializer through PanelClient to the gRPC service
  • Extend protobuf definitions and regenerate serialized descriptors
  • Refine dependencies, example scripts, and contributing instructions

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/test_panel_client.py Updated tests to pass python_path to start_panel
src/nipanel/_panel_client.py Extended start_panel signature to include python_path
src/nipanel/_panel.py Resolve and pass sys.executable path into start_panel
src/ni/pythonpanel/v1/python_panel_service_pb2.pyi Added python_path field to the StartPanelRequest stub interface
src/ni/pythonpanel/v1/python_panel_service_pb2.py Updated serialized descriptor ranges to accommodate python_path
pyproject.toml Removed streamlit-echarts from main deps; adjusted numpy constraints
protos/ni/pythonpanel/v1/python_panel_service.proto Added python_path field to StartPanelRequest message
examples/simple_graph/simple_graph_panel.py Moved get_panel_accessor after set_page_config
examples/nidaqmx/nidaqmx_continuous_analog_input_panel.py Adjusted sample_rate default, added st_echarts key
examples/nidaqmx/nidaqmx_continuous_analog_input.py Added panel URL printout; formatted task.read call
examples/hello/hello_panel.py Moved get_panel_accessor after set_page_config
examples/all_types/all_types_panel.py Moved get_panel_accessor after set_page_config
CONTRIBUTING.md Updated example setup and run instructions
Comments suppressed due to low confidence (3)

src/nipanel/_panel_client.py:62

  • The new required python_path parameter is a breaking change for existing callers; consider making it optional (e.g., with a default value or keyword-only) to maintain backward compatibility.
    def start_panel(self, panel_id: str, panel_script_path: str, python_path: str) -> str:

tests/unit/test_panel_client.py:16

  • Tests invoke start_panel with python_path but do not assert that the stub request actually received the expected python_path; add a test to verify the request payload includes the correct interpreter path.
    client.start_panel("panel1", "uri1", "python.exe")

pyproject.toml:15

  • The examples still use st_echarts but its dependency was removed from main deps; consider adding streamlit-echarts to an examples or dev dependency group so example scripts run out of the box.
streamlit = ">=1.24"

@mikeprosserni mikeprosserni merged commit 2b1d60d into main Jun 27, 2025
14 checks passed
@mikeprosserni mikeprosserni deleted the users/mprosser/td-3171565-venv-woes branch June 27, 2025 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants