Skip to content

Commit 16c5767

Browse files
committed
Format code with black
1 parent a6d8775 commit 16c5767

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

vsb/cmdline_args.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,10 @@ def validate_parsed_args(
525525
parser.error(
526526
"multi_namespace mode requires --skip_populate. Multi-namespace benchmarking only works with existing populated indexes."
527527
)
528-
if getattr(args, "pinecone_namespace_name", "__default__") != "__default__":
528+
if (
529+
getattr(args, "pinecone_namespace_name", "__default__")
530+
!= "__default__"
531+
):
529532
parser.error(
530533
"multi_namespace mode does not support custom namespace names. Use --pinecone_multi_namespace to auto-discover all namespaces."
531534
)

vsb/databases/pinecone/pinecone.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def __init__(
199199
f"PineconeDB: Index '{self.index_name}' does not exist. Multi-namespace mode requires an existing populated index. Please create the index first or use single-namespace mode."
200200
)
201201
raise StopUser()
202-
202+
203203
logger.info(
204204
f"PineconeDB: Specified index '{self.index_name}' was not found, or the "
205205
f"specified API key cannot access it. Creating new index '{self.index_name}'."
@@ -242,22 +242,22 @@ def __init__(
242242

243243
# Initialize namespaces list (empty for both modes to avoid AttributeError)
244244
self.namespaces = []
245-
245+
246246
# Multi-namespace mode: discover and validate namespaces
247247
if self.multi_namespace:
248248
if self.created_index:
249249
logger.critical(
250250
f"PineconeDB: Cannot use multi_namespace mode with a newly created index. Index '{self.index_name}' must already exist and be populated."
251251
)
252252
raise StopUser()
253-
253+
254254
self.namespaces = self._discover_all_namespaces()
255255
if not self.namespaces:
256256
logger.critical(
257257
f"PineconeDB: No populated namespaces found in index '{self.index_name}'. Multi-namespace mode requires at least one namespace with records."
258258
)
259259
raise StopUser()
260-
260+
261261
logger.info(
262262
f"PineconeDB: Discovered {len(self.namespaces)} namespaces: {', '.join(self.namespaces)}"
263263
)
@@ -381,12 +381,12 @@ def _discover_all_namespaces(self) -> list[str]:
381381
raise ValueError(
382382
f"Failed to list namespaces in index '{self.index_name}': {e}"
383383
) from e
384-
384+
385385
if not populated_namespaces:
386386
raise ValueError(
387387
f"No populated namespaces found in index '{self.index_name}'. Multi-namespace mode requires at least one namespace with records."
388388
)
389-
389+
390390
return sorted(populated_namespaces)
391391

392392
def _get_namespaces_for_user(self, user_id: int, num_users: int) -> list[str]:
@@ -395,7 +395,9 @@ def _get_namespaces_for_user(self, user_id: int, num_users: int) -> list[str]:
395395
raise ValueError(
396396
f"Cannot distribute {num_users} users across {len(self.namespaces)} namespaces. Number of users must be <= number of namespaces."
397397
)
398-
return [self.namespaces[i] for i in range(user_id, len(self.namespaces), num_users)]
398+
return [
399+
self.namespaces[i] for i in range(user_id, len(self.namespaces), num_users)
400+
]
399401

400402
def check_namespace_exists(self, namespace: str) -> bool:
401403
"""Check if a namespace exists inside the current index using list_namespaces generator."""

vsb/users.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ def __init__(self, environment):
250250
f"Initialising RunUser id:{self.user_id}, target request/sec:{target_throughput}"
251251
)
252252
self.query_iter = None
253-
253+
254254
# Multi-namespace mode: get namespaces assigned to this user
255-
if hasattr(self.database, 'multi_namespace') and self.database.multi_namespace:
255+
if hasattr(self.database, "multi_namespace") and self.database.multi_namespace:
256256
self.user_namespaces = self.database._get_namespaces_for_user(
257257
self.user_id, self.users_total
258258
)
@@ -291,9 +291,13 @@ def do_run(self):
291291
base_iter = self.workload.get_query_iter(
292292
self.users_total, self.user_id, batch_size
293293
)
294-
294+
295295
# Multi-namespace mode: wrap iterator to inject namespace names
296-
if hasattr(self.database, 'multi_namespace') and self.database.multi_namespace:
296+
if (
297+
hasattr(self.database, "multi_namespace")
298+
and self.database.multi_namespace
299+
):
300+
297301
def namespace_wrapper():
298302
for tenant, request in base_iter:
299303
# Select next namespace using round-robin
@@ -302,6 +306,7 @@ def namespace_wrapper():
302306
]
303307
self.namespace_index += 1
304308
yield (namespace, request)
309+
305310
self.query_iter = namespace_wrapper()
306311
else:
307312
# Single namespace mode: use iterator as-is

0 commit comments

Comments
 (0)