Skip to content

Commit 91ba4d0

Browse files
authored
fix epithermal sideeffect during retirement (#21)
* fix epthermal sideeffect during retirement * Update tests/steps/qdrant/e2e_test.py
1 parent 64fa849 commit 91ba4d0

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

tests/steps/qdrant/e2e_test.py

+41-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pytest
1313

1414
# qdrant-Lite; See: https://qdrant.io/docs/qdrant_lite.md
15-
from qdrant_client import QdrantClient
15+
from qdrant_client import QdrantClient, models
1616

1717
from wurzel.exceptions import StepFailed
1818
from wurzel.step_executor import BaseStepExecutor
@@ -95,6 +95,46 @@ def test_qdrant_collection_retirement(
9595
)
9696

9797

98+
def test_qdrant_get_collections_with_ephemerals(
99+
input_output_folder: Tuple[Path, Path], env, dummy_collection
100+
):
101+
input_path, output_path = input_output_folder
102+
HIST_LEN = 3
103+
env.set("COLLECTION_HISTORY_LEN", str(HIST_LEN))
104+
env.set("COLLECTION", "tenant1-dev")
105+
input_file = input_path / "qdrant_at.csv"
106+
shutil.copy("./tests/data/embedded.csv", input_file)
107+
client = QdrantClient(location=":memory:")
108+
{
109+
client.create_collection(
110+
coll,
111+
vectors_config=models.VectorParams(
112+
size=100, distance=models.Distance.COSINE
113+
),
114+
)
115+
for coll in [
116+
"tenant1-dev_v1",
117+
"tenant1-dev_v2",
118+
"tenant1-dev_v3",
119+
"tenant1-dev-feature-abc_v1",
120+
]
121+
}
122+
123+
client.close = print
124+
with unittest.mock.patch("wurzel.steps.qdrant.step.QdrantClient") as mock:
125+
mock.return_value = client
126+
step = QdrantConnectorStep()
127+
result = step._get_collection_versions()
128+
assert len(result) == 3
129+
assert set(result.keys()) == {1, 2, 3}
130+
131+
env.set("COLLECTION", "tenant1-dev-feature-abc")
132+
step = QdrantConnectorStep()
133+
result = step._get_collection_versions()
134+
assert len(result) == 1
135+
assert set(result.keys()) == {1}
136+
137+
98138
def test_qdrant_connector_csv_partially_not_same_shape(
99139
input_output_folder: Tuple[Path, Path],
100140
):

wurzel/steps/qdrant/step.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,6 @@ def _get_collection_versions(self) -> dict[int, str]:
210210
versioned_collections = {
211211
int(previous.name.split("_v")[-1]): previous.name
212212
for previous in previous_collections
213-
if self.settings.COLLECTION in previous.name
213+
if f"{self.settings.COLLECTION}_v" in previous.name
214214
}
215215
return dict(sorted(versioned_collections.items()))

0 commit comments

Comments
 (0)