[PR #1696] fix(labs): catch missing wheel before deploy to prevent BadZipFile in browser #10238

Open
opened 2026-05-08 11:21:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1696
Author: @Shashank-Tripathi-07
Created: 5/7/2026
Status: 🔄 Open

Base: devHead: fix/labs-wheel-missing-test


📝 Commits (1)

  • fd6e27c fix(labs): catch missing wheel before deploy to prevent BadZipFile in browser

📊 Changes

2 files changed (+42 additions, -0 deletions)

View changed files

📝 labs/tests/test_static.py (+21 -0)
📝 labs/tools/build_site.sh (+21 -0)

📄 Description

Summary

Fixes #1691.

Root cause: micropip.install("../../wheels/mlsysim-0.1.1-py3-none-any.whl") in the browser resolves to mlsysbook.ai/labs/wheels/mlsysim-0.1.1-py3-none-any.whl. The live site was deployed before commit 1eb30f5f8 landed (which bumped the wheel and all lab references from 0.1.0 to 0.1.1), so the URL returns a 404 HTML page. micropip hands that to zipfile, which correctly raises BadZipFile. Every downstream cell then fails with "Ancestor raised".

Immediate fix for maintainers: retrigger labs-publish-live.yml via workflow_dispatch -- no code change needed for the live site to recover.

This PR prevents recurrence with two guards:

  • labs/tests/test_static.py -- new test_wheel_file_exists_on_disk test that asserts wheels/mlsysim-{version}-py3-none-any.whl actually exists on disk. This runs in labs-validate-dev.yml, which gates the publish workflow via the publish guard. A deploy where the wheel file is absent will now fail CI before any WASM export happens.

  • labs/tools/build_site.sh -- version-consistency guard added after python3 -m build --wheel. Reads the version from mlsysim/pyproject.toml, confirms the built wheel exists at the expected path, and spot-checks lab_01_ml_intro.py to confirm the micropip.install() URL references the same version. Fails the build immediately with a clear error message if there is a mismatch.

Test plan

  • python3 -m pytest labs/tests/test_static.py::TestWheelConsistency::test_wheel_file_exists_on_disk -v passes with wheel present, fails with wheel removed
  • labs-validate-dev.yml passes on this branch
  • Retrigger labs-publish-live.yml to deploy the 0.1.1 wheel and unblock users hitting #1691

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1696 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 5/7/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/labs-wheel-missing-test` --- ### 📝 Commits (1) - [`fd6e27c`](https://github.com/harvard-edge/cs249r_book/commit/fd6e27ccf37516c239252aadc987472562ea1d35) fix(labs): catch missing wheel before deploy to prevent BadZipFile in browser ### 📊 Changes **2 files changed** (+42 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `labs/tests/test_static.py` (+21 -0) 📝 `labs/tools/build_site.sh` (+21 -0) </details> ### 📄 Description ## Summary Fixes #1691. **Root cause:** `micropip.install("../../wheels/mlsysim-0.1.1-py3-none-any.whl")` in the browser resolves to `mlsysbook.ai/labs/wheels/mlsysim-0.1.1-py3-none-any.whl`. The live site was deployed before commit `1eb30f5f8` landed (which bumped the wheel and all lab references from `0.1.0` to `0.1.1`), so the URL returns a 404 HTML page. `micropip` hands that to `zipfile`, which correctly raises `BadZipFile`. Every downstream cell then fails with "Ancestor raised". **Immediate fix for maintainers:** retrigger `labs-publish-live.yml` via `workflow_dispatch` -- no code change needed for the live site to recover. **This PR prevents recurrence with two guards:** - `labs/tests/test_static.py` -- new `test_wheel_file_exists_on_disk` test that asserts `wheels/mlsysim-{version}-py3-none-any.whl` actually exists on disk. This runs in `labs-validate-dev.yml`, which gates the publish workflow via the publish guard. A deploy where the wheel file is absent will now fail CI before any WASM export happens. - `labs/tools/build_site.sh` -- version-consistency guard added after `python3 -m build --wheel`. Reads the version from `mlsysim/pyproject.toml`, confirms the built wheel exists at the expected path, and spot-checks `lab_01_ml_intro.py` to confirm the `micropip.install()` URL references the same version. Fails the build immediately with a clear error message if there is a mismatch. ## Test plan - [ ] `python3 -m pytest labs/tests/test_static.py::TestWheelConsistency::test_wheel_file_exists_on_disk -v` passes with wheel present, fails with wheel removed - [ ] `labs-validate-dev.yml` passes on this branch - [ ] Retrigger `labs-publish-live.yml` to deploy the `0.1.1` wheel and unblock users hitting #1691 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-08 11:21:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#10238