Skip to content

Commit 997d241

Browse files
committed
chore: Removing get_client and coupling to Python client
1 parent c511cf0 commit 997d241

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

modules/chroma/testcontainers/chroma/__init__.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import TYPE_CHECKING
22

3-
import chromadb
43
from requests import ConnectionError, get
54

65
from testcontainers.core.container import DockerContainer
@@ -49,17 +48,6 @@ def __init__(
4948
self.with_exposed_ports(self.port)
5049
# self.with_command(f"server /data --address :{self.port}")
5150

52-
def get_client(self, **kwargs) -> chromadb.ClientAPI:
53-
"""Returns a Chroma HttpClient to connect to the container.
54-
55-
Returns:
56-
HttpClient: Chroma HttpClient according to
57-
https://docs.trychroma.com/reference/Client#httpclient
58-
"""
59-
host_ip = self.get_container_host_ip()
60-
exposed_port = self.get_exposed_port(self.port)
61-
return chromadb.HttpClient(host=host_ip, port=int(exposed_port))
62-
6351
def get_config(self) -> dict:
6452
"""This method returns the configuration of the Chroma container,
6553
including the endpoint.
@@ -71,6 +59,8 @@ def get_config(self) -> dict:
7159
exposed_port = self.get_exposed_port(self.port)
7260
return {
7361
"endpoint": f"{host_ip}:{exposed_port}",
62+
"host": host_ip,
63+
"port": exposed_port,
7464
}
7565

7666
@wait_container_is_ready(ConnectionError)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from testcontainers.chroma import ChromaContainer
2+
import chromadb
23

34

45
def test_docker_run_chroma():
56
with ChromaContainer(image="chromadb/chroma:0.4.24") as chroma:
6-
client = chroma.get_client()
7+
client = chromadb.HttpClient(host=chroma.get_config()["host"], port=chroma.get_config()["port"])
78
col = client.get_or_create_collection("test")
89
assert col.name == "test"

0 commit comments

Comments
 (0)