docs: install the published wheel in notebooks 02 and 03 - #197
Conversation
Both notebooks imported datasets.make_donor_panel, absent from the 0.7.0 wheel, and fell back to a try/except ImportError that pip-installed from git+main. That fallback cannot work in-process: the failed import leaves the stale philanthropy.datasets module cached in sys.modules, so the re-import after a successful install raises the same ImportError. It only worked where philanthropy was absent entirely, which is fresh Colab, so a reader who followed the README's pip install and then opened a notebook locally got a hard failure, and the Colab badge ran an unreleased snapshot rather than the release paper.md points at. Replaced with a plain pip install -q "philanthropy[viz]>=0.7.1". 0.7.1 satisfies that from PyPI, and an existing install satisfies it without a network call, so a local checkout and CI are unaffected. Notebook 01 keeps its try/except deliberately: a bare import philanthropy succeeds against any published release, so its guard never misfires and the in-process problem does not arise there. pytest --nbmake examples/notebooks: 3 passed. That run does NOT verify the PyPI path, because the editable 0.7.1 install already satisfies the requirement and pip short-circuits. The wheel path can only be verified after 0.7.1 is published, from a neutral cwd in a clean venv, which is why this stays unmerged until then.
|
0.7.1 is on PyPI, so the gate on this PR is satisfied and the verification the body said could not be done before publish has now been done properly: clean venv, published wheel, neutral cwd.
Then the notebooks themselves, run from a scratch directory outside the repository so the checkout cannot shadow the install: That is all three notebooks, including 01, executing end to end against the published 0.7.1 wheel with the new unconditional CI on this PR is green across all fifteen checks on Merging. |
Do not merge until 0.7.1 is on PyPI. The draft release for
v0.7.1is created and waiting on the maintainer's Publish release click. Until that click lands,pip install "philanthropy[viz]>=0.7.1"has nothing to resolve to on a fresh machine, and merging this would break the Colab badge in the window between merge and publish. Right now thegit+mainfallback onmainstill works in fresh Colab, so there is no urgency to land this early.The bug
Notebooks 02 and 03 import
philanthropy.datasets.make_donor_panel, which the published 0.7.0 wheel does not contain. Verified in a clean venv from a neutral cwd, because the repository root shadows site-packages and an earlier check run from the root reported the opposite:So both notebooks fell into this:
That cannot work in-process. The failed
from philanthropy.datasets import make_donor_panelleaves the already-importedphilanthropy.datasetsmodule object cached insys.modules, so the secondfrom ... importafter a successful install re-reads the same stale module and raises the identicalImportError. The fallback only works where philanthropy is absent from the environment entirely, which is fresh Colab and nowhere else.Two consequences:
pip install philanthropyand then opened a notebook locally got a hard failure, on the two notebooks that demonstrate the package's central argument.mainsnapshot rather than the archived releasepaper.mdpoints at. That is the one a JOSS reviewer sees.The fix
Unconditional rather than guarded, because the guard was the bug. In fresh Colab this installs 0.7.1 from PyPI before anything imports philanthropy, so
sys.modulesis clean. In a local checkout or in CI the requirement is already satisfied by the editable install, so pip short-circuits against installed metadata and never queries the index.Notebook 01 is deliberately untouched. Its guard is
try: import philanthropy, which succeeds against any published release, so it never misfires and the in-process staleness problem does not arise there. Changing it would be churn.What is verified, and what is not
Being explicit about the gap rather than letting a later reader assume it away, because
plan.mdD.1 says never to anticipate what a notebook does against the published wheel: that nbmake run does not exercise the PyPI path. The editable 0.7.1 install already satisfies>=0.7.1, so pip short-circuits and the wheel is never fetched. CI has the same blind spot, because CI installs the working tree. The only real check ispytest --nbmakein a clean venv from a neutral cwd after the wheel exists on PyPI, and that is a post-publish step, not something this PR can carry.Sequence, so nothing is verified out of order:
v0.7.1draft.publish.ymluploads to PyPI.pip install philanthropy==0.7.1in a clean venv from a neutral cwd, and thatdatasets.__all__now containsmake_donor_panel.pytest --nbmake examples/notebooksagainst that venv.Also worth knowing:
pypi-smoke.ymlruns Mondays at 12:00 UTC against the published wheel on Linux, macOS and Windows, so it becomes an independent check on step 2 without anyone having to remember it.