Welcome! Happy to see you want to help us make the project better.
The following is a summary of important commands and protocols for developers contributing to qBraid. Note that all commands assume a Debian environment, and that all commands (except the initial repository cloning command) assume your current working directory is the qBraid repo root.
tox -e unit-tests
: All unit tests are passing. New + modified code has corresponding unit tests and satisfycodecov
checks. To run remote tests (i.e. those requiring qBraid/AWS/IBM credentials), set environment variableQBRAID_RUN_REMOTE_TESTS=True
.tox -e docs
: Doc builds are passing. New + modified code has appropriate docstrings and tree stubs are updated, if applicable.tox -e format-check
: Code passes linters and formatters checks. Any exceptions or updates to code style configs are documented.python tools/verify_headers.py
: New files have appropriate licensing headers. Running headers script passes checks.
You can install the qBraid-SDK from source by cloning this repository and running a pip install command in the root directory:
git clone https://github.com/qbraid/qBraid.git
cd qBraid
pip install -e '.[all]' # install all extensions
To generate the API reference documentation locally:
pip install 'tox>=4.2'
tox -e docs
Alternatively:
pip install -e '.[docs]'
cd docs
make html
Both methods will run Sphinx in your shell. If the build results in an InvocationError
due to a
duplicate object description, try rm docs/stubs/*
to empty the old stubs directory, and then
re-start the build. If the build succeeds, it will say The HTML pages are in build/html
. You can
view the generated documentation in your browser (on OS X) using:
open build/html/index.html
You can also view it by running a web server in that directory:
cd build/html
python3 -m http.server
Then open your browser to http://localhost:8000. If you make changes to the docs that aren't
reflected in subsequent builds, run make clean html
, which will force a full rebuild.
Our docs are written using reStructuredText (reST), which is the default plaintext markup language used by Sphinx. It's pretty straightforward once you get the hang of it. If you're unfamiliar, reStructuredText Primer is a good place to start.
This project uses Google Style Python Docstrings
to specify attributes, arguments, exceptions, returns, and other related info. The docstrings are compiled into HTML using Sphinx,
so to add relative links, in-line markup, bulleted lists, code-blocks, or do other types of formatting inside of docstrings, use
the reST
syntax mentioned (linked) above.
To run all unit tests:
pip install 'tox>=4.2'
tox -e unit-tests
You can also pass in various pytest arguments to run selected tests:
tox -e unit-tests -- {your-arguments}
Alternatively:
pip install pytest
pytest {path-to-test}
Running unit tests with tox will automatically generate a coverage report, which can be viewed by
opening tests/_coverage/index.html
in your browser. The latest code coverage report generated
from the main
branch can be viewed at https://app.codecov.io/gh/qBraid/qBraid/tree/main.
To run linters and doc generators and unit tests:
tox
For code style, our project uses a combination of isort, pylint,
and black. Each of these tools is setup with its own default configuration specific to this project in pyproject.toml
.