Skip to content

fix(async): from_system_async() now binds to the provided system#6884

Open
peteroyce wants to merge 1 commit intochroma-core:mainfrom
peteroyce:fix/from-system-async-reuse-system
Open

fix(async): from_system_async() now binds to the provided system#6884
peteroyce wants to merge 1 commit intochroma-core:mainfrom
peteroyce:fix/from-system-async-reuse-system

Conversation

@peteroyce
Copy link
Copy Markdown

Summary

AsyncClient.from_system_async(system, ...) was ignoring the system argument and creating a fresh client stack from system.settings. This violated the documented contract ("create a client from an existing system") and was inconsistent with the sync Client.from_system().

Root Cause

The sync from_system() calls SharedSystemClient._populate_data_from_system(system) before constructing the client, which caches the existing System object. Subsequent create() calls then find and reuse that cached system via its identifier.

The async version skipped this step, so AsyncClient.create() always spun up a brand new system, giving the client a different UUID than the one passed in.

# Before (broken — ignores system)
async def from_system_async(cls, system, tenant=..., database=...) -> "AsyncClient":
    return await AsyncClient.create(tenant, database, system.settings)

# After (fixed — matches sync behaviour)
async def from_system_async(cls, system, tenant=..., database=...) -> "AsyncClient":
    SharedSystemClient._populate_data_from_system(system)
    return await AsyncClient.create(tenant, database, system.settings)

Changes

  • chromadb/api/async_client.py: add SharedSystemClient._populate_data_from_system(system) call before AsyncClient.create(), mirroring the sync Client.from_system() implementation

Closes #6871

AsyncClient.from_system_async() was calling AsyncClient.create() with
system.settings, which creates a fresh client stack and assigns a new
UUID identifier — ignoring the actual system object passed in.

The sync Client.from_system() calls _populate_data_from_system(system)
first, which caches the existing system so subsequent create() calls
reuse it. Adding the same call to from_system_async() aligns the async
implementation with its sync counterpart.

Closes chroma-core#6871
@github-actions
Copy link
Copy Markdown

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)

@propel-code-bot
Copy link
Copy Markdown
Contributor

Fix AsyncClient.from_system_async() to reuse provided System instance

This PR fixes a behavior bug in chromadb/api/async_client.py where AsyncClient.from_system_async() previously ignored the passed system object and effectively created a new client stack from system.settings. The method now first calls SharedSystemClient._populate_data_from_system(system) before invoking AsyncClient.create(...), matching the sync path behavior.

The change restores the documented contract of creating a client from an existing system and aligns async and sync semantics, preventing unintended creation of a different underlying system identity when a caller explicitly provides one.

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

Copy link
Copy Markdown
Contributor

@propel-code-bot propel-code-bot bot left a comment

Choose a reason for hiding this comment

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

Review found no issues; the async system-binding fix appears correct and low risk.

Status: No Issues Found | Risk: Low

Review Details

📁 1 files reviewed | 💬 0 comments

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.

[Bug]: from_system_async() builds a fresh client system instead of reusing the provided one

1 participant