ftm_lakehouse.lake
Public convenience functions for the lakehouse.
from ftm_lakehouse import lake
dataset = lake.get_dataset("my_data")
dataset = lake.ensure_dataset("my_data", title="My Dataset")
catalog = lake.get_lakehouse()
# Repository shortcuts
entities = lake.get_entities("my_data")
archive = lake.get_archive("my_data")
mappings = lake.get_mappings("my_data")
Get a lakehouse catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Uri | None
|
Storage URI (default from LAKEHOUSE_URI setting) |
None
|
model_class
|
type[DM]
|
Custom DatasetModel subclass |
DatasetModel
|
Returns:
| Type | Description |
|---|---|
Catalog[DM]
|
Catalog instance |
Source code in ftm_lakehouse/lake.py
Get a dataset by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name |
required |
model_class
|
type[DM]
|
Custom DatasetModel subclass |
DatasetModel
|
**data
|
Any
|
Additional config data (auto-saved if dataset exists) |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset[DM]
|
Dataset instance |
Source code in ftm_lakehouse/lake.py
Get a dataset and ensure it exists.
Creates config.yml if the dataset doesn't exist, recording data at
creation (e.g. ensure_dataset("big_leak", shards=8)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name |
required |
model_class
|
type[DM]
|
Custom DatasetModel subclass |
DatasetModel
|
**data
|
Any
|
Config data for creation |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset[DM]
|
Dataset instance (created if needed) |
Source code in ftm_lakehouse/lake.py
Repository Shortcuts
Get the entity repository for a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset name |
required |
uri
|
Uri | None
|
Dataset URI override (default: {LAKEHOUSE_URI}/{dataset}) |
None
|
Returns:
| Type | Description |
|---|---|
EntityRepository
|
EntityRepository instance (cached) |
Source code in ftm_lakehouse/repository/factories.py
Get the archive repository for a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset name |
required |
uri
|
Uri | None
|
Dataset URI override (default: {LAKEHOUSE_URI}/{dataset}) |
None
|
Returns:
| Type | Description |
|---|---|
ArchiveRepository
|
ArchiveRepository instance (cached) |
Source code in ftm_lakehouse/repository/factories.py
Get the mappings repository for a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset name |
required |
uri
|
Uri | None
|
Dataset URI override (default: {LAKEHOUSE_URI}/{dataset}) |
None
|
Returns:
| Type | Description |
|---|---|
MappingRepository
|
MappingRepository instance (cached) |
Source code in ftm_lakehouse/repository/factories.py
Classes
Bases: Generic[DM]
Multi-dataset lakehouse catalog.
The Catalog manages multiple datasets within a lakehouse storage location.
Example
Source code in ftm_lakehouse/catalog.py
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
model
property
Load and return the catalog model from config.yml.
get_dataset(name, **data)
Get a Dataset instance by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name. Validated against
:func: |
required |
**data
|
Any
|
Additional config data (auto-saved to config.yml if dataset exists) |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset[DM]
|
Dataset instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in ftm_lakehouse/catalog.py
list_datasets()
Iterate through all datasets in the catalog.
Yields:
| Type | Description |
|---|---|
Dataset[DM]
|
Dataset instances that have a config.yml |
Source code in ftm_lakehouse/catalog.py
create_dataset(name, **data)
Create a new dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name |
required |
**data
|
Any
|
Initial config data, recorded into |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset[DM]
|
Created Dataset instance |
Source code in ftm_lakehouse/catalog.py
update_model(**data)
Update config.yml with new data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
Fields to update in the model |
{}
|
Returns:
| Type | Description |
|---|---|
CatalogModel
|
Updated model |
Source code in ftm_lakehouse/catalog.py
Bases: Generic[DM]
A single dataset within the lakehouse – a stateless handle around the dataset's name, storage uri and configuration.
Repository access goes through the LRU-cached factories, so every path
addressing the same dataset – this handle, the module-level
get_entities("name") convenience functions, and operations – shares
one repository instance:
get_archive(): File storage (ArchiveRepository)get_entities(): Entity/statement operations (EntityRepository)get_documents(): Document metadata (DocumentRepository)get_mappings(): Mapping configurations (MappingRepository)
Example
Source code in ftm_lakehouse/dataset.py
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 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 | |
model
property
Load and return the dataset model from config.yml.
update_model(**data)
Update config.yml with new data.
Uses VersionStore to create versioned snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
Fields to update in the model |
{}
|
Returns:
| Type | Description |
|---|---|
DM
|
Updated model |
Source code in ftm_lakehouse/dataset.py
exists()
ensure(**data)
Ensure dataset exists, create config.yml if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
Initial config data recorded at creation (e.g.
|
{}
|