Skip to content

fix: consistency_level to return human-readable string#3267

Open
veeceey wants to merge 2 commits intomilvus-io:masterfrom
veeceey:fix/issue-2985-consistency-level-human-readable
Open

fix: consistency_level to return human-readable string#3267
veeceey wants to merge 2 commits intomilvus-io:masterfrom
veeceey:fix/issue-2985-consistency-level-human-readable

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 8, 2026

Fixes #2985

Summary

When calling describe_collection(), the consistency_level field was returning a numeric value (0, 1, 2, 3, 4) instead of a human-readable string ("Strong", "Session", "Bounded", "Eventually", "Customized").

This made the output not user-friendly and required users to manually map the integer to its semantic meaning.

Changes

  • Added _consistency_level_to_str() helper method to CollectionSchema class
  • Maps ConsistencyLevel enum integers to their string names
  • Falls back to returning the int if an unknown value is encountered
  • Updated dict() method to use the helper when building the response

Before

{
  'collection_name': 'client_geometry_3yiyc8Bb',
  'consistency_level': 0,  # Not user-friendly!
  ...
}

After

{
  'collection_name': 'client_geometry_3yiyc8Bb', 
  'consistency_level': 'Strong',  # Human-readable!
  ...
}

Test Plan

The fix converts all consistency level enum values correctly:

  • 0"Strong"
  • 1"Session"
  • 2"Bounded"
  • 3"Eventually"
  • 4"Customized"

Existing tests in tests/grpc_handler/test_collection.py verify describe_collection() functionality and will validate this change.

@sre-ci-robot
Copy link

Welcome @veeceey! It looks like this is your first PR to milvus-io/pymilvus 🎉

@veeceey
Copy link
Author

veeceey commented Feb 8, 2026

/assign @longjiquan

@veeceey veeceey force-pushed the fix/issue-2985-consistency-level-human-readable branch from 4eaf8a3 to 9cb3025 Compare February 8, 2026 23:46
@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: veeceey
To complete the pull request process, please ask for approval from longjiquan after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mergify mergify bot added dco-passed and removed needs-dco labels Feb 8, 2026
@veeceey veeceey changed the title Fix consistency_level to return human-readable string fix: consistency_level to return human-readable string Feb 13, 2026
@veeceey
Copy link
Author

veeceey commented Feb 19, 2026

Hi @longjiquan, friendly ping on this PR. It's been open for about 10 days and is awaiting your review/approval. Would appreciate any feedback when you have a moment. Thank you!

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.21%. Comparing base (4297335) to head (9cb3025).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3267   +/-   ##
=======================================
  Coverage   76.21%   76.21%           
=======================================
  Files          63       63           
  Lines       13292    13296    +4     
=======================================
+ Hits        10130    10134    +4     
  Misses       3162     3162           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@XuanYang-cn
Copy link
Contributor

@veeceey Please fix the code checker

@veeceey
Copy link
Author

veeceey commented Mar 10, 2026

On it @XuanYang-cn — looking into the code checker failure now and will push a fix.

@mergify mergify bot added needs-dco and removed dco-passed labels Mar 10, 2026
veeceey added 2 commits March 11, 2026 18:25
…lection

Fixes milvus-io#2985

When calling describe_collection(), the consistency_level field
was returning a numeric value (0, 1, 2, 3, 4) instead of a
human-readable string ("Strong", "Session", "Bounded", "Eventually", "Customized").

This made the output not user-friendly and required users to
manually map the integer to its semantic meaning.

Changes:
- Added _consistency_level_to_str() helper method to CollectionSchema
- Maps ConsistencyLevel enum integers to their string names
- Falls back to returning the int if an unknown value is encountered
- Updated dict() method to use the helper when building the response

Before:
{'consistency_level': 0, ...}

After:
{'consistency_level': 'Strong', ...}

Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
@veeceey veeceey force-pushed the fix/issue-2985-consistency-level-human-readable branch from eb2df71 to 7efb5f7 Compare March 12, 2026 01:25
@veeceey
Copy link
Author

veeceey commented Mar 12, 2026

Fixed -- rebased to add the DCO sign-off that was missing on the second commit. Should be green now.

@mergify mergify bot added dco-passed and removed needs-dco labels Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The value of consistency_level returned by describe collection is a number rather than a corresponding semantic term, which is not user-friendly.

4 participants