mirror of
https://github.com/qdrant/qdrant-client.git
synced 2026-07-31 23:20:54 -05:00
* deprecated recreate_collection from tests * checked if collection exists before deletion * reverted deletion of recreate_collection * added missing collection_exsits before deletion * nit if condition * fix type hint in local_collection * removed run mypy on async client generator * added checks for create_collection if exists * nit change collection name * add else to create_collection * nit * nit * refactoring: remove redundant checks * fix: do not test collection_exists through itself * refactoring: remove redundant collection exists checks * fix: remove redundant collection exists checks * refactoring: remove redundant collection checks * refactoring: remove redundant collection existence check in test sparse search * refactoring: remove redundant checks in test_updates * refactoring: remove redundant checks * fix: remove redundant checks * refactoring: remove redundant checks * refactoring: remove redundant imports * new: add recreate collection test --------- Co-authored-by: George Panchuk <george.panchuk@qdrant.tech>
50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
import time
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from qdrant_client import QdrantClient
|
|
from qdrant_client.http.models import Distance, VectorParams
|
|
|
|
COLLECTION_NAME = "test_rest_upload"
|
|
VECTOR_SIZE = 256
|
|
BATCH_SIZE = 64
|
|
|
|
|
|
def get_data(num_vectors: int):
|
|
return np.random.rand(num_vectors, VECTOR_SIZE)
|
|
|
|
|
|
def prepare_collection_rest():
|
|
client = QdrantClient(timeout=30)
|
|
if client.collection_exists(COLLECTION_NAME):
|
|
client.delete_collection(COLLECTION_NAME)
|
|
client.create_collection(
|
|
COLLECTION_NAME,
|
|
vectors_config=VectorParams(size=VECTOR_SIZE, distance=Distance.COSINE),
|
|
)
|
|
|
|
|
|
def upload_data(data):
|
|
client = QdrantClient(timeout=30)
|
|
client.upload_collection(
|
|
collection_name=COLLECTION_NAME,
|
|
vectors=data,
|
|
payload=None,
|
|
ids=None,
|
|
batch_size=BATCH_SIZE,
|
|
parallel=2,
|
|
)
|
|
|
|
|
|
@pytest.mark.skip(reason="skip slow benchmark")
|
|
def test_rest_upload():
|
|
print("")
|
|
prepare_collection_rest()
|
|
|
|
data = get_data(num_vectors=50_000)
|
|
start = time.time()
|
|
upload_data(data)
|
|
end = time.time()
|
|
print("Elapsed", end - start)
|