feat: add ChromaDB hosting and client integrations#1132
feat: add ChromaDB hosting and client integrations#1132ali-Hamza817 wants to merge 6 commits intoCommunityToolkit:mainfrom
Conversation
This contribution adds support for ChromaDB as a .NET Aspire resource, including: - Hosting integration for containerized ChromaDB - Client integration with health checks and keyed service support - Persistence support via volumes and bind mounts - Comprehensive unit tests and documentation
|
@dotnet-policy-service agree |
aaronpowell
left a comment
There was a problem hiding this comment.
We need to have an example app included as part of the PR and a test covering that the sample starts and the resource becomes health.
Ideally, the sample should also actually use Chroma, so some kind of basic CRUD just to allow for more advanced testing and demonstrations.
You also need to add the test projects to the tests.yml workflow - we have a script in eng that will generate the properly formatted test list if you'd like.
But overall, a solid looking integration set.
There was a problem hiding this comment.
This file is auto-generated on merging to main, so it should be removed.
|
|
||
| private static ChromaClient CreateClient(IServiceProvider sp, ChromaClientSettings settings, string connectionName) | ||
| { | ||
| if (settings.Endpoint == null) |
There was a problem hiding this comment.
| if (settings.Endpoint == null) | |
| if (settings.Endpoint is null) |
There was a problem hiding this comment.
This file is generated when merging to main so it should be removed.
| public ChromaResource(string name) : base(name) | ||
| { | ||
| } |
There was a problem hiding this comment.
Can you use a primary constructor to be consistent with the coding style
- Removed auto-generated api files. - Refactored ChromaResource to use a primary constructor. - Corrected style for null checks (is null). - Added example app with CRUD operations in examples/chromadb. - Added integration tests for health and CRUD verification. - Updated tests.yml workflow to include new tests.
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive ChromaDB hosting and client integrations to the Aspire Community Toolkit, enabling developers to easily orchestrate and consume ChromaDB vector database services in their .NET Aspire applications.
Changes:
- New hosting integration package (CommunityToolkit.Aspire.Hosting.Chroma) providing resource orchestration for ChromaDB containers with configurable persistence options
- New client integration package (CommunityToolkit.Aspire.Chroma) providing ChromaClient registration with health checks and configuration support
- Comprehensive test coverage including unit tests, integration tests, and AppHost tests
- Example application demonstrating end-to-end usage with collection creation and querying
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CommunityToolkit.Aspire.Hosting.Chroma/ChromaResource.cs | Defines the ChromaDB container resource with connection string support |
| src/CommunityToolkit.Aspire.Hosting.Chroma/ChromaBuilderExtensions.cs | Provides AddChroma extension method and persistence configuration helpers |
| src/CommunityToolkit.Aspire.Hosting.Chroma/ChromaContainerImageTags.cs | Defines ChromaDB container image details (chromadb/chroma:0.5.0) |
| src/CommunityToolkit.Aspire.Chroma/AspireChromaExtensions.cs | Implements ChromaClient DI registration with keyed service support |
| src/CommunityToolkit.Aspire.Chroma/ChromaHealthCheck.cs | Provides health check implementation using GetVersion API |
| src/CommunityToolkit.Aspire.Chroma/ChromaClientSettings.cs | Configuration model supporting endpoint, health checks, and timeout settings |
| tests/CommunityToolkit.Aspire.Hosting.Chroma.Tests/AddChromaTests.cs | Unit tests for hosting resource configuration and annotations |
| tests/CommunityToolkit.Aspire.Hosting.Chroma.Tests/AppHostTests.cs | Integration tests verifying ChromaDB startup and API service interaction |
| tests/CommunityToolkit.Aspire.Chroma.Tests/ChromaClientExtensionsTests.cs | Unit tests for client registration and health check behavior |
| examples/chromadb/CommunityToolkit.Aspire.Hosting.Chroma.AppHost/Program.cs | Example AppHost orchestrating ChromaDB and API service |
| examples/chromadb/CommunityToolkit.Aspire.Hosting.Chroma.ApiService/Program.cs | Example API service demonstrating ChromaDB operations |
| Directory.Packages.props | Adds ChromaDB.Client 1.0.0 package reference |
| CommunityToolkit.Aspire.slnx | Adds new projects to solution |
| .github/workflows/tests.yaml | Adds test projects to CI workflow |
| public bool DisableHealthChecks { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a integer value that indicates the ChromaDB health check timeout in milliseconds. |
There was a problem hiding this comment.
Grammar issue: "a integer" should be "an integer".
| /// Gets or sets a integer value that indicates the ChromaDB health check timeout in milliseconds. | |
| /// Gets or sets an integer value that indicates the ChromaDB health check timeout in milliseconds. |
|
|
||
| namespace CommunityToolkit.Aspire.Chroma.Tests; | ||
|
|
||
| public class AspireChromaClientExtensionsTests |
There was a problem hiding this comment.
The class name AspireChromaClientExtensionsTests does not match the file name ChromaClientExtensionsTests.cs. For consistency with the codebase (e.g., AspireMeilisearchClientExtensionsTest), consider either:
- Renaming the class to
ChromaClientExtensionsTeststo match the file name, or - Renaming the file to
AspireChromaClientExtensionsTests.csto match the class name.
The former approach (matching the file name without the "Aspire" prefix) appears more common in client integration tests.
| public class AspireChromaClientExtensionsTests | |
| public class ChromaClientExtensionsTests |
aaronpowell
left a comment
There was a problem hiding this comment.
Code-wise, this looks great, thanks for the contribution!
aaronpowell
left a comment
There was a problem hiding this comment.
Just some test failures and then it should be good to merge
| var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| appBuilder.AddChroma("chroma") | ||
| .WithDataBindMount("C:/chroma/data"); |
There was a problem hiding this comment.
You'll need to set a relative path here so it doesn't error on CI
…Settings.json for ApiService
|
Looks like is still failing |
|
@aaronpowell |
Pull Request: Add ChromaDB Hosting and Client Integrations
Summary
This PR adds a new hosting and client integration for ChromaDB, an open-source vector database essential for AI and RAG applications.
Features
builder.AddChroma("chroma").ChromaClientin your application viabuilder.AddChromaClient("chroma").builder.AddKeyedChromaClient("chroma").GetVersion()API.PR Checklist
Additional information
Verified with 8 unit tests covering hosting resource creation, endpoint configuration, persistence volumes, DI registration, and health checks.