attribute_table_builder
SNOMED attribute table builder for pgvector.
Creates/populates PostgreSQL table {VOCAB_SCHEMA}.snomed_attribute with
attribute-value concept rows and their embeddings.`
build_attribute_table(hierarchy_settings, if_exists='append')
Build the pgvector SNOMED attribute table from OMOP relationships.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hierarchy_settings
|
HierarchySettings
|
Hierarchy settings containing |
required |
if_exists
|
Literal['append', 'skip', 'rebuild']
|
Behavior when target tables already contain rows:
- |
'append'
|
Source code in src/ariadne/hierarchy/attribute_table_builder.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
check_populated(conn, table)
Return True if table already contains at least one row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection
|
psycopg connection (read access is enough). |
required |
table
|
str
|
Table name to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/ariadne/hierarchy/attribute_table_builder.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
create_embedding_index(conn)
Create the HNSW embedding index for snomed_attribute if missing.
Source code in src/ariadne/hierarchy/attribute_table_builder.py
62 63 64 65 66 67 68 69 70 71 72 | |
create_table(conn, dim)
Create snomed_attribute table.
Safe to call when tables already exist (uses CREATE TABLE IF NOT EXISTS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection
|
Admin psycopg connection. |
required |
dim
|
int
|
Embedding dimension |
required |
Source code in src/ariadne/hierarchy/attribute_table_builder.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
insert_attributes(conn, batch_files, upload_batch_size, rebuild=False)
Insert pre-embedded parquet batches into snomed_attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
Connection
|
Admin psycopg connection (returned — may be replaced on retry). |
required |
batch_files
|
list[Path]
|
Parquet files containing pre-embedded attribute rows. |
required |
upload_batch_size
|
int
|
Number of rows per INSERT chunk. |
required |
rebuild
|
bool
|
When True, truncate the table first. |
False
|
Returns:
| Type | Description |
|---|---|
Connection
|
The (possibly reconnected) psycopg connection. |
Source code in src/ariadne/hierarchy/attribute_table_builder.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
load_attributes_from_db(snomed_relationships)
Load SNOMED attribute value rows from the OHDSI Vocabularies DB.
Source code in src/ariadne/hierarchy/attribute_table_builder.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |