Skip to content

refactor(docs/quick-tour): modernize hello-pinecone to pinecone 9.0#572

Open
jhamon wants to merge 1 commit into
mainfrom
nb-087-hello-pinecone
Open

refactor(docs/quick-tour): modernize hello-pinecone to pinecone 9.0#572
jhamon wants to merge 1 commit into
mainfrom
nb-087-hello-pinecone

Conversation

@jhamon
Copy link
Copy Markdown
Collaborator

@jhamon jhamon commented May 12, 2026

Purpose

hello-pinecone.ipynb pinned pinecone==8.0.0 (one major version behind) and had
imports scattered across non-first code cells (code cells 2, 5, 8, 10),
failing the check-structure validator. Ruff reported I001 import-sorting
errors in three cells where stdlib and third-party imports were not separated
by a blank line.

Solution

  • pinecone==8.0.0pinecone==9.0.0 (pip install cell)
  • Consolidate all unconditional imports into the first code cell (the pip install
    cell) per check-structure requirements: os, random, time, pandas,
    and all pinecone symbols now live in a single block at the top
  • Sort imports: stdlib group (os, random, time) then third-party group
    (pandas, pinecone symbols) with a blank line between groups — fixes all
    I001 findings
  • Remove now-redundant import lines from the former code cells 5, 8, and 10
  • All Pinecone call sites already used keyword arguments (no positional fixes needed)

Verification

  • Notebook executes top-to-bottom against real Pinecone API
  • ruff check clean
  • ruff format --check clean
  • check-pinning passes
  • check-secrets passes
  • check-structure passes
  • check-timeless passes
  • No pinecone.init / pinecone-client / environment= patterns remaining
  • Cleanup cell (pc.delete_index(name=index_name)) executed successfully

Advisory checks

  • Behavior preservation: confirmed — notebook still creates a serverless index,
    upserts 10 simulated vectors, waits for indexing, runs a cosine-similarity
    query, and deletes the index. Output shape and values unchanged.

Refs

  • Harness task: NB-087

Note

Low Risk
Low risk documentation-only change: updates a tutorial notebook’s dependency pin and reorganizes notebook cells/imports without changing the underlying API flow.

Overview
Updates docs/quick-tour/hello-pinecone.ipynb to pin pinecone==9.0.0 (from 8.x) and consolidates/sorts all imports into the first install cell.

Cleans the notebook for tooling/validation by clearing execution counts/outputs and normalizing cell ids, removing redundant per-cell imports while keeping the index create/upsert/query/delete steps the same.

Reviewed by Cursor Bugbot for commit 1c9c9a9. Bugbot is set up for automated code reviews on this repo. Configure here.

jhamon added a commit that referenced this pull request May 13, 2026
## Purpose

The current `run-notebook` action partitions each code cell whole-cell:
cells containing `!pip` go entirely to a bash script, the rest go to a
Python script. A cell that mixes `!pip install` with Python imports — a
standard Jupyter pattern — fails with `import: command not found`
because bash tries to execute Python as a shell command. See PR #572 /
[run
25743389812](https://github.com/pinecone-io/examples/actions/runs/25743389812/job/75599935724)
for a live example.

## Solution

Drive notebooks through [`nbclient`](https://nbclient.readthedocs.io/),
the same tool Project Jupyter ships behind `jupyter nbconvert
--execute`. `nbclient` launches a real `ipykernel` and processes cells
line-by-line: `!pip` and other shell magics route through the kernel's
magic handlers (subshell), Python runs as Python. Mixed cells work
exactly as they do in Colab and Jupyter Lab.

## Changes

- New `run-notebook.py`: 50-line nbclient driver. Takes the notebook
path as its only arg. Exits 0 on success, 1 on any cell error, 2 on
usage error.
- Updated `action.yml`: installs `nbformat nbclient ipykernel` into the
runner Python, then invokes the new script. No tempdir, no nested venv,
no bash conversion.
- Removed `convert-notebook.py` (~120 lines).

Net diff: 66 insertions, 137 deletions.

## Verification

Tested locally against the notebook from PR #572
(`docs/quick-tour/hello-pinecone.ipynb`, with `!pip install` and Python
imports in the same cell — the case that breaks today's runner):

```
$ python .github/actions/run-notebook/run-notebook.py docs/quick-tour/hello-pinecone.ipynb
Executing docs/quick-tour/hello-pinecone.ipynb
PASS — docs/quick-tour/hello-pinecone.ipynb
```

## Notes

- **`check-structure` follow-up.** The lint rule "imports must be in the
first code cell" was designed around today's runner: under the new
runner, a single cell holding `!pip install` + imports is once again the
correct pattern. Either relax the rule to skip pip-only cells when
locating "the first code cell," or remove the rule entirely. Separate
PR.
- **Notebook dep isolation.** Notebook deps now install into the
runner's Python (the kernel shares its interpreter), not a nested venv.
Acceptable for CI (ephemeral runner) and simpler than the previous
tempdir/venv dance.
- **Per-cell timeout.** 600s by default, overridable via
`NOTEBOOK_CELL_TIMEOUT`.
- **Soak.** Worth running this against a known-passing notebook before
merging to confirm no regressions on the existing fleet — let me know if
you want me to dual-run on a sample.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes the CI notebook execution mechanism from a custom
conversion/venv+bash flow to `nbclient` driving a real Jupyter kernel,
which may alter dependency/runtime behavior and failure modes across the
notebook suite.
> 
> **Overview**
> Updates the `run-notebook` composite action to execute notebooks
end-to-end using `nbclient`/`ipykernel` instead of converting cells into
separate bash/python scripts.
> 
> This removes `convert-notebook.py`, installs `nbformat nbclient
ipykernel` on the runner, and adds `run-notebook.py` which runs the
notebook with a real kernel, returning clearer per-cell errors and
supporting mixed `!pip` + Python cells (with an optional
`NOTEBOOK_CELL_TIMEOUT`).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f87187a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
## Purpose

hello-pinecone.ipynb pinned pinecone==8.0.0 and had imports scattered
across non-first code cells (code cells 2, 5, 8, 10), failing
check-structure. Ruff reported I001 import-sorting errors in 3 cells.

## Solution

- pinecone==8.0.0 → pinecone==9.0.0 (cell 0, pip install)
- Consolidate all unconditional imports into the first code cell
  (pip install cell) per check-structure requirements
- Sort imports: stdlib (os, random, time) then third-party
  (pandas, pinecone) with blank line between groups
- Remove scattered import lines from cells 2, 5, 8, 10
- Use keyword arguments throughout (per .ai/notebook-standards.md:53)

Refs: harness task NB-087.
@jhamon jhamon force-pushed the nb-087-hello-pinecone branch from c90cdc2 to 1c9c9a9 Compare May 13, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant