|
1 | 1 | # GitHub Copilot Instructions for Space Packet Parser |
2 | 2 |
|
3 | | -## Project Overview |
4 | | - |
5 | | -Space Packet Parser is a Python library for decoding CCSDS (Consultative Committee for Space Data Systems) telemetry packets according to XTCE (XML Telemetric and Command Exchange) packet structure definitions. The library is based on the UML model of the XTCE specification and aims to support all but the most esoteric elements of the XTCE telemetry packet specification. |
6 | | - |
7 | | -### Key Concepts |
8 | | - |
9 | | -- **CCSDS**: Space data systems standard for space communications |
10 | | -- **XTCE**: XML-based format for describing telemetry and command data structures |
11 | | -- **Telemetry Packets**: Binary data packets from spacecraft/instruments that need to be parsed and decoded |
12 | | - |
13 | | -## Technical Requirements |
14 | | - |
15 | | -### Python Version |
16 | | - |
17 | | -- **Minimum**: Python 3.9+ |
18 | | -- **Tested on**: Python 3.9, 3.10, 3.11, 3.12, 3.13 |
19 | | - |
20 | | -### Core Dependencies |
21 | | - |
22 | | -- `lxml>=4.8.0` - XML parsing for XTCE definitions |
23 | | -- `click>=8.0` - CLI framework |
24 | | -- `rich>=13.0` - Terminal formatting and output |
25 | | -- `xarray` (optional) - Multi-dimensional data arrays |
26 | | -- `numpy` (optional) - Numerical computing |
27 | | - |
28 | | -## Development Setup |
29 | | - |
30 | | -### Installation |
31 | | - |
32 | | -```bash |
33 | | -# Install with development dependencies using pip |
34 | | -pip install ".[test,xarray]" |
35 | | - |
36 | | -# For development with uv (creates and manages virtual environment) |
37 | | -uv sync --all-extras |
38 | | -``` |
39 | | - |
40 | | -### Pre-commit Hooks |
41 | | - |
42 | | -The project uses pre-commit hooks for code quality. Install them with: |
43 | | - |
44 | | -```bash |
45 | | -pre-commit install |
46 | | -``` |
47 | | - |
48 | | -The hooks include: |
49 | | - |
50 | | -- `ruff` for linting and code formatting |
51 | | -- `prettier` for YAML, JSON, and Markdown formatting |
52 | | -- `codespell` for spell checking |
53 | | -- Security checks (AWS credentials, private keys) |
54 | | -- Metadata validation |
55 | | - |
56 | | -## Code Style and Linting |
57 | | - |
58 | | -### Ruff Configuration |
59 | | - |
60 | | -- **Line length**: 120 characters |
61 | | -- **Formatter**: ruff format (follows Black-compatible style) |
62 | | -- **Linter**: Enabled rules include: |
63 | | - - E/W (pycodestyle errors and warnings) |
64 | | - - F (pyflakes) |
65 | | - - I (isort import sorting) |
66 | | - - S (flake8-bandit security) |
67 | | - - PT (flake8-pytest-style) |
68 | | - - UP (pyupgrade syntax upgrader) |
69 | | - |
70 | | -### Running Linters |
71 | | - |
72 | | -```bash |
73 | | -# Format code |
74 | | -ruff format |
75 | | - |
76 | | -# Check and fix linting issues |
77 | | -ruff check --fix |
78 | | - |
79 | | -# Run all pre-commit hooks |
80 | | -pre-commit run --all-files |
81 | | -``` |
82 | | - |
83 | | -## Testing |
84 | | - |
85 | | -### Running Tests |
86 | | - |
87 | | -```bash |
88 | | -# Run all tests with coverage |
89 | | -pytest --color=yes --cov --cov-report=xml |
90 | | - |
91 | | -# Run specific test module |
92 | | -pytest tests/unit/test_xtce/ |
93 | | - |
94 | | -# Run with verbose output |
95 | | -pytest -v |
96 | | -``` |
97 | | - |
98 | | -### Test Structure |
99 | | - |
100 | | -- `tests/unit/` - Unit tests for individual components |
101 | | -- `tests/integration/` - Integration tests for end-to-end scenarios |
102 | | -- `tests/benchmark/` - Performance benchmarks |
103 | | -- `conftest.py` - Shared test fixtures and configuration |
104 | | - |
105 | | -### Test Conventions |
106 | | - |
107 | | -- Use pytest fixtures defined in `conftest.py` |
108 | | -- Test data is stored in `tests/test_data/` |
109 | | -- Use pytest parametrize for testing multiple scenarios |
110 | | -- Security checks (S-prefixed rules) are disabled in test files |
111 | | - |
112 | | -## Project Structure |
113 | | - |
114 | | -### Main Package: `space_packet_parser/` |
115 | | - |
116 | | -- `__init__.py` - Public API exports (`load_xtce`, `ccsds_generator`, etc.) |
117 | | -- `cli.py` - Command-line interface using Click |
118 | | -- `common.py` - Common data structures (SpacePacket, etc.) |
119 | | -- `definitions.py` - Core definitions and base classes |
120 | | -- `exceptions.py` - Custom exception classes |
121 | | -- `packets.py` - Packet parsing and handling logic |
122 | | -- `xtce/` - XTCE parsing and validation |
123 | | - - `definitions.py` - XTCE packet definitions |
124 | | - - `validation.py` - XTCE schema validation |
125 | | -- `generators/` - Binary data generators and readers |
126 | | -- `xarr.py` - XArray integration (optional feature) |
127 | | - |
128 | | -### Examples |
129 | | - |
130 | | -Example usage scripts are in `examples/` directory. |
131 | | - |
132 | | -### Documentation |
133 | | - |
134 | | -- Built with Sphinx |
135 | | -- Uses MyST Parser for Markdown support |
136 | | -- Hosted on ReadTheDocs: https://space-packet-parser.readthedocs.io |
137 | | -- Source files in `docs/source/` |
138 | | - |
139 | | -## CLI Tool |
140 | | - |
141 | | -The package provides a command-line tool: |
142 | | - |
143 | | -```bash |
144 | | -spp <command> [options] |
145 | | -``` |
146 | | - |
147 | | -Entry point defined in `space_packet_parser.cli:spp` |
148 | | - |
149 | | -## Making Changes |
150 | | - |
151 | | -### Before Submitting a PR |
152 | | - |
153 | | -1. Ensure all tests pass: `pytest` |
154 | | -2. Run linters: `pre-commit run --all-files` |
155 | | -3. Update tests for new functionality |
156 | | -4. Update `docs/source/changelog.md` with your changes |
157 | | -5. Ensure dependencies in `pyproject.toml` are current |
158 | | - |
159 | | -### PR Checklist (from template) |
160 | | - |
161 | | -- [ ] Changes are fully implemented without dangling issues or TODO items |
162 | | -- [ ] Deprecated/superseded code is removed or marked with deprecation warning |
163 | | -- [ ] Current dependencies have been properly specified and old dependencies removed |
164 | | -- [ ] New code/functionality has accompanying tests and any old tests have been updated |
165 | | -- [ ] The changelog.md has been updated |
166 | | - |
167 | | -## Code Review |
168 | | - |
169 | | -- Code changes will be reviewed by @medley56 (see CODEOWNERS) |
170 | | -- Follow the project's Code of Conduct |
171 | | - |
172 | | -## CI/CD |
173 | | - |
174 | | -### GitHub Actions Workflows |
175 | | - |
176 | | -- `tests.yml` - Runs tests on Windows, Ubuntu, and macOS across Python 3.9-3.13 |
177 | | -- `test_examples.yml` - Validates example scripts |
178 | | -- `release.yml` - Handles package releases |
179 | | - |
180 | | -### Coverage |
181 | | - |
182 | | -- Code coverage reports are uploaded to Codecov |
183 | | -- Target: Maintain high test coverage for critical components |
184 | | - |
185 | | -## Common Tasks |
186 | | - |
187 | | -### Adding a New Parameter Type |
188 | | - |
189 | | -1. Define the parameter type class in `space_packet_parser/xtce/` |
190 | | -2. Add parsing logic to handle the XTCE element |
191 | | -3. Add unit tests in `tests/unit/test_xtce/test_parameters.py` |
192 | | -4. Add integration test with a real XTCE file if applicable |
193 | | -5. Update documentation |
194 | | - |
195 | | -### Adding a New CLI Command |
196 | | - |
197 | | -1. Add command function to `space_packet_parser/cli.py` |
198 | | -2. Use Click decorators for arguments/options |
199 | | -3. Use Rich for formatted terminal output |
200 | | -4. Add tests in `tests/unit/test_cli/` (if test directory exists) |
201 | | - |
202 | | -### Updating XTCE Validation |
203 | | - |
204 | | -1. Modify validation logic in `space_packet_parser/xtce/validation.py` |
205 | | -2. Update schema files if needed |
206 | | -3. Add test cases for the validation scenario |
207 | | -4. Ensure backward compatibility with existing XTCE files |
208 | | - |
209 | | -## Important Notes |
210 | | - |
211 | | -- The library focuses on **telemetry parsing only** (not command generation) |
212 | | -- Binary data parsing is performance-critical - consider efficiency |
213 | | -- XTCE files can be very large - optimize for memory efficiency |
214 | | -- Support for edge cases in XTCE spec is important for mission use |
215 | | -- This is production code used by real space missions (IMAP, CLARREO, Libera, CTIM-FD, MMS) |
216 | | - |
217 | | -## Resources |
218 | | - |
219 | | -- [XTCE Green Book (Informational Report)](https://public.ccsds.org/Pubs/660x2g2.pdf) |
220 | | -- [XTCE Element Description (Green Book)](https://public.ccsds.org/Pubs/660x1g2.pdf) |
221 | | -- [XTCE Blue Book (Recommended Standard)](https://public.ccsds.org/Pubs/660x0b2.pdf) |
222 | | -- [Project Documentation](https://space-packet-parser.readthedocs.io) |
223 | | -- [PyHC (Python in Heliophysics Community)](https://heliopython.org) |
| 3 | +This is the Space Packet Parser repository. Detailed instructions for coding rules, patterns, and testing are in |
| 4 | +[`instructions/space_packet_parser.instructions.md`](instructions/space_packet_parser.instructions.md). |
| 5 | +Please refer to that file for the most up-to-date and comprehensive guidelines on contributing to this project. |
0 commit comments