Skip to content

Commit 4856453

Browse files
committed
Add comprehensive documentation and fix Qiskit adapter
Documentation: - Complete README with use cases, CLI reference, and examples - docs/USE-CASES.md: 10 real-world scenarios (academic, compliance, debugging, etc.) - docs/INSTALLATION.md: Installation guide for all platforms - docs/USAGE.md: Complete usage guide with framework examples - docs/CLI.md: Full CLI reference for all commands - docs/API.md: Python API reference for all data models - docs/ADAPTERS.md: Framework adapter documentation - docs/WHY-QBOM.md: Background and motivation for non-technical stakeholders - CONTRIBUTING.md: Contribution guidelines Features: - Reproducibility scoring (score.py) - Calibration drift analysis (drift.py) - Trace validation (validation.py) - CycloneDX extension proposal - SPDX export format Bug fixes: - Fix Qiskit adapter to detect imports after qbom - Fix adapter re-installation for qiskit_aer - Fix provider detection for AerSimulator (shows "Aer (Local)") - Fix qbom.current() to return last finalized trace
1 parent 9435a1a commit 4856453

File tree

20 files changed

+5299
-281
lines changed

20 files changed

+5299
-281
lines changed

CONTRIBUTING.md

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
# Contributing to QBOM
2+
3+
Thank you for your interest in contributing to QBOM! This document provides guidelines and information for contributors.
4+
5+
## Code of Conduct
6+
7+
We are committed to providing a welcoming and inclusive environment. Please be respectful and constructive in all interactions.
8+
9+
## Getting Started
10+
11+
### Development Setup
12+
13+
```bash
14+
# Clone the repository
15+
git clone https://github.com/csnp/qbom.git
16+
cd qbom
17+
18+
# Create a virtual environment (recommended)
19+
python -m venv venv
20+
source venv/bin/activate # On Windows: venv\Scripts\activate
21+
22+
# Install in development mode with all dependencies
23+
pip install -e ".[dev,all]"
24+
```
25+
26+
### Running Tests
27+
28+
```bash
29+
# Run all tests
30+
pytest
31+
32+
# Run with coverage
33+
pytest --cov=src/qbom --cov-report=html
34+
35+
# Run specific test file
36+
pytest tests/test_models.py
37+
38+
# Run with verbose output
39+
pytest -v
40+
```
41+
42+
### Code Quality
43+
44+
```bash
45+
# Type checking
46+
mypy src/qbom
47+
48+
# Linting
49+
ruff check src/qbom
50+
51+
# Auto-fix linting issues
52+
ruff check src/qbom --fix
53+
54+
# Format code
55+
ruff format src/qbom
56+
```
57+
58+
## Project Structure
59+
60+
```
61+
qbom/
62+
├── src/qbom/
63+
│ ├── core/ # Framework-agnostic core
64+
│ │ ├── models.py # Pydantic data models
65+
│ │ ├── trace.py # Trace object and builder
66+
│ │ └── session.py # Session management
67+
│ ├── adapters/ # Framework-specific adapters
68+
│ │ ├── base.py # Base adapter class
69+
│ │ ├── qiskit.py # Qiskit adapter
70+
│ │ ├── cirq.py # Cirq adapter
71+
│ │ └── pennylane.py # PennyLane adapter
72+
│ ├── analysis/ # Analysis tools
73+
│ │ ├── score.py # Reproducibility scoring
74+
│ │ ├── drift.py # Calibration drift
75+
│ │ └── validation.py # Trace validation
76+
│ ├── cli/ # Command-line interface
77+
│ └── notebook/ # Jupyter integration
78+
├── tests/ # Test files
79+
├── docs/ # Documentation
80+
└── pyproject.toml # Project configuration
81+
```
82+
83+
## How to Contribute
84+
85+
### Reporting Bugs
86+
87+
1. Check existing issues to avoid duplicates
88+
2. Create a new issue with:
89+
- Clear, descriptive title
90+
- Steps to reproduce
91+
- Expected vs actual behavior
92+
- Environment details (Python version, OS, framework versions)
93+
- QBOM trace file if relevant
94+
95+
### Suggesting Features
96+
97+
1. Check existing issues and discussions
98+
2. Create a feature request with:
99+
- Clear description of the feature
100+
- Use case and motivation
101+
- Proposed implementation (if any)
102+
103+
### Submitting Pull Requests
104+
105+
1. **Fork** the repository
106+
2. **Create a branch** for your changes:
107+
```bash
108+
git checkout -b feature/my-feature
109+
# or
110+
git checkout -b fix/bug-description
111+
```
112+
3. **Make your changes**
113+
4. **Add tests** for new functionality
114+
5. **Run tests and linting**:
115+
```bash
116+
pytest
117+
mypy src/qbom
118+
ruff check src/qbom
119+
```
120+
6. **Commit** with clear messages:
121+
```bash
122+
git commit -m "Add feature: description of feature"
123+
```
124+
7. **Push** to your fork:
125+
```bash
126+
git push origin feature/my-feature
127+
```
128+
8. **Create a Pull Request** with:
129+
- Clear description of changes
130+
- Link to related issues
131+
- Test results
132+
133+
## Coding Guidelines
134+
135+
### Style
136+
137+
- Follow PEP 8
138+
- Use type hints for all functions
139+
- Maximum line length: 100 characters
140+
- Use descriptive variable names
141+
142+
### Documentation
143+
144+
- All public functions must have docstrings
145+
- Use Google-style docstrings
146+
- Update relevant documentation files
147+
148+
### Testing
149+
150+
- Write tests for all new functionality
151+
- Maintain test coverage above 80% for new code
152+
- Use pytest fixtures for common setup
153+
154+
### Example
155+
156+
```python
157+
def calculate_score(trace: Trace) -> ScoreResult:
158+
"""
159+
Calculate reproducibility score for a trace.
160+
161+
Analyzes the trace's completeness and calculates a score
162+
from 0-100 indicating how reproducible the experiment is.
163+
164+
Args:
165+
trace: The QBOM trace to analyze.
166+
167+
Returns:
168+
ScoreResult containing total score, grade, and component breakdown.
169+
170+
Raises:
171+
ValueError: If trace is invalid or empty.
172+
173+
Example:
174+
>>> trace = qbom.current()
175+
>>> result = calculate_score(trace)
176+
>>> print(f"Score: {result.total_score}/100")
177+
Score: 71/100
178+
"""
179+
# Implementation...
180+
```
181+
182+
## Adding a New Adapter
183+
184+
To add support for a new quantum framework:
185+
186+
1. Create `src/qbom/adapters/newframework.py`:
187+
188+
```python
189+
from qbom.adapters.base import Adapter
190+
191+
class NewFrameworkAdapter(Adapter):
192+
name = "newframework"
193+
194+
def install(self) -> None:
195+
# Hook framework functions
196+
pass
197+
198+
def uninstall(self) -> None:
199+
self._unwrap_all()
200+
self._installed = False
201+
```
202+
203+
2. Register in `src/qbom/core/session.py`:
204+
205+
```python
206+
ADAPTER_MAP = {
207+
# ...existing...
208+
"newframework": ("qbom.adapters.newframework", "NewFrameworkAdapter"),
209+
}
210+
```
211+
212+
3. Add to `WATCHED_MODULES` in `QBOMImportFinder`:
213+
214+
```python
215+
WATCHED_MODULES = {
216+
# ...existing...
217+
"newframework": "newframework",
218+
}
219+
```
220+
221+
4. Add optional dependency in `pyproject.toml`:
222+
223+
```toml
224+
[project.optional-dependencies]
225+
newframework = ["newframework>=1.0.0"]
226+
```
227+
228+
5. Write tests in `tests/test_newframework_adapter.py`
229+
230+
6. Update documentation in `docs/ADAPTERS.md`
231+
232+
## Release Process
233+
234+
Releases are managed by maintainers:
235+
236+
1. Update version in `pyproject.toml`
237+
2. Update CHANGELOG.md
238+
3. Create git tag: `git tag v0.2.0`
239+
4. Push tag: `git push origin v0.2.0`
240+
5. GitHub Actions builds and publishes to PyPI
241+
242+
## Getting Help
243+
244+
- Open an issue for bugs or questions
245+
- Start a discussion for feature ideas
246+
- See [documentation](docs/) for usage guides
247+
248+
## Recognition
249+
250+
Contributors are recognized in:
251+
- CONTRIBUTORS.md file
252+
- Release notes
253+
- Project documentation
254+
255+
Thank you for contributing to QBOM!

0 commit comments

Comments
 (0)