norm_toolkit 1.0.1__tar.gz → 1.0.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.
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/PKG-INFO +1 -1
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/pyproject.toml +1 -1
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/normalizer_postgres.py +13 -2
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/README.md +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/__init__.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/build_merged.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/build_ontology.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/build_umls.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/constants.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/models.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/normalizer.py +0 -0
- {norm_toolkit-1.0.1 → norm_toolkit-1.0.2}/src/norm_toolkit/utils.py +0 -0
|
@@ -10,6 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
import asyncio
|
|
11
11
|
import json
|
|
12
12
|
from collections.abc import Mapping, Sequence
|
|
13
|
+
from typing import Any
|
|
13
14
|
|
|
14
15
|
import asyncpg
|
|
15
16
|
import polars as pl
|
|
@@ -42,13 +43,20 @@ class PostgresNormalizer:
|
|
|
42
43
|
Uses VALUES clauses instead of temp tables for efficiency with small batches.
|
|
43
44
|
"""
|
|
44
45
|
|
|
45
|
-
def __init__(
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
pool: asyncpg.Pool,
|
|
49
|
+
schema: str = "public",
|
|
50
|
+
owned_resource: Any | None = None,
|
|
51
|
+
) -> None:
|
|
46
52
|
"""
|
|
47
53
|
Initialize the normalizer with an external connection pool.
|
|
48
54
|
|
|
49
55
|
Args:
|
|
50
56
|
pool: asyncpg connection pool (caller manages lifecycle)
|
|
51
57
|
schema: PostgreSQL schema where tables are located (default: "public")
|
|
58
|
+
owned_resource: Optional resource with async close() method to clean up
|
|
59
|
+
when this normalizer is closed (e.g., AlloyDB AsyncConnector)
|
|
52
60
|
|
|
53
61
|
Note:
|
|
54
62
|
After creating the normalizer, call `await normalizer.initialize()`
|
|
@@ -57,6 +65,7 @@ class PostgresNormalizer:
|
|
|
57
65
|
self._pool = pool
|
|
58
66
|
self._schema = schema
|
|
59
67
|
self._loop: asyncio.AbstractEventLoop | None = None
|
|
68
|
+
self._owned_resource = owned_resource
|
|
60
69
|
self._has_types = False
|
|
61
70
|
self._has_defs = False
|
|
62
71
|
self._has_edges = False
|
|
@@ -820,12 +829,14 @@ WHERE concept_id != $1
|
|
|
820
829
|
|
|
821
830
|
async def close(self) -> None:
|
|
822
831
|
"""
|
|
823
|
-
Close the connection pool.
|
|
832
|
+
Close the connection pool and any owned resources.
|
|
824
833
|
|
|
825
834
|
Note: Only call this if you want to close the pool. If the pool
|
|
826
835
|
is managed externally, the caller should close it instead.
|
|
827
836
|
"""
|
|
828
837
|
await self._pool.close()
|
|
838
|
+
if self._owned_resource is not None:
|
|
839
|
+
await self._owned_resource.close()
|
|
829
840
|
|
|
830
841
|
def close_sync(self) -> None:
|
|
831
842
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|