Skip to content

Commit dd37b77

Browse files
mikeprossernirenovate[bot]Mike Prosser
authored
Add Copilot Instructions (#168)
* chore(deps): update dependency streamlit to v1.50.0 * add some copilot instructions * add some copilot instructions --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mike Prosser <Mike.Prosser@emerson.com>
1 parent 5d3bcab commit dd37b77

File tree

1 file changed

+180
-0
lines changed

1 file changed

+180
-0
lines changed

.github/copilot-instructions.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Copilot Instructions for nipanel-python
2+
3+
## Repository Overview
4+
5+
**nipanel** is a Python package that provides support for creating and controlling measurement and visualization panels. It's developed by NI and enables Python applications to create Streamlit-based panels that can be served and controlled via gRPC services.
6+
7+
### Key Repository Information
8+
- **Language**: Python (3.9+)
9+
- **Package Manager**: Poetry 2.1+
10+
- **Framework**: Uses Streamlit for panel UI, gRPC for communication
11+
- **Size**: Medium-sized repository (~1300 lines of code in src/)
12+
- **Architecture**: Client-server model with Python panel service and Streamlit frontend
13+
- **Testing**: Comprehensive test suite with unit, integration, and acceptance tests
14+
15+
## Build and Validation Commands
16+
17+
**CRITICAL**: Always run commands in this exact order for successful builds and validation.
18+
19+
### Environment Setup
20+
```powershell
21+
# 1. Verify Poetry is installed (required version 2.1+)
22+
poetry --version
23+
24+
# 2. Install project dependencies (ALWAYS run first)
25+
poetry install
26+
27+
# 3. For examples and development work
28+
poetry install --with examples
29+
30+
# 4. For documentation work
31+
poetry install --with docs
32+
```
33+
34+
### Development Workflow Commands
35+
Follow this sequence when making changes:
36+
37+
```powershell
38+
# 1. Run linting (shows warnings but continues)
39+
poetry run nps lint
40+
41+
# 2. Apply automatic formatting fixes
42+
poetry run nps fix
43+
44+
# 3. Run static type checking (must pass)
45+
poetry run mypy
46+
47+
# 4. Run security analysis (must pass)
48+
poetry run bandit -c pyproject.toml -r src/nipanel
49+
50+
# 5. Run all tests (must pass)
51+
poetry run pytest -v
52+
53+
# 6. Run only unit tests (faster feedback)
54+
poetry run pytest ./tests/unit -v
55+
56+
# 7. Run tests with coverage
57+
poetry run pytest ./tests/unit -v --cov=nipanel
58+
```
59+
60+
### Documentation Build
61+
```powershell
62+
# Build documentation (may fail due to external SSL cert issues - this is expected)
63+
poetry run sphinx-build docs docs/_build --builder html --fail-on-warning
64+
```
65+
66+
### Runtime Requirements
67+
- **Python**: 3.9+ (excludes 3.9.7 due to Streamlit incompatibility)
68+
- **Poetry**: 2.1+ required for build system
69+
- **Virtual Environment**: Configured in-project (`.venv/` directory)
70+
71+
## Project Layout and Architecture
72+
73+
### Source Code Structure
74+
```
75+
src/nipanel/ # Main package directory
76+
├── __init__.py # Public API exports
77+
├── _streamlit_panel.py # Core StreamlitPanel class
78+
├── _panel_client.py # gRPC client for panel communication
79+
├── _panel_value_accessor.py # Value management for panels
80+
├── _streamlit_panel_initializer.py # Panel creation utilities
81+
├── _convert.py # Type conversion utilities
82+
├── controls/ # Streamlit UI control components
83+
├── converters/ # Type conversion modules
84+
├── panel_refresh/ # Panel refresh functionality
85+
└── streamlit_refresh/ # Streamlit-specific refresh logic
86+
```
87+
88+
### Configuration Files
89+
- **pyproject.toml**: Main project configuration, dependencies, tool settings
90+
- **poetry.toml**: Poetry configuration (sets `in-project = true` for venv)
91+
- **.github/workflows/**: Complete CI/CD pipeline
92+
93+
### Test Structure
94+
```
95+
tests/
96+
├── unit/ # Unit tests (primary test suite)
97+
├── integration/ # Integration tests
98+
├── acceptance/ # End-to-end acceptance tests
99+
├── utils/ # Test utilities and fakes
100+
└── conftest.py # Pytest configuration and fixtures
101+
```
102+
103+
### Examples
104+
```
105+
examples/
106+
├── hello/ # Basic panel example
107+
├── all_types/ # Demonstrates all supported data types
108+
├── simple_graph/ # Graph visualization example
109+
├── nidaqmx/ # Hardware integration examples
110+
└── performance_checker/ # Performance monitoring example
111+
```
112+
113+
## CI/CD Pipeline
114+
115+
The repository uses a comprehensive GitHub Actions pipeline:
116+
117+
1. **check_nipanel.yml**: Runs on Windows, Ubuntu, macOS with Python 3.9, 3.13
118+
- Linting with `poetry run nps lint`
119+
- Type checking with `poetry run mypy`
120+
- Security scanning with `poetry run bandit -c pyproject.toml -r src/nipanel`
121+
122+
2. **run_unit_tests.yml**: Cross-platform testing (Windows, Ubuntu) with Python 3.9-3.13
123+
- Unit tests: `poetry run pytest ./tests/unit -v --cov=nipanel --junitxml=test_results/nipanel-{os}-py{version}.xml`
124+
125+
3. **check_docs.yml**: Documentation validation
126+
- Lock file verification: `poetry check --lock`
127+
- Documentation build: `poetry run sphinx-build docs docs/_build -b html -W`
128+
129+
### Key Dependencies
130+
- **Core Runtime**: grpcio, protobuf, streamlit, nitypes, numpy, debugpy
131+
- **NI Packages**: ni-grpc-extensions, ni-measurementlink-discovery-v1-client, ni-protobuf-types, ni-panels-v1-proto
132+
- **Development Tools**: ni-python-styleguide, mypy, bandit, pytest
133+
134+
## Architecture Overview
135+
136+
**nipanel** implements a client-server architecture:
137+
138+
1. **Python Application**: Uses nipanel API to create and control panels
139+
2. **Panel Service**: Separate gRPC service (PythonPanelService - external dependency)
140+
3. **Streamlit Frontend**: Web-based UI for the panels
141+
4. **Communication**: gRPC for Python ↔ Service, HTTP for Service ↔ Streamlit
142+
143+
### Core Classes
144+
- `StreamlitPanel`: Main panel interface
145+
- `PanelValueAccessor`: Manages panel state and values
146+
- `create_streamlit_panel()`: Factory function for panel creation
147+
148+
## Validation Steps
149+
150+
### Pre-commit Validation (replicate CI locally)
151+
```powershell
152+
# Complete validation sequence
153+
poetry install
154+
poetry run nps lint
155+
poetry run nps fix
156+
poetry run mypy
157+
poetry run bandit -c pyproject.toml -r src/nipanel
158+
poetry run pytest -v
159+
```
160+
161+
### Common Issues and Solutions
162+
163+
1. **Poetry Lock Issues**: Run `poetry check --lock` to verify lock file consistency
164+
2. **Import Warnings**: flake8_import_order pkg_resources warnings are expected and harmless
165+
3. **Documentation SSL Errors**: External inventory fetch failures are known issues
166+
4. **Python 3.9.7**: Excluded due to Streamlit incompatibility - use different Python 3.9.x version
167+
168+
### File System Requirements
169+
- Virtual environment created in `.venv/` (configured in poetry.toml)
170+
- Test results written to `test_results/` directory
171+
- Documentation built to `docs/_build/`
172+
173+
## Trust These Instructions
174+
175+
These instructions are comprehensive and tested. Only perform additional searches if:
176+
- Commands fail unexpectedly
177+
- You need to understand specific implementation details not covered here
178+
- You're working with files not mentioned in this overview
179+
180+
The build and test commands listed here are the authoritative source - they match exactly what the CI pipeline runs and have been validated to work correctly.

0 commit comments

Comments
 (0)