ftm_lakehouse.lake
Public convenience functions for the lakehouse – repositories are the dataset handle.
from ftm_lakehouse import ensure_dataset, get_entities, get_archive, get_lakehouse
ensure_dataset("my_data", title="My Dataset", shards=8)
entities = get_entities("my_data")
archive = get_archive("my_data")
for name in get_lakehouse().list_datasets():
...
Get a lakehouse catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Uri | None
|
Storage URI (default from LAKEHOUSE_URI setting) |
None
|
Returns:
| Type | Description |
|---|---|
Catalog
|
Catalog instance |
Source code in ftm_lakehouse/lake.py
Dataset config lifecycle
Get or create a dataset.
Creates config.yml if the dataset doesn't exist, recording data
at creation (e.g. ensure_dataset("big_leak", shards=8)); data is
ignored when the dataset already exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name. |
required |
uri
|
Uri | None
|
Dataset storage root override. |
None
|
**data
|
Any
|
Config data recorded at creation. |
{}
|
Returns:
| Type | Description |
|---|---|
DatasetModel
|
The dataset's model. |
Source code in ftm_lakehouse/catalog.py
Merge data into the dataset's config.yml (versioned snapshot).
Invalidates the repository factory caches afterwards so newly fetched repositories see the fresh config; instances held across the write keep their old snapshot (see the module docstring for the freshness contract).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name. |
required |
uri
|
Uri | None
|
Dataset storage root override. |
None
|
**data
|
Any
|
Fields to update in the model. |
{}
|
Returns:
| Type | Description |
|---|---|
DatasetModel
|
The updated model. |
Source code in ftm_lakehouse/catalog.py
The dataset's config, read fresh from config.yml on every call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name. |
required |
uri
|
Uri | None
|
Dataset storage root override (default:
|
None
|
Source code in ftm_lakehouse/catalog.py
The dataset's published index.json, falling back to the config.
The index is the config enriched with export resources and statistics,
written by the index export operation.
Source code in ftm_lakehouse/catalog.py
Repository Shortcuts
Get the entity repository for a dataset (cached; the api-mode subclass for http uris).
Source code in ftm_lakehouse/repository/factories.py
Get the archive repository for a dataset (cached).
Source code in ftm_lakehouse/repository/factories.py
Get the document repository for a dataset (cached).
Source code in ftm_lakehouse/repository/factories.py
Custom dataset models
Register a custom DatasetModel subclass process-wide.
Every config read – repository construction, get_dataset_model,
update_dataset, the index export – constructs models via
get_model_class, so downstream applications extend the dataset
config schema with one call at process start:
import ftm_lakehouse
class MyModel(ftm_lakehouse.DatasetModel):
my_field: str | None = None
ftm_lakehouse.set_model_class(MyModel)
Call this before any repository or config access – repositories
snapshot their model at construction and are LRU-cached, so a later
switch requires repository.factories.clear_caches().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_class
|
type[DatasetModel]
|
The |
required |
Source code in ftm_lakehouse/model/dataset.py
Classes
Multi-dataset lakehouse catalog – enumeration and dataset addressing.
Example
Source code in ftm_lakehouse/catalog.py
dataset_uri(name)
Validated canonical uri for name under this catalog's root.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
list_datasets()
Yield the names of all datasets that have a config.yml.
Source code in ftm_lakehouse/catalog.py
ensure_dataset(name, **data)
Get or create a dataset under this catalog.
See ensure_dataset.