Fix broken import and embed() retry bug in rerankers notebook#583
Open
amaralazizy wants to merge 1 commit into
Open
Fix broken import and embed() retry bug in rerankers notebook#583amaralazizy wants to merge 1 commit into
amaralazizy wants to merge 1 commit into
Conversation
- Replace `pinecone_plugins.inference.core.client.exceptions.PineconeApiException` with `pinecone.exceptions.PineconeApiException`. The plugin module no longer exports this symbol in current `pinecone[grpc]` releases, so the notebook fails at import. - Initialize `passed = False` inside `embed()` so total failure raises the intended `RuntimeError` instead of `UnboundLocalError`. - `break` after a successful embed call, instead of continuing to issue the remaining retry-loop iterations. Previously every batch made 5 API calls even on success, which hit rate limits and made indexing extremely slow. - Print the actual `PineconeApiException` on retry so users can diagnose rate-limit / auth / quota errors instead of seeing a bare "Retrying...".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes to
learn/generation/better-rag/00-rerankers-pinecone.ipynb:Broken import.
pinecone_plugins.inference.core.client.exceptions.PineconeApiExceptionno longer exists in currentpinecone[grpc]releases (the plugin module'sexceptions.pyis empty). The notebook fails immediately on cell 18 withImportError. Replaced withpinecone.exceptions.PineconeApiException.embed()retry-loop bugs:passedwas never initialized — if all 5 retries failed,if not passedraisedUnboundLocalErrorinstead of the intendedRuntimeError. Now initialized toFalseat the top of the function.breakafter success, so every batch issued all 5 API calls even when the first one succeeded. This compounds with embedding rate limits and makes indexing extremely slow (I was seeing ~25s per batch with constant 429s before this fix).except PineconeApiException:swallowed the exception, so the only feedback was a bare"Retrying...". Now printsf"Retry {j}: {e}"so users can see whether it's rate limiting, auth, quota, etc.Test plan
pinecone[grpc]==5.1.0.embed()raisesRuntimeError(notUnboundLocalError) when all retries fail.Note
Low Risk
Documentation-only notebook changes with no production code; low risk aside from verifying the new import matches the pinned Pinecone version.
Overview
Updates
00-rerankers-pinecone.ipynbso it runs against currentpinecone[grpc]and indexes batches without redundant API calls.PineconeApiExceptionis imported frompinecone.exceptionsinstead of the removed plugin path, so the embedding cell no longer fails on import.The
embed()retry helper now initializespassed = False,breaks after a successfulpc.inference.embed, and logsRetry {j}: {e}on failure so exhausted retries raiseRuntimeErrorinstead ofUnboundLocalError, and successful batches stop after one call instead of five.Also fixes the notebook JSON trailing newline.
Reviewed by Cursor Bugbot for commit 95b55c5. Bugbot is set up for automated code reviews on this repo. Configure here.