llama-index-vector-stores-postgres 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-vector-stores-postgres
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: llama-index vector_stores postgres integration
5
5
  License: MIT
6
6
  Author: Your Name
@@ -149,6 +149,7 @@ class PGVectorStore(BasePydanticVectorStore):
149
149
  debug: bool
150
150
  use_jsonb: bool
151
151
  create_engine_kwargs: Dict
152
+ initialization_fail_on_error: bool = False
152
153
 
153
154
  hnsw_kwargs: Optional[Dict[str, Any]]
154
155
 
@@ -175,6 +176,7 @@ class PGVectorStore(BasePydanticVectorStore):
175
176
  use_jsonb: bool = False,
176
177
  hnsw_kwargs: Optional[Dict[str, Any]] = None,
177
178
  create_engine_kwargs: Optional[Dict[str, Any]] = None,
179
+ initialization_fail_on_error: bool = False,
178
180
  ) -> None:
179
181
  """Constructor.
180
182
 
@@ -220,6 +222,7 @@ class PGVectorStore(BasePydanticVectorStore):
220
222
  use_jsonb=use_jsonb,
221
223
  hnsw_kwargs=hnsw_kwargs,
222
224
  create_engine_kwargs=create_engine_kwargs or {},
225
+ initialization_fail_on_error=initialization_fail_on_error,
223
226
  )
224
227
 
225
228
  # sqlalchemy model
@@ -405,17 +408,35 @@ class PGVectorStore(BasePydanticVectorStore):
405
408
  session.commit()
406
409
 
407
410
  def _initialize(self) -> None:
411
+ fail_on_error = self.initialization_fail_on_error
408
412
  if not self._is_initialized:
409
413
  self._connect()
410
414
  if self.perform_setup:
411
- schema_created = self._create_schema_if_not_exists()
412
- if not schema_created:
413
- self._is_initialized = True
414
- return # Skip table creation if schema already existed
415
- self._create_extension()
416
- self._create_tables_if_not_exists()
415
+ try:
416
+ self._create_schema_if_not_exists()
417
+ except Exception as e:
418
+ _logger.warning(f"PG Setup: Error creating schema: {e}")
419
+ if fail_on_error:
420
+ raise
421
+ try:
422
+ self._create_extension()
423
+ except Exception as e:
424
+ _logger.warning(f"PG Setup: Error creating extension: {e}")
425
+ if fail_on_error:
426
+ raise
427
+ try:
428
+ self._create_tables_if_not_exists()
429
+ except Exception as e:
430
+ _logger.warning(f"PG Setup: Error creating tables: {e}")
431
+ if fail_on_error:
432
+ raise
417
433
  if self.hnsw_kwargs is not None:
418
- self._create_hnsw_index()
434
+ try:
435
+ self._create_hnsw_index()
436
+ except Exception as e:
437
+ _logger.warning(f"PG Setup: Error creating HNSW index: {e}")
438
+ if fail_on_error:
439
+ raise
419
440
  self._is_initialized = True
420
441
 
421
442
  def _node_to_table_row(self, node: BaseNode) -> Any:
@@ -27,7 +27,7 @@ exclude = ["**/BUILD"]
27
27
  license = "MIT"
28
28
  name = "llama-index-vector-stores-postgres"
29
29
  readme = "README.md"
30
- version = "0.3.1"
30
+ version = "0.3.2"
31
31
 
32
32
  [tool.poetry.dependencies]
33
33
  python = ">=3.9,<4.0"