-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
While building for nixpkgs, TestEmbeddingFunctionSchemas.test_embedding_function_config_roundtrip[simple_ef] fails with:
E AssertionError: Configs don't match after recreation for simple_ef
E assert <MagicMock na...727821456000'> == {'dim': <Magi...33900358720'>}
E
E Full diff:
E + <MagicMock name='mock.get_config()' id='140727821456000'>
E - {
E - 'dim': <MagicMock name='mock.get_config().__getitem__()' id='140733900358720'>,
E - }Versions
Chromadb 1.3.6, Python 3.13.9, on x86_64-Linux and aarch64-Darwin
Relevant log output
_ TestEmbeddingFunctionSchemas.test_embedding_function_config_roundtrip[simple_ef] _
[gw2] linux -- Python 3.12.12 /nix/store/fdibxyh7xcmqrc172y78awzhxs292gq1-python3-3.12.12/bin/python3.12
self = <test_embedding_function_schemas.TestEmbeddingFunctionSchemas object at 0x7fff29356360>
ef_name = 'simple_ef'
mock_embeddings = <function mock_embeddings.<locals>._mock_embeddings at 0x7ffdbfcc62a0>
mock_common_deps = <_pytest.monkeypatch.MonkeyPatch object at 0x7ffdbfced670>
@pytest.mark.parametrize("ef_name", get_embedding_function_names())
def test_embedding_function_config_roundtrip(
self,
ef_name: str,
mock_embeddings: Callable[[Documents], Embeddings],
mock_common_deps: MonkeyPatch,
) -> None:
"""Test embedding function configuration roundtrip"""
ef_class = known_embedding_functions[ef_name]
# Create an autospec of the embedding function class
mock_ef = create_autospec(ef_class, instance=True)
# Mock the __call__ method
mock_call = MagicMock(return_value=mock_embeddings(["test"]))
mock_ef.__call__ = mock_call
# For chroma-cloud-qwen, mock get_config to return valid data
if ef_name == "chroma-cloud-qwen":
from chromadb.utils.embedding_functions.chroma_cloud_qwen_embedding_function import (
ChromaCloudQwenEmbeddingModel,
CHROMA_CLOUD_QWEN_DEFAULT_INSTRUCTIONS,
)
mock_ef.get_config.return_value = {
"api_key_env_var": "CHROMA_API_KEY",
"model": ChromaCloudQwenEmbeddingModel.QWEN3_EMBEDDING_0p6B.value,
"task": "nl_to_code",
"instructions": CHROMA_CLOUD_QWEN_DEFAULT_INSTRUCTIONS,
}
# Mock the class constructor to return our mock instance
mock_common_deps.setattr(
ef_class, "__new__", lambda cls, *args, **kwargs: mock_ef
)
# Create instance with minimal args (constructor will be mocked)
ef_instance = ef_class()
# Get the config (this will use the real method)
config = ef_instance.get_config()
# Test recreation from config
new_instance = ef_class.build_from_config(config)
new_config = new_instance.get_config()
# Configs should match
> assert (
config == new_config
), f"Configs don't match after recreation for {ef_name}"
E AssertionError: Configs don't match after recreation for simple_ef
E assert <MagicMock na...727821456000'> == {'dim': <Magi...33900358720'>}
E
E Full diff:
E + <MagicMock name='mock.get_config()' id='140727821456000'>
E - {
E - 'dim': <MagicMock name='mock.get_config().__getitem__()' id='140733900358720'>,
E - }
chromadb/test/utils/test_embedding_function_schemas.py:82: AssertionErrorReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working