Skip to content

Commit 0460d77

Browse files
author
Dilmi Wickramanayake
committed
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input
2 parents 1bfa9ad + 6d2ec85 commit 0460d77

26 files changed

+1036
-217
lines changed

.github/workflows/check_docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Check out repo
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1414
- name: Set up Python
15-
uses: ni/python-actions/setup-python@97860b52be87c788fb6df812bd8d1ca68c7aa885 # v0.3.0
15+
uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
1616
id: setup-python
1717
- name: Set up Poetry
18-
uses: ni/python-actions/setup-poetry@97860b52be87c788fb6df812bd8d1ca68c7aa885 # v0.3.0
18+
uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
1919
- name: Check for lock changes
2020
run: poetry check --lock
2121
- name: Cache virtualenv (with docs)

.github/workflows/check_nipanel.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Check out repo
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1414
- name: Set up Python
15-
uses: ni/python-actions/setup-python@97860b52be87c788fb6df812bd8d1ca68c7aa885 # v0.3.0
15+
uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
1616
id: setup-python
1717
- name: Set up Poetry
18-
uses: ni/python-actions/setup-poetry@97860b52be87c788fb6df812bd8d1ca68c7aa885 # v0.3.0
18+
uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
1919
- name: Check for lock changes
2020
run: poetry check --lock
2121
- name: Cache virtualenv
@@ -33,3 +33,15 @@ jobs:
3333
run: poetry run mypy --platform win32
3434
- name: Bandit security checks
3535
run: poetry run bandit -c pyproject.toml -r src/nipanel
36+
- name: Add virtualenv to the path for pyright-action
37+
run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
38+
- name: Pyright static analysis (Linux)
39+
uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
40+
with:
41+
python-platform: Linux
42+
version: PATH
43+
- name: Pyright static analysis (Windows)
44+
uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2
45+
with:
46+
python-platform: Windows
47+
version: PATH

.github/workflows/run_unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
- name: Check out repo
2020
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121
- name: Set up Python
22-
uses: ni/python-actions/setup-python@97860b52be87c788fb6df812bd8d1ca68c7aa885 # v0.3.0
22+
uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
2323
id: setup-python
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Set up Poetry
27-
uses: ni/python-actions/setup-poetry@97860b52be87c788fb6df812bd8d1ca68c7aa885 # v0.3.0
27+
uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
2828
- name: Cache virtualenv
2929
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3030
with:

.vscode/launch.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: Current File",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
},
14+
{
15+
// To use this configuration, add `debugpy.listen(("localhost", 5678))` to the script you wish to debug
16+
"name": "Attach to Streamlit at localhost:5678",
17+
"type": "debugpy",
18+
"request": "attach",
19+
"connect": {
20+
"host": "localhost",
21+
"port": 5678
22+
},
23+
"justMyCode": false
24+
}
25+
]
26+
}

CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,65 @@ poetry run sphinx-build docs docs/_build --builder html --fail-on-warning
5454
start docs\_build\index.html
5555
```
5656

57+
# Debugging on the streamlit side
58+
59+
Debugging the measurement script can be done using standard Python debugging
60+
techniques. However, debugging the Streamlit script—or any code invoked by the
61+
Streamlit script—is more complex because it runs in a separate process launched
62+
by the PythonPanelServer. To debug the Streamlit script, you can use debugpy to
63+
attach the Visual Studio Code debugger as follows:
64+
65+
## Instrument Streamlit script to debug
66+
67+
To enable debugpy debugging, include this code in your streamlit script:
68+
69+
```python
70+
import debugpy # type: ignore
71+
72+
try:
73+
debugpy.listen(("localhost", 5678))
74+
debugpy.wait_for_client()
75+
except RuntimeError as e:
76+
if "debugpy.listen() has already been called on this process" not in str(e):
77+
raise
78+
```
79+
80+
The `debugpy.listen()` function opens a port that allows the debugger to attach
81+
to the running process. You can specify any available port, as long as it
82+
matches the port configured in the launch.json file shown below. Since calling
83+
listen() more than once will raise an exception, it is wrapped in a try block to
84+
prevent the script from crashing if it is rerun.
85+
86+
The `debugpy.wait_for_client()` function pauses script execution until the
87+
debugger is attached. This is helpful if you need to debug initialization code,
88+
but you can omit this line if it is not required.
89+
90+
The `import debugpy` statement includes a type suppression comment to satisfy mypy.
91+
92+
## Add debugpy configuration in launch.json
93+
94+
You will also need this configuration in your launch.json:
95+
96+
```json
97+
{
98+
"name": "Attach to Streamlit at localhost:5678",
99+
"type": "debugpy",
100+
"request": "attach",
101+
"connect": {
102+
"host": "localhost",
103+
"port": 5678
104+
},
105+
"justMyCode": false
106+
}
107+
```
108+
109+
After running your measurement script and allowing the PythonPanelServer to
110+
launch Streamlit with your Streamlit script, you can attach the debugger by
111+
clicking the **Attach to Streamlit at localhost:5678** button in the VS Code
112+
**Run and Debug** tab. Once attached, you can set breakpoints and use all
113+
standard debugging features in your Streamlit script, as well as in any nipanel
114+
code invoked by the Streamlit script.
115+
57116
# Developer Certificate of Origin (DCO)
58117

59118
Developer's Certificate of Origin 1.1

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ def setup(sphinx):
7373
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
7474

7575

76-
# TODO: AB#3120159 - Update nipanel intersphinx mapping for nitypes
7776
intersphinx_mapping = {
7877
"grpc": ("https://grpc.github.io/grpc/python/", None),
7978
"measurement-plugin-python": (
8079
"https://measurement-plugin-python.readthedocs.io/en/latest/",
8180
None,
8281
),
82+
"nitypes": ("https://nitypes.readthedocs.io/en/latest/", None),
8383
"numpy": ("https://numpy.org/doc/stable/", None),
8484
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
8585
"python": ("https://docs.python.org/3", None),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Prerequisites
2+
===============
3+
In order to use the **nidaqmx** package, you must have at least one DAQ
4+
device installed on your system. Both physical and simulated devices are supported. The
5+
examples below use an X Series DAQ device of PCIe-6320 You can use **NI MAX** or **NI Hardware Configuration Utility** to
6+
verify and configure your devices.
7+
8+
Finding and configuring device name in **NI MAX**:
9+
10+
![alt text](image.png)
11+
12+
Finding and configuring device name in NI Hardware Configuration Utility:
13+
14+
![alt text](image-1.png)
15+
16+
Snippet is from: https://github.com/ni/nidaqmx-python/blob/master/README.rst Getting Started Section
81.7 KB
Loading
146 KB
Loading

examples/nidaqmx_continuous_analog_input/nidaqmx_continuous_analog_input.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import nidaqmx
66
from nidaqmx.constants import AcquisitionType
77

8-
98
import nipanel
109

1110
script_path = pathlib.Path(__file__)
@@ -18,13 +17,12 @@
1817
)
1918

2019
with nidaqmx.Task() as task:
21-
# User needs simulated hardware to run script, and user should use NI MAX to setup cDAQ1 Model NI 9201
22-
task.ai_channels.add_ai_voltage_chan("Mod1/ai2")
23-
task.ai_channels.add_ai_thrmcpl_chan("Mod1/ai3")
20+
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
21+
task.ai_channels.add_ai_thrmcpl_chan("Dev1/ai1")
2422
task.timing.cfg_samp_clk_timing(
25-
rate=1000.0, # Sample rate in Hz
23+
rate=1000.0,
2624
sample_mode=AcquisitionType.CONTINUOUS,
27-
samps_per_chan=3000 # Buffer size per channel
25+
samps_per_chan=3000
2826
)
2927
task.start()
3028
try:

0 commit comments

Comments
 (0)