graflo.hq.inferencer¶
InferenceManager
¶
Inference manager for PostgreSQL sources.
Source code in graflo/hq/inferencer.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
__init__(conn, target_db_flavor=DBType.ARANGO, fuzzy_threshold=0.8)
¶
Initialize the PostgreSQL inference manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
PostgresConnection
|
PostgresConnection instance |
required |
target_db_flavor
|
DBType
|
Target database flavor for schema sanitization |
ARANGO
|
fuzzy_threshold
|
float
|
Similarity threshold for fuzzy matching (0.0 to 1.0, default 0.8) |
0.8
|
Source code in graflo/hq/inferencer.py
create_resources(introspection_result, schema)
¶
Create Resources from PostgreSQL introspection result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
introspection_result
|
SchemaIntrospectionResult from PostgreSQL |
required | |
schema
|
Schema
|
Existing Schema object |
required |
Returns:
| Type | Description |
|---|---|
list[Resource]
|
list[Resource]: List of Resources for PostgreSQL tables |
Source code in graflo/hq/inferencer.py
create_resources_for_schema(schema, schema_name=None)
¶
Create Resources from source for an existing schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
Schema
|
Existing Schema object |
required |
schema_name
|
str | None
|
Schema name to introspect (source-specific) |
None
|
Returns:
| Type | Description |
|---|---|
list[Resource]
|
list[Resource]: List of Resources for the source |
Source code in graflo/hq/inferencer.py
infer_complete_schema(schema_name=None)
¶
Infer a complete schema and ingestion model from source and sanitize for target.
This is a convenience method that: 1. Introspects the source schema 2. Infers the graflo Schema 3. Sanitizes for the target database flavor 4. Creates and adds resources 5. Re-initializes the schema
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_name
|
str | None
|
Schema name to introspect (source-specific) |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Schema, IngestionModel]
|
tuple[Schema, IngestionModel]: Complete schema and ingestion model |
Source code in graflo/hq/inferencer.py
infer_schema(introspection_result, schema_name=None)
¶
Infer graflo Schema from PostgreSQL introspection result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
introspection_result
|
SchemaIntrospectionResult from PostgreSQL |
required | |
schema_name
|
str | None
|
Schema name (optional, may be inferred from result) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Schema |
Schema
|
Inferred schema with vertices and edges |
Source code in graflo/hq/inferencer.py
introspect(schema_name=None, include_raw_tables=False)
¶
Introspect PostgreSQL schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_name
|
str | None
|
Schema name to introspect |
None
|
include_raw_tables
|
bool
|
Whether to build sampled per-column raw table metadata. Defaults to False for performance (binding/schema inference does not require it). |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
SchemaIntrospectionResult |
SchemaIntrospectionResult
|
PostgreSQL schema introspection result |