gpsaggese/helpers / .claude/skills/notebook.fix_packages
notebook.fix_packages
VerifiedKeep the Docker container aligned with the template and install Python packages directly in the notebook
Goal
- When creating Docker images for projects and tutorials, we want to
- Always use the same Docker template image from
class_projectto avoid replicating Docker containers - Install the needed packages in the notebooks to customize the container
- Always use the same Docker template image from
Inputs
- The user passes:
- A target dir
<TARGET_DIR>(e.g.,msml610/tutorials/L03_knowledge_representation) cloned fromclass_project/project_template - (Optional) pointers to Jupyter notebooks
- A target dir
Workflow
Use the Docker Container From the Project Teamplate
- In the project dir (e.g.,
msml610/tutorials/L03_knowledge_representation), use the sameDockerfileandrequirements.txtas the matching files inclass_project/project_template, so the project container matches the class project template - If the image needs something that
pipcannot install, add it toDockerfilewith a clear comment on why it is needed
Discover All Packages Needed by the Notebook
-
A notebook's own
importlines are not the full picture. Each notebook pairs with a*_utils.pyfile (e.g.,L03_06_logic_solvers.ipynb->L03_06_logic_solvers_utils.py), imported with a line like:import L03_06_logic_solvers_utils as utils -
Read the
*_utils.pyfile and any local module it imports (transitively). Collect every third-partyimport/from ... importstatement, not just those in the notebook -
Map import names to pip names where they differ (e.g.,
cv2->opencv-python,sklearn->scikit-learn,PIL->Pillow,yaml->PyYAML) -
Diff this full list against
requirements.txtandDockerfile. A package used by the notebook or its utils that is missing from both is a bug, even if it is already installed in the container used to author the notebook -
Add every missing package to
requirements.txt, and toDockerfileonly if it cannot be installed withpip(per## Use the Docker Container from the Project Teamplateabove)
Add Packages to Notebooks
-
Add a
pip installcell for the packages needed in each notebook, including every package from## Discover All Packages Needed by the Notebookabove. Install and pin the versions -
For each notebook, add after the first call with
%load_ext autoreload %autoreload 2 import logginga cell with content like:
!pip install -q python-sat==1.9.dev15 sympy==1.14.0 z3-solver==5.1.0.0 import pysat print("pysat version: ", pysat.__version__) import sympy print("sympy version: ", sympy.__version__) import z3 print("z3 version: ", z3.get_version_string())
Sync Notebook
- At the end, sync the paired
.pyfile with Jupytext following the conventions in# Code Architecture and Responsibility->## Utilities vs. Notebook Responsibilitiesin.claude/skills/notebook.rules.md
Verification
- Every third-party import in the notebook and its paired
*_utils.pyfile has a matching entry inrequirements.txtand in the notebook'spip installcell - Build the docker container with
docker_build.shinside the target dir<TARGET_DIR> - Make sure the container builds correctly and it's the same as the Docker container for the project, if possible
- Run each notebook inside the docker container with
docker_cmd.shandnbconvertto make sure they run correctly end-to-end
Conventions
- Always follow the conventions and guidelines in
.claude/skills/notebook.rules.md
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 117k | Updated | Claude CodeCodex | Verified | Install |