How qiskit/qiskit-tutorials works
Project Type and Purpose
• This is an educational “documentation‐as‐code” project: a collection of Jupyter notebooks (tutorials) built into HTML documentation via Sphinx.
• Purpose: Teach users how to use Qiskit (quantum programming SDK) through hands-on notebooks, automated testing of notebooks, and CI/CD to publish tutorials.
File‐Structure Analysis
• Top-level:
• .github/ → GitHub issue/PR templates, contributing rules
• azure-pipelines.yml → Azure DevOps CI config
• tox.ini, requirements-dev.txt, constraints.txt → Local/test environment orchestration
• conf.py, index.rst, _static/ → Sphinx documentation source
• tutorials/ → Jupyter notebooks grouped by topic (algorithms, circuits, advanced)
• start_here.ipynb → Entry-point tutorial
• Build tooling: Tox drives environment setup and “docs” build, nbsphinx converts .ipynb to RST/HTML, Sphinx renders site.
README Insights
• Mentions Sphinx, Tox, three-minute cell execution limit, no live IBMQ calls, strict header rules.
• Deployment: After PR, docs are hosted via Qiskit’s Sphinx infrastructure (e.g., on GitHub Pages or ReadTheDocs).
a. Main Components
1. Tutorial Content Repository (Git)
2. CI/CD Orchestration (GitHub Actions / Azure Pipelines)
3. Build/Test Environment (Tox + Python Virtualenvs)
4. Documentation Generator (nbsphinx + Sphinx)
5. Artifact Storage / Hosting (ReadTheDocs / GitHub Pages / S3)
6. External Dependencies (PyPI packages: qiskit-terra, qiskit-aer, etc.; IBM Quantum backends—not used at build)
b. Relationships and Interactions
• Code push → CI/CD triggers → Tox creates env → executes notebooks (nbsphinx) → Sphinx builds HTML → CI publishes artifacts to hosting.
• README, RST, conf.py feed Sphinx’s master document tree.
• Requirements files govern environment in Tox and CI.
c. Architectural Patterns
• “Docs as Code”: treat tutorials as source code, versioned and tested.
• Pipeline as Code: CI/CD defined in YAML (azure-pipelines.yml, .mergify.yml).
• Modular content: notebooks grouped by domain, nbsphinx extension handles conversion.
d. Key Technologies
• Python, Jupyter Notebooks, Sphinx, nbsphinx, Tox, GitHub Actions / Azure Pipelines, nbsphinx-thumbnail, ReadTheDocs/GitHub Pages.
Detailed Component Breakdown
• Source Control
• .github/ → Contributor guidelines, templates
• Tutorials/*.ipynb → Domain notebooks
• conf.py, index.rst → Sphinx config
• CI/CD
• azure-pipelines.yml / GitHub Actions steps
• Tox env creation & execution
• Build & Test
• Install deps from requirements-dev.txt & constraints.txt
• nbsphinx renders notebooks to RST
• Sphinx builds HTML under _build/html
• Deployment
• Push HTML to hosting (e.g., ReadTheDocs webhook or GitHub Pages branch)
• External Dependencies
• Qiskit packages (terra, aer) fetched from PyPI
• IBM Quantum API (shown as “Not invoked during CI build”)
Putting It All Together
• Branching into two parallel flows in CI: (1) Notebook execution tests, (2) Lint + static checks.
• Merge flows into “Sphinx Build” node.
• Constraints (3-min cell timeout, no IBMQ calls).