Skip to content

Commit 59ac9d9

Browse files
Mike ProsserMike Prosser
authored andcommitted
fix mypy issues and move streamlit-echarts to examples dependancy group
1 parent 9526a40 commit 59ac9d9

File tree

7 files changed

+22
-6
lines changed

7 files changed

+22
-6
lines changed

CONTRIBUTING.md

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

57+
## Running examples
58+
59+
1. First, run the PythonPanelService (not part of this repo, provided seperately)
60+
2. Run the command `poetry run python examples/sample/sample.py`
61+
3. Open http://localhost:42001/panel-service/panels/sample_panel/ in your browser
62+
4. If there is an error about missing imports (especially nipanel), execute this
63+
command to install the dependencies into the venv: `C:\Users\mprosser\AppData\Local\Temp\python_panel_service_venv\Scripts\python.exe
64+
-m pip install C:\dev\fireserp\nipanel-python[examples,dev]`, then restart the PythonPanelService and re-run sample.py.
65+
66+
You can see all running panels (and stop them) at: http://localhost:42001/panel-service/
67+
5768
# Debugging on the streamlit side
5869

5970
Debugging the measurement script can be done using standard Python debugging

examples/all_types/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ This is an example for `nipanel` that demonstrates all supported data types
1212

1313
### Usage
1414

15-
Run `poetry run examples/all_types/all_types.py`
15+
Run `poetry run python examples/all_types/all_types.py`

examples/sample/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ This is a nipanel example that displays an interactive Streamlit app and updates
1212

1313
### Usage
1414

15-
Run `poetry run examples/sample/sample.py`
15+
Run `poetry run python examples/sample/sample.py`

examples/simple_graph/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ This example demonstrates using nipanel with Streamlit to display a dynamic sine
1515

1616
### Usage
1717

18-
Run `poetry run examples/simple_graph/simple_graph.py`
18+
Run `poetry run python examples/simple_graph/simple_graph.py`

examples/simple_graph/simple_graph_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Example of displaying a sine wave using streamlit-echarts in a nipanel."""
22

33
import streamlit as st
4-
from streamlit_echarts import st_echarts
4+
from streamlit_echarts import st_echarts # type: ignore
55

66
from nipanel import initialize_panel
77

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ protobuf = {version=">=4.21"}
1313
ni-measurement-plugin-sdk = {version=">=2.3"}
1414
typing-extensions = ">=4.13.2"
1515
streamlit = ">=1.24"
16-
streamlit-echarts = ">=0.4.0"
1716
nitypes = {version=">=0.1.0dev2", allow-prereleases=true}
1817
debugpy = ">=1.8.1"
1918

@@ -53,6 +52,12 @@ sphinx-autoapi = ">=1.8.4"
5352
m2r2 = ">=0.3.2"
5453
toml = ">=0.10.2"
5554

55+
[tool.poetry.group.examples]
56+
optional = true
57+
58+
[tool.poetry.group.examples.dependencies]
59+
streamlit-echarts = ">=0.4.0"
60+
5661
[build-system]
5762
requires = ["poetry-core>=1.8.0"]
5863
build-backend = "poetry.core.masonry.api"

src/nipanel/converters/protobuf_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _value_to_attribute(self, value: ExtendedPropertyValue) -> WaveformAttribute
100100
def to_python_value(self, protobuf_message: DoubleAnalogWaveform) -> AnalogWaveform[np.float64]:
101101
"""Convert the protobuf DoubleAnalogWaveform to a Python AnalogWaveform."""
102102
# Declare timing to accept both bintime and dt.datetime to satisfy mypy.
103-
timing: Timing[bt.DateTime | dt.datetime]
103+
timing: Timing[Union[bt.DateTime, dt.datetime]]
104104
if not protobuf_message.dt and not protobuf_message.HasField("t0"):
105105
# If both dt and t0 are unset, use Timing.empty.
106106
timing = Timing.empty

0 commit comments

Comments
 (0)