Skip to content

fix(python): preserve API state on failed operations - #102

Merged
huanglune merged 3 commits into
mainfrom
fix/python-api-state-consistency
Jun 30, 2026
Merged

fix(python): preserve API state on failed operations#102
huanglune merged 3 commits into
mainfrom
fix/python-api-state-consistency

Conversation

@huanglune

Copy link
Copy Markdown
Contributor

Summary

  • Avoid shared default IndexParams state between independently created Index() instances.
  • Keep Index and Collection retryable after failed first-fit / first-insert paths instead of leaving half-initialized Python API state behind.
  • Validate Client disk-delete preconditions before mutating in-memory maps, and normalize Index.insert() list inputs through the same numpy path as search APIs.
  • Add focused regression coverage for each fixed API state edge case.

Test plan

  • git diff --check
  • timeout 60s .venv/bin/pytest -q
  • timeout 60s .venv/bin/ruff check python scripts tools
  • pre-commit hooks during git commit

Copilot AI review requested due to automatic review settings June 30, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
python/src/alayalite/index.py 89.74% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves error handling and state consistency in alayalite. Specifically, it ensures that delete_collection and delete_index validate disk operations before modifying the client's internal maps, avoids using mutable default arguments in Index.init, and ensures that failed fit operations do not leave the index or collection in a corrupted state. The review feedback highlights an issue where a failed fit operation can leave orphaned RocksDB files on disk, and suggests explicitly cleaning up the rocksdb_path directory and handling exceptions during database closure to prevent masking the original error.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/src/alayalite/index.py
@huanglune
huanglune merged commit 9917fe9 into main Jun 30, 2026
12 checks passed
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.

2 participants