|
10 | 10 | """ |
11 | 11 | import re |
12 | 12 | import sys |
13 | | -import warnings |
14 | 13 | from dataclasses import dataclass |
15 | 14 | from typing import Optional |
16 | 15 |
|
@@ -353,83 +352,6 @@ def create_pyseekdb_client(params: Optional[ConnectionParams] = None): # type: |
353 | 352 | return client |
354 | 353 |
|
355 | 354 |
|
356 | | -# Default values for deprecated vector memory parameters |
357 | | -_DEFAULT_VECTOR_MEMORY_LIMIT_PERCENTAGE = 30 |
358 | | -_DEFAULT_QUERY_TIMEOUT = 100000000 |
359 | | - |
360 | | - |
361 | | -def ensure_vector_memory_params( |
362 | | - client, # pyseekdb.Client - type ignored due to library typing issues |
363 | | - memory_limit_percentage: int = _DEFAULT_VECTOR_MEMORY_LIMIT_PERCENTAGE, |
364 | | - query_timeout: int = _DEFAULT_QUERY_TIMEOUT, |
365 | | -) -> None: |
366 | | - """ |
367 | | - Ensure vector memory parameters are properly configured. |
368 | | -
|
369 | | - .. deprecated:: |
370 | | - This function is deprecated and will be removed in a future version. |
371 | | - Database parameters should be configured at the infrastructure level, |
372 | | - not in application code. |
373 | | -
|
374 | | - Checks and sets the ob_vector_memory_limit_percentage parameter if needed, |
375 | | - and sets the ob_query_timeout for the session. |
376 | | -
|
377 | | - Args: |
378 | | - client: pyseekdb client instance |
379 | | - memory_limit_percentage: Target value for ob_vector_memory_limit_percentage |
380 | | - query_timeout: Query timeout in microseconds |
381 | | -
|
382 | | - Raises: |
383 | | - RuntimeError: If parameter check or setting fails |
384 | | - """ |
385 | | - warnings.warn( |
386 | | - "ensure_vector_memory_params is deprecated and will be removed in a future version. " |
387 | | - "Database parameters should be configured at the infrastructure level.", |
388 | | - DeprecationWarning, |
389 | | - stacklevel=2, |
390 | | - ) |
391 | | - |
392 | | - logger.info("Checking and setting database parameters") |
393 | | - |
394 | | - # Check ob_vector_memory_limit_percentage |
395 | | - vals = [] |
396 | | - params = client.execute( |
397 | | - "SHOW PARAMETERS LIKE '%ob_vector_memory_limit_percentage%'" |
398 | | - ) |
399 | | - for row in params: |
400 | | - val = int(row[6]) |
401 | | - vals.append(val) |
402 | | - |
403 | | - if len(vals) == 0: |
404 | | - logger.error("ob_vector_memory_limit_percentage not found in parameters.") |
405 | | - raise RuntimeError("ob_vector_memory_limit_percentage not found in parameters.") |
406 | | - |
407 | | - # Set ob_vector_memory_limit_percentage if any value is 0 |
408 | | - if any(val == 0 for val in vals): |
409 | | - try: |
410 | | - logger.info( |
411 | | - f"Setting ob_vector_memory_limit_percentage to {memory_limit_percentage}" |
412 | | - ) |
413 | | - client.execute( |
414 | | - f"ALTER SYSTEM SET ob_vector_memory_limit_percentage = {memory_limit_percentage}" |
415 | | - ) |
416 | | - logger.info( |
417 | | - f"Successfully set ob_vector_memory_limit_percentage to {memory_limit_percentage}" |
418 | | - ) |
419 | | - except Exception as e: |
420 | | - logger.error( |
421 | | - f"Failed to set ob_vector_memory_limit_percentage to {memory_limit_percentage}: {e}" |
422 | | - ) |
423 | | - raise RuntimeError( |
424 | | - f"Failed to set ob_vector_memory_limit_percentage: {e}" |
425 | | - ) from e |
426 | | - |
427 | | - # Set query timeout |
428 | | - logger.info(f"Setting ob_query_timeout to {query_timeout}") |
429 | | - client.execute(f"SET ob_query_timeout={query_timeout}") |
430 | | - logger.debug("Database parameters configured successfully") |
431 | | - |
432 | | - |
433 | 355 | # ============================================================================= |
434 | 356 | # CLI Functions |
435 | 357 | # ============================================================================= |
|
0 commit comments