Skip to content

Conversation

@Sicheng-Pan
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan commented Sep 17, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • N/A
  • New functionality
    • Implement a rows method for the search result
    • Add a test for this

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

Copy link
Contributor Author

Sicheng-Pan commented Sep 17, 2025

@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@Sicheng-Pan Sicheng-Pan marked this pull request as ready for review September 17, 2025 22:11
@propel-code-bot
Copy link
Contributor

Implement rows Iterator for SearchResult and Associated Tests

This pull request adds a rows method to the SearchResult object, enabling users to iterate over search results in a row-major (record-wise) structure instead of the default column-major format. The new method converts column-oriented search results into a list of dictionaries, each containing all available fields for a particular result, which improves consumption and downstream processing of search results. Supporting changes include a new SearchResultRow type, updates to the SearchResult API type, changes in chromadb/api/fastapi.py and chromadb/api/async_fastapi.py to instantiate SearchResult correctly, and comprehensive testing in chromadb/test/test_api.py.

Key Changes

• Introduced SearchResultRow TypedDict, defining the schema for a single result row.
• Refactored SearchResult from a TypedDict to a dictionary subclass with a .rows() method for row-major conversion.
• Added the .rows() method to SearchResult, implementing column-to-row transformation logic.
• Updated exports in chromadb/api/types.py to include the new SearchResultRow.
• Patched chromadb/api/fastapi.py and chromadb/api/async_fastapi.py to instantiate SearchResult from server response dictionaries for backward compatibility.
• Added extensive unit tests in chromadb/test/test_api.py to validate various use-cases and edge cases for the new rows() API.

Affected Areas

chromadb/api/types.py (API types, result conversion logic)
chromadb/api/fastapi.py and chromadb/api/async_fastapi.py (client/server response wrapping)
chromadb/test/test_api.py (new and updated tests for SearchResult.rows)

This summary was automatically generated by @propel-code-bot

Copy link
Contributor Author

Sicheng-Pan commented Sep 23, 2025

Merge activity

  • Sep 23, 12:17 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Sep 23, 12:17 AM UTC: @Sicheng-Pan merged this pull request with Graphite.

@Sicheng-Pan Sicheng-Pan merged commit ea4c7f4 into main Sep 23, 2025
61 checks passed
@Sicheng-Pan Sicheng-Pan deleted the 09-17-_enh_implement_row_iterator_for_search_result branch September 23, 2025 00:23
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.

3 participants