dataenginex.data¶
Data connectors, profiling, and schema registry.
dataenginex.data
¶
Data connectors, profiling, and schema registry.
Public API::
from dataenginex.data import (
DataConnector, RestConnector, FileConnector,
ConnectorStatus, FetchResult,
DataProfiler, ProfileReport, ColumnProfile,
SchemaRegistry, SchemaVersion,
)
ConnectorStatus
¶
Bases: StrEnum
Lifecycle states for a data connector.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
DataConnector
¶
Bases: ABC
Base class for all data connectors in DEX.
Subclass and implement connect, fetch, and close.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
FetchResult
dataclass
¶
Outcome of a single fetch invocation.
Attributes:
| Name | Type | Description |
|---|---|---|
records |
list[dict[str, Any]]
|
Retrieved data records. |
record_count |
int
|
Number of records returned. |
source |
str
|
Name of the data source. |
fetched_at |
datetime
|
Timestamp of the fetch. |
duration_ms |
float
|
Fetch duration in milliseconds. |
errors |
list[str]
|
Error messages (empty on success). |
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
success
property
¶
Return True if the fetch completed without errors.
FileConnector
¶
Bases: DataConnector
Reads records from local JSON, JSONL, or CSV files.
Parameters¶
name:
Human-readable connector label.
path:
File system path to the data file.
file_format:
One of "json", "jsonl", "csv".
encoding:
Text encoding (default utf-8).
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 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 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
connect()
async
¶
Verify the configured file exists and is readable.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
fetch(*, limit=None, offset=0, filters=None)
async
¶
Read and parse records from the local file.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
RestConnector
¶
Bases: DataConnector
Fetches records from an HTTP/REST API endpoint.
Parameters¶
name:
Human-readable connector label.
base_url:
Root URL of the API (e.g. https://api.example.com).
endpoint:
Path appended to base_url for fetches (e.g. /v1/jobs).
headers:
Extra HTTP headers (auth tokens, accept types, etc.).
timeout:
HTTP timeout in seconds (default 30).
records_key:
JSON key that contains the result list (e.g. "data").
When None the root response is expected to be a list.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 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 | |
connect()
async
¶
Open an HTTP client session to the configured base URL.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
fetch(*, limit=None, offset=0, filters=None)
async
¶
Fetch records from the REST endpoint with optional pagination.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
close()
async
¶
Close the HTTP client session and release resources.
Source code in packages/dataenginex/src/dataenginex/data/connectors.py
ColumnProfile
dataclass
¶
Statistics for a single column / field.
Source code in packages/dataenginex/src/dataenginex/data/profiler.py
DataProfiler
¶
Profile a list of dict records in pure Python (no pandas needed).
Source code in packages/dataenginex/src/dataenginex/data/profiler.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 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 | |
profile(records, dataset_name='unnamed')
¶
Profile a list of dict records and return column-level statistics.
Source code in packages/dataenginex/src/dataenginex/data/profiler.py
ProfileReport
dataclass
¶
Aggregated profiling report for a dataset.
Attributes:
| Name | Type | Description |
|---|---|---|
dataset_name |
str
|
Name of the profiled dataset. |
record_count |
int
|
Total number of records profiled. |
column_count |
int
|
Number of columns/fields discovered. |
columns |
list[ColumnProfile]
|
Per-column profile statistics. |
profiled_at |
datetime
|
Timestamp when profiling was performed. |
duration_ms |
float
|
Time taken for profiling in milliseconds. |
Source code in packages/dataenginex/src/dataenginex/data/profiler.py
completeness
property
¶
Overall dataset completeness (1 − avg null rate).
to_dict()
¶
Serialize the profile report to a plain dictionary.
Source code in packages/dataenginex/src/dataenginex/data/profiler.py
SchemaRegistry
¶
In-process schema registry backed by an optional JSON file.
Parameters¶
persist_path: If given, schemas are saved/loaded from this JSON file so they survive across process restarts.
Source code in packages/dataenginex/src/dataenginex/data/registry.py
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
register(schema)
¶
Register a new schema version. Duplicate versions are rejected.
Source code in packages/dataenginex/src/dataenginex/data/registry.py
get_latest(name)
¶
Return the most recently registered version for name.
get_version(name, version)
¶
Return a specific version, or None if not found.
Source code in packages/dataenginex/src/dataenginex/data/registry.py
list_schemas()
¶
list_versions(name)
¶
Return all registered versions for name (oldest first).
validate(name, record, version=None)
¶
Validate record against a schema.
If version is None the latest version is used.
Source code in packages/dataenginex/src/dataenginex/data/registry.py
SchemaVersion
dataclass
¶
An immutable snapshot of a schema at a particular version.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Schema identifier (e.g. |
version |
str
|
Semver string (e.g. |
fields |
dict[str, str]
|
Mapping of field names to type descriptions. |
required_fields |
list[str]
|
Fields that must be present in every record. |
description |
str
|
Human-readable summary of the schema. |
created_at |
datetime
|
When this version was registered. |
metadata |
dict[str, Any]
|
Extra context dict. |
Source code in packages/dataenginex/src/dataenginex/data/registry.py
to_dict()
¶
Serialize the schema version to a plain dictionary.
Source code in packages/dataenginex/src/dataenginex/data/registry.py
validate_record(record)
¶
Check that record has all required fields.
Returns (is_valid, errors) where errors lists the missing
required fields.