Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Check that saved notebook outputs still match the package
# Runs pages that need no downloaded data, without saving them, and fails
# when what they print has changed. Add such pages to PAGES.
run: make -C docs check-outputs PAGES="quickstart differential_expression guides/export_cubes guides/bulk_rna_seq guides/composition guides/combine_studies guides/replication_across_studies"
run: make -C docs check-outputs PAGES="quickstart why_pseudobulk guides/pool_cells guides/save_and_trace_cubes guides/export_cubes guides/anndata_and_mudata guides/bulk_rna_seq guides/composition guides/combine_studies guides/replication_across_studies"
- name: Store the site
if: ${{ !inputs.pages }}
uses: actions/upload-artifact@v7
Expand Down
5 changes: 0 additions & 5 deletions docs/coverage_exemptions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,5 @@
"cytepool.table.Table.to_dict" = "a method of CytePool's minimal table of columns, documented in the API reference; the guides show the common ones"

[planned]
"cytepool.table.Table.select" = "guides/pool_cells: sample and group tables"
"cytepool.table.Table.filter" = "guides/pool_cells: sample and group tables"
"cytepool.table.Table.with_columns" = "guides/pool_cells: sample and group tables"
"cytepool.plotting.plot_dispersions" = "guides/bulk_rna_seq: DESeq2's dispersion estimates"
"cytepool.plotting.plot_pca" = "guides/normalization_and_quality and guides/bulk_rna_seq: samples on their principal components"
"cytepool.plotting.plot_dotplot" = "guides/pool_cells: the markers of each cell type as a dot plot, from the cube"
"cytepool.plotting.plot_quasi_dispersions" = "guides/bulk_rna_seq: edgeR's quasi-dispersions"
24 changes: 20 additions & 4 deletions docs/execute_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
the text they print differs from the saved outputs, as it does when a change to the
package changed their results. Figures and standard error are not compared, and
neither is CytePool's own version, which changes with every commit of a development
version and which a page can print, for example in a cube's history: the saved text is
compared with the version that ran it replaced by the version running now.
version and which a page can print: the saved text is compared with the version that
ran it replaced by the version running now, and a version written after "CytePool ",
as a cube's history writes the version that built it, is left out of both. A dataset
prepared before the page ran was built by another version, and on CI every dataset is
built again by the version being checked.

Usage, from the repository root::

Expand All @@ -31,6 +34,7 @@

import argparse
import copy
import re
import tempfile
import time
from datetime import UTC, datetime
Expand Down Expand Up @@ -155,18 +159,30 @@ def printed_text(notebook: nbformat.NotebookNode) -> list[str]:
return texts


# A version of CytePool where printed text names it, as in "CytePool 0.1.dev42+g6991e63f8".
_NAMED_VERSION = re.compile(
r"(?<=CytePool )\d+(?:\.\d+)*(?:(?:a|b|rc|\.dev|\.post)\d+)*(?:\+[0-9A-Za-z.]+)?"
)


def differences(
saved: list[str], fresh: list[str], saved_version: str | None, version: str
) -> list[str]:
"""The code cells whose printed text differs, other than in CytePool's version.

``saved_version`` is the version that ran the saved notebook (None if it was
not recorded) and ``version`` the one that ran it again.
not recorded) and ``version`` the one that ran it again. A version written after
"CytePool " is left out of both texts.
"""

def compared(text: str) -> str:
return _NAMED_VERSION.sub("<version>", text)

return [
f"code cell {number}: saved {old!r}, now {new!r}"
for number, (old, new) in enumerate(zip(saved, fresh, strict=True), start=1)
if (old.replace(saved_version, version) if saved_version else old) != new
if compared(old.replace(saved_version, version) if saved_version else old)
!= compared(new)
]


Expand Down
Loading