Notebook.fix packages

From gpsaggese/helpers · View interactive version

Notebook.fix packages is an AI agent skill from the GitHub repository gpsaggese/helpers. Keep the Docker container aligned with the template and install Python packages directly in the notebook

How to use this skill

Skill file

Goal

replicating Docker containers

Inputs

msml610/tutorials/L03_knowledge_representation) cloned from

class_project/project_template

Workflow

Use the Docker Container From the Project Teamplate

use the same Dockerfile and requirements.txt as the matching files in

class_project/project_template, so the project container matches the class

project template

with a clear comment on why it is needed

Discover All Packages Needed by the Notebook

a *_utils.py file (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

```

every third-party import / from ... import statement, not just those in the

notebook

sklearn -> scikit-learn, PIL -> Pillow, yaml -> PyYAML)

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

cannot be installed with pip (per `## Use the Docker Container from the Project

Teamplate` above)

Add Packages to Notebooks

package from ## Discover All Packages Needed by the Notebook above. Install and

pin the versions

```

%load_ext autoreload

%autoreload 2

import logging

```

a 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

# Code Architecture and Responsibility ->

## Utilities vs. Notebook Responsibilities in .claude/skills/notebook.rules.md

Verification

has a matching entry in requirements.txt and in the notebook's

pip install cell

<TARGET_DIR>

container for the project, if possible

nbconvert to make sure they run correctly end-to-end

Conventions

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.