Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.6
rev: v0.14.2
hooks:
# Run the linter.
- id: ruff
Expand Down
21 changes: 12 additions & 9 deletions src/vdf_io/import_vdf/astradb_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def upsert_data(self, via_cql=False):
data_path = namespace_meta["data_path"]
final_data_path = self.get_final_data_path(data_path)
new_index_name = index_name + (
f'_{namespace_meta["namespace"]}'
f"_{namespace_meta['namespace']}"
if namespace_meta["namespace"]
else ""
)
Expand Down Expand Up @@ -162,7 +162,7 @@ def upsert_data(self, via_cql=False):

self.session.execute(
f"CREATE TABLE IF NOT EXISTS {self.args['keyspace']}.{new_index_name}"
f" (id text PRIMARY KEY, \"$vector\" vector<float,{namespace_meta['dimensions']}>)"
f' (id text PRIMARY KEY, "$vector" vector<float,{namespace_meta["dimensions"]}>)'
)
parquet_files = self.get_parquet_files(final_data_path)
vectors = {}
Expand Down Expand Up @@ -208,7 +208,7 @@ def flush_to_db(self, vectors, metadata, collection, via_cql, parallel=True):
keys = list(set(vectors.keys()).union(set(metadata.keys())))
for id in keys:
self.session.execute(
f"INSERT INTO {self.args['keyspace']}.{collection.name} (id, \"$vector\", {', '.join(metadata[id].keys())}) "
f'INSERT INTO {self.args["keyspace"]}.{collection.name} (id, "$vector", {", ".join(metadata[id].keys())}) '
f"VALUES ('{id}', {vectors[id]}, {', '.join([str(v) for v in metadata[id].values()])})"
)
return len(vectors)
Expand Down Expand Up @@ -248,12 +248,15 @@ def flush_batch_to_db(collection, keys, vectors, metadata):
for i in range(0, total_points, BATCH_SIZE)
]

with concurrent.futures.ThreadPoolExecutor(
max_workers=num_parallel_threads
) as executor, tqdm(
total=total_points,
desc=f"Flushing to DB in batches of {BATCH_SIZE} in {num_parallel_threads} threads",
) as pbar:
with (
concurrent.futures.ThreadPoolExecutor(
max_workers=num_parallel_threads
) as executor,
tqdm(
total=total_points,
desc=f"Flushing to DB in batches of {BATCH_SIZE} in {num_parallel_threads} threads",
) as pbar,
):
future_to_batch = {
executor.submit(flush_batch_to_db, collection, *batch): batch
for batch in batches
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_io/import_vdf/chroma_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def upsert_data(self):
parquet_files = self.get_parquet_files(final_data_path)

new_index_name = index_name + (
f'_{namespace_meta["namespace"]}'
f"_{namespace_meta['namespace']}"
if namespace_meta["namespace"]
else ""
)
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_io/import_vdf/kdbai_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def upsert_data(self):
data_path = namespace_meta["data_path"]
final_data_path = self.get_final_data_path(data_path)
index_name = index_name + (
f'_{namespace_meta["namespace"]}'
f"_{namespace_meta['namespace']}"
if namespace_meta["namespace"]
else ""
)
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_io/import_vdf/lancedb_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def upsert_data(self):
parquet_files = self.get_parquet_files(final_data_path)

new_index_name = index_name + (
f'_{namespace_meta["namespace"]}'
f"_{namespace_meta['namespace']}"
if namespace_meta["namespace"]
else ""
)
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_io/import_vdf/milvus_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def upsert_data(self):
self.set_dims(namespace_meta, collection_name)
data_path = namespace_meta["data_path"]
index_name = collection_name + (
f'_{namespace_meta["namespace"]}'
f"_{namespace_meta['namespace']}"
if namespace_meta["namespace"]
else ""
)
Expand Down
15 changes: 9 additions & 6 deletions src/vdf_io/import_vdf/qdrant_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,15 @@ def get_nested_config(config, keys, default=None):
total_points = len(points)

num_parallel_threads = self.args.get("parallel", 5) or 5
with concurrent.futures.ThreadPoolExecutor(
max_workers=num_parallel_threads
) as executor, tqdm(
total=total_points,
desc=f"Uploading points in batches of {BATCH_SIZE} in {num_parallel_threads} threads",
) as pbar:
with (
concurrent.futures.ThreadPoolExecutor(
max_workers=num_parallel_threads
) as executor,
tqdm(
total=total_points,
desc=f"Uploading points in batches of {BATCH_SIZE} in {num_parallel_threads} threads",
) as pbar,
):
# Create a future to batch mapping to update progress bar correctly after each batch completion
future_to_batch = {
executor.submit(
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_io/import_vdf/turbopuffer_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def upsert_data(self):
parquet_files = self.get_parquet_files(final_data_path)

new_index_name = index_name + (
f'_{namespace_meta["namespace"]}'
f"_{namespace_meta['namespace']}"
if namespace_meta["namespace"]
else ""
)
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_io/marqo_vespa_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_all_documents(
[f"{key}={value}" for key, value in query_params.items() if value]
)
url = f"{self.document_url}/document/v1/{schema}/{schema}/docid"
url = f'{url.strip("?")}?{query_string}'
url = f"{url.strip('?')}?{query_string}"
print(f"{url=}")
resp = self.http_client.get(url)
except httpx.HTTPError as e:
Expand Down
Loading