- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Input improvements #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input improvements #106
Conversation
| Test Results   10 files  ±  0     10 suites  ±0   21s ⏱️ +2s Results for commit c7318d6. ± Comparison against base commit 2f3724a. This pull request removes 10 and adds 36 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. | 
- Added MyIntableFlags and MyIntableEnum classes to define new enum types. - Updated all_types_with_values to include new enum types. - Modified PanelValueAccessor to allow list values without type matching. - Improved test coverage for enum types in StreamlitPanel.
…iguration in Streamlit panel
There was a problem hiding this 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 enhances the panel value API to indicate when values are missing, updates clients and tests for this new behavior, and adds first-class support for Enum and Flag controls in Streamlit panels.
- Introduce a foundfield in GetValue RPC, updatePanelClient.get_valueto return(found, value), and adaptStreamlitPanelValueAccessor.get_valueto raiseKeyErroror coerce enums.
- Extend tests: update the fake servicer, adjust existing exception tests, and add extensive coverage for enum and flag value handling.
- Add two new Streamlit controls (enum_selectbox,flag_checkboxes), auto-sync session state in panel initializer, and update example scripts to use these controls.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description | 
|---|---|
| tests/utils/_fake_python_panel_servicer.py | Return GetValueResponse(found=...)instead of aborting | 
| tests/unit/test_streamlit_panel.py | Adjust exception types, add new tests for enum/flag paths | 
| tests/unit/test_panel_client.py | Update get_valuetests to expect(found, value)tuple | 
| tests/types.py | Add new Flag/Enumtypes to cover expanded support | 
| src/nipanel/_panel_client.py | Change get_valueto return(bool, object) | 
| src/nipanel/_panel_value_accessor.py | Handle (found, value)tuple and enum coercion | 
| src/nipanel/_convert.py | Add is_supported_typehelper | 
| src/ni/pythonpanel/v1/python_panel_service_pb2* | Add foundfield in protobuf definitions and stubs | 
| src/nipanel/_streamlit_panel_initializer.py | Auto-sync session state values into the panel | 
| src/nipanel/controls/_flag_checkboxes.py | New control for selecting Flagenums via checkboxes | 
| src/nipanel/controls/_enum_selectbox.py | New control for selecting Enumvalues via a selectbox | 
| examples/nidaqmx/nidaqmx_continuous_analog_input_panel.py | Use new controls, session-state sync, layout tweaks | 
| examples/nidaqmx/nidaqmx_continuous_analog_input.py | Drive panel values for DAQmx task configuration | 
| examples/all_types/define_types.py & all_types_panel.py | Update example to showcase all supported types | 
Comments suppressed due to low confidence (3)
tests/unit/test_streamlit_panel.py:300
- This docstring is outdated: the test now covers enum types. Update it to reflect that this test validates enum behavior.
    """Test that set_value() and get_value() work for builtin scalar types."""
tests/types.py:72
- StrEnum is not imported in this file, causing a NameError. Add from enum import StrEnumor qualify asenum.StrEnum.
class MyStringableEnum(StrEnum):
examples/nidaqmx/nidaqmx_continuous_analog_input_panel.py:55
- The st.containerAPI does not support aborderparameter. Removeborder=Trueor apply supported Streamlit styling instead.
    with st.container(border=True):
What does this Pull Request accomplish?
This PR upgrades how inputs work for streamlit pages.
st.session_stateso that users don't have to callpanel.set_value()for input controls likest.number_inputandst.text_input(as long as they provide a key).ni.enum_selectboxthat turns any Enum into a dropdown, and handlespanel.set_value()ni.flag_checkboxesthat turns any Flags into a set of checkboxes, and handlespanel.set_value()all_typesexample has been updated to show input controls for supported types, and better show output values for enums and flags.nidaqmx_continuous_analog_inputexample has been updated so all of the controls are actually functional (except the I/O channel selectors), and to make the layout look more like the LabVIEW version of the example. It also now has a run/stop button, since you have to restart the task to use different settings.Why should this Pull Request be merged?
We want inputs to be as user-friendly as possible.
Finalizes AB#3127262 and fixes AB#3180627
What testing has been done?
Autotests in
test_panel_client,test_streamlit_panel, andtest_streamlit_panel_accessor.Manual testing with the
all_typesexample and thenidaqmx_continuous_analog_inputexample.