Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask contributors to use tox for final notebook execution. #1365

Merged
merged 5 commits into from
May 14, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,23 @@ This staging environment can be useful to see how the docs are rendering before

## Execute notebooks

Before submitting a new notebook or code changes to a notebook, you must run
the notebook using `tox -- --write <path-to-notebook>` and commit the results.
If the notebook submits jobs, also use the argument `--submit-jobs`. This means
we can be sure all notebooks work and that users will see the same results when
they run using the environment we recommend.

To execute notebooks in a fixed Python environment, first install `tox` using
[pipx](https://pipx.pypa.io/stable/):

```sh
pipx install tox
```

You also need to install a few system dependencies: TeX, Poppler, and graphviz. On macOS, you can run `brew install mactex-no-gui poppler graphviz`. On Ubuntu, you can run `apt-get install texlive-pictures texlive-latex-extra poppler-utils graphviz`.
You also need to install a few system dependencies: TeX, Poppler, and graphviz.
On macOS, you can run `brew install mactex-no-gui poppler graphviz`. On Ubuntu,
you can run `apt-get install texlive-pictures texlive-latex-extra poppler-utils
graphviz`.

- To execute all notebooks, run tox.
```sh
Expand All @@ -128,20 +137,20 @@ You also need to install a few system dependencies: TeX, Poppler, and graphviz.
> [!NOTE]
> If your notebook submits hardware jobs to Qiskit Runtime, you must add it to
> [`scripts/nb-tester/notebooks.toml`](scripts/nb-tester/notebooks.toml). If it
> can be run with simulators, i.e., the circuit is not too large, add it to `notebooks_that_submit_jobs`.
> Otherwise, add it to `notebooks_no_mock`.
> can be run with simulators, i.e., the circuit is not too large, add it to
> `notebooks_that_submit_jobs`. Otherwise, add it to `notebooks_no_mock`.
frankharkins marked this conversation as resolved.
Show resolved Hide resolved

> If your notebook uses the latex circuit drawer (`qc.draw("latex")`), you must
> add it to the "Check for notebooks that require LaTeX" step in
> `.github/workflows/notebook-test.yml`.

When you make a pull request changing a notebook that doesn't submit jobs, you
can get a version of that notebook that was executed in a uniform environment
from CI. To do this, click "Show all checks" in the info box at the bottom of
the pull request page on GitHub, then choose "Details" for the "Test notebooks"
job. From the job page, click "Summary", then download "Executed notebooks".
Otherwise, if your notebook does submit jobs, you need to run it locally with
`tox -- --write --submit-jobs <path/to/notebook.ipynb>`.
can get a version of that notebook that was executed by tox from CI. To do
this, click "Show all checks" in the info box at the bottom of the pull request
page on GitHub, then choose "Details" for the "Test notebooks" job. From the
job page, click "Summary", then download "Executed notebooks". Otherwise, if
your notebook does submit jobs, you need to run it locally using the steps
mentioned earlier.

### Ignoring warnings

Expand Down
Loading