From 1136b3a6c98e0cac60af6685deb90c8461d25ea0 Mon Sep 17 00:00:00 2001 From: Mike Prosser Date: Mon, 16 Jun 2025 08:39:37 -0500 Subject: [PATCH] followup comments --- .gitignore | 3 --- .vscode/launch.json | 26 ++++++++++++++++++++++++++ CONTRIBUTING.md | 23 +++++++++++++++++++---- poetry.lock | 2 +- pyproject.toml | 2 +- 5 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index 3f5686b..0a19790 100644 --- a/.gitignore +++ b/.gitignore @@ -172,6 +172,3 @@ cython_debug/ # PyPI configuration file .pypirc - -# VS Code settings -.vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9890a57 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Current File", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + // To use this configuration, add `debugpy.listen(("localhost", 5678))` to the script you wish to debug + "name": "Attach to Streamlit at localhost:5678", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 5678 + }, + "justMyCode": false + } + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 65480d7..d28ad97 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,11 @@ start docs\_build\index.html # Debugging on the streamlit side -Debugging the measurement script can be done using standard Python debugging techniques. However, debugging the Streamlit script—or any code invoked by the Streamlit script—is more complex because it runs in a separate process launched by the PythonPanelServer. To debug the Streamlit script, you can use debugpy to attach the Visual Studio Code debugger as follows: +Debugging the measurement script can be done using standard Python debugging +techniques. However, debugging the Streamlit script—or any code invoked by the +Streamlit script—is more complex because it runs in a separate process launched +by the PythonPanelServer. To debug the Streamlit script, you can use debugpy to +attach the Visual Studio Code debugger as follows: ## Instrument Streamlit script to debug @@ -73,9 +77,15 @@ except RuntimeError as e: raise ``` -The `debugpy.listen()` function opens a port that allows the debugger to attach to the running process. You can specify any available port, as long as it matches the port configured in the launch.json file shown below. Since calling listen() more than once will raise an exception, it is wrapped in a try block to prevent the script from crashing if it is rerun. +The `debugpy.listen()` function opens a port that allows the debugger to attach +to the running process. You can specify any available port, as long as it +matches the port configured in the launch.json file shown below. Since calling +listen() more than once will raise an exception, it is wrapped in a try block to +prevent the script from crashing if it is rerun. -The `debugpy.wait_for_client()` function pauses script execution until the debugger is attached. This is helpful if you need to debug initialization code, but you can omit this line if it is not required. +The `debugpy.wait_for_client()` function pauses script execution until the +debugger is attached. This is helpful if you need to debug initialization code, +but you can omit this line if it is not required. The `import debugpy` statement includes a type suppression comment to satisfy mypy. @@ -96,7 +106,12 @@ You will also need this configuration in your launch.json: } ``` -After running your measurement script and allowing the PythonPanelServer to launch Streamlit with your Streamlit script, you can attach the debugger by clicking the **Attach to Streamlit at localhost:5678** button in the VS Code **Run and Debug** tab. Once attached, you can set breakpoints and use all standard debugging features in your Streamlit script, as well as in any nipanel code invoked by the Streamlit script. +After running your measurement script and allowing the PythonPanelServer to +launch Streamlit with your Streamlit script, you can attach the debugger by +clicking the **Attach to Streamlit at localhost:5678** button in the VS Code +**Run and Debug** tab. Once attached, you can set breakpoints and use all +standard debugging features in your Streamlit script, as well as in any nipanel +code invoked by the Streamlit script. # Developer Certificate of Origin (DCO) diff --git a/poetry.lock b/poetry.lock index 1ef4a25..4aff7f7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2822,4 +2822,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0,!=3.9.7" -content-hash = "d57820becd3c1e2de9916ffab6a31e3ff80f1763e0451822edb9b6a2fc18aeeb" +content-hash = "b5a867eac14c2241ae4e15f741ddbc388fb60c5bf11483bdb6c869f7d59816de" diff --git a/pyproject.toml b/pyproject.toml index 74ba01d..5bc8033 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ ni-measurement-plugin-sdk = {version=">=2.3"} typing-extensions = ">=4.13.2" streamlit = ">=1.24" nitypes = {version=">=0.1.0dev1", allow-prereleases=true} -debugpy = "^1.8.1" +debugpy = ">=1.8.1" [tool.poetry.group.dev.dependencies] types-grpcio = ">=1.0"