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

Notebooks guide #3781

Merged
merged 12 commits into from
Feb 12, 2021
Prev Previous commit
Next Next commit
added note about saving external notebook cell outputs
  • Loading branch information
balopat committed Feb 10, 2021
commit 7934eaf739589a53c85166d1db382a4cd4f08b36
13 changes: 13 additions & 0 deletions docs/dev/notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Our guides and tutorials are frequently written using iPython Notebooks. The not
Formatting is easy, the script `check/nbformat` should tell you if your notebooks are formatted or not.
You can apply the changes in one go with `check/nbformat --apply`. It is recommended to add this to you [git pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), to save feedback time and CI resources.
balopat marked this conversation as resolved.
Show resolved Hide resolved

## Output cells

Output cells typically should not be saved in the notebook. They will be generated for the final site.
The exception to this rule are notebooks with external dependencies (see below).
balopat marked this conversation as resolved.
Show resolved Hide resolved

## Header

We also expect a standard header to be included in all of our notebooks:
balopat marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -21,6 +26,14 @@ See the `dev_tools/notebooks` directory for the two tests:
- notebook_tests.py - to test notebooks against the current branch
- isolated_notebook_tests.py - to test notebooks against the latest released version of Cirq

## Notebooks with external dependencies

Unfortunately we have no way to test notebooks yet easily with external API dependencies, e.g. cirq.google's Engine API.
balopat marked this conversation as resolved.
Show resolved Hide resolved
These notebooks should be excluded from both tests.

The site that generates the outputs for notebooks also can't handle external dependencies.
Thus, for notebooks with external dependencies, **all cells must have their outputs saved in the notebook file**.

## Lifecycle

Notebooks are handled differently based on whether they rely on features in the pre-release build of cirq or not.
balopat marked this conversation as resolved.
Show resolved Hide resolved
Expand Down