entei_core package
entei_core
entei-core: MongoDB collection roots and columnar dict[str, list] materialization.
Exports :class:MongoRoot, :func:mongo_root_to_column_dict, and
:func:materialize_root_data for building columnar data from PyMongo collections
without a native extension stack.
MongoRoot
dataclass
Carrier for a collection plus optional fixed column list for materialization.
Used with :func:~entei_core.mongo_root_to_column_dict to produce
dict[str, list] with one list per top-level field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Any
|
A PyMongo :class: |
required |
fields
|
tuple[str, ...] | None
|
Column order and membership for output. If |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in packages/entei-core/src/entei_core/mongo_root.py
9 10 11 12 13 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 | |
__post_init__()
Validate fields invariants.
Source code in packages/entei-core/src/entei_core/mongo_root.py
36 37 38 39 | |
materialize_root_data(data)
Normalize pipeline data: columnarize :class:MongoRoot, else identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Any value. If it is a :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Columnar dict or the original |
Source code in packages/entei-core/src/entei_core/_materialize.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
mongo_root_to_column_dict(root)
Run find() on root.collection and build aligned column lists.
Reads the entire cursor into memory. Only top-level keys participate; nested documents are values in a single cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
MongoRoot
|
Collection and optional |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list]
|
Keys are field names; each value is the column in document order. |
Notes
When root.fields is None, keys are inferred from documents. When it is
an empty tuple, returns {} for any document count.
Source code in packages/entei-core/src/entei_core/_materialize.py
10 11 12 13 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 | |