Feat/index stats query params#1237
Conversation
Support showInternalDatabaseSizes and sizeFormat on index stats, extend IndexStats with internal_database_sizes, and add integration tests.
Support showInternalDatabaseSizes and sizeFormat on global stats, with integration tests and updated code sample.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThis PR adds optional stats query parameters for internal database sizes and human-readable formatting, extends the stats model, updates API samples, expands tests, and increases two embedder test timeouts. ChangesStats API Query Parameters Extension
Test Infrastructure Improvements
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/client/test_client_stats_meilisearch.py (1)
39-54: ⚡ Quick winThe internal-sizes human-format check can silently no-op.
Unlike
test_get_all_stats_with_internal_database_sizes, this test has noany(...)guard asserting that at least one index actually containsinternalDatabaseSizes. If no index returns the key, the loop body never runs and the human-format assertion on internal sizes is skipped (only the top-leveldatabaseSizecheck on Line 48 would cover the format). Add a presence guard to ensure the internal-size branch is exercised.✅ Proposed guard
assert isinstance(response["databaseSize"], str) assert HUMAN_SIZE_PATTERN.match(response["databaseSize"]) + assert any( + "internalDatabaseSizes" in index_stats for index_stats in response["indexes"].values() + ) for index_stats in response["indexes"].values(): if "internalDatabaseSizes" in index_stats:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/client/test_client_stats_meilisearch.py` around lines 39 - 54, The test test_get_all_stats_with_size_format can silently skip the internalDatabaseSizes checks if no index contains that key; update the test to assert the branch is exercised by collecting presence from response (e.g., use any(...) on response["indexes"].values() to check for "internalDatabaseSizes") and assert that at least one index contains internalDatabaseSizes before running the loop that validates HUMAN_SIZE_PATTERN on those values; operate on the existing response variable and keep the databaseSize string checks, then add the presence guard to fail the test if no internal sizes are present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/client/test_client_stats_meilisearch.py`:
- Around line 39-54: The test test_get_all_stats_with_size_format can silently
skip the internalDatabaseSizes checks if no index contains that key; update the
test to assert the branch is exercised by collecting presence from response
(e.g., use any(...) on response["indexes"].values() to check for
"internalDatabaseSizes") and assert that at least one index contains
internalDatabaseSizes before running the loop that validates HUMAN_SIZE_PATTERN
on those values; operate on the existing response variable and keep the
databaseSize string checks, then add the presence guard to fail the test if no
internal sizes are present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e585e2a7-2f74-4d44-95cb-53d88495ad07
📒 Files selected for processing (6)
.code-samples.meilisearch.yamlmeilisearch/client.pymeilisearch/index.pymeilisearch/models/index.pytests/client/test_client_stats_meilisearch.pytests/index/test_index_stats_meilisearch.py
Address CodeRabbit feedback: fail test_get_all_stats_with_size_format if no index returns internalDatabaseSizes, so human-size checks cannot pass silently.
Strift
left a comment
There was a problem hiding this comment.
Hello @vivek378521, thanks for your PR!
This looks good, but CI is not passing. I suggest you run tests + formatting locally before requesting another review 🙏
…ery-params # Conflicts: # tests/settings/test_settings_embedders.py
|
Hello @Strift I ran all tests locally and now everything looks good. Please review. Thank you for the time. I really appreciate it. :) |
Need to resolve conflicts. |
|
@DhavalGojiya @Strift Resolved merge conflicts. Thanks! |
I think you forgot to run the linter and formatter again for this PR. |
Pull Request
Related issue
Fixes #1234
What does this PR do?
Meilisearch v1.44.0 adds two optional query parameters to
GET /indexes/{indexUid}/statsandGET /stats:showInternalDatabaseSizes— when true, index stat objects include aninternalDatabaseSizesdictionarysizeFormat—"human"for readable sizes (e.g."19.64 MiB") or"raw"for byte counts (default)This PR wires those parameters through the Python SDK:
Index.get_stats()— keyword-onlyshow_internal_database_sizesandsize_formatClient.get_all_stats()— same parametersIndexStats— optionalinternal_database_sizes: Dict[str, Any](loosely typed; keys may change between Meilisearch versions, per API guidance)SizeFormatenum (raw/human) for optional typing onsize_format.code-samples.meilisearch.yaml— updatedget_index_stats_1andget_indexes_stats_1Query params are only sent when the caller provides them (backward compatible). Boolean values are encoded as lowercase
true/false.Example:
PR checklist
Please check if your PR fulfills the following requirements:
Summary by CodeRabbit
New Features
show_internal_database_sizesandsize_format.size_formatcan return raw values or human-readable sizes (e.g.,"human"/RAW/HUMAN).Documentation
Tests
Chores