Layer 3: Repository
Domain-specific combinations of multiple stores. Each repository owns one domain concept.
ArchiveRepository
Content-addressed file archive with metadata and extracted text storage.
from ftm_lakehouse import get_archive
archive = get_archive("my_dataset")
archive.store(uri)
archive.get_file(checksum)
archive.stream(checksum)
ftm_lakehouse.repository.ArchiveRepository
Bases: DatasetHandle
Repository for file archive operations.
Combines content-addressed blob storage (raw bytes) and model-based metadata storage (JSON) to provide file archiving.
Blobs are stored once per checksum, but each unique source path creates its own metadata file (keyed by File.id).
Optionally, extracted text (by different origins) can be stored and retrieved. As well, other programs can write arbitrary additional data to the archive (such as pdf page thumbnails).
Example
Source code in ftm_lakehouse/repository/archive.py
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 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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
delete(file)
Delete a file's metadata from the archive.
The blob is never deleted. (FIXME)
Source code in ftm_lakehouse/repository/archive.py
exists(checksum)
get_all_files(checksum)
Iterate all metadata files for the given checksum.
Multiple crawlers may have archived the same file content from different source paths, each creating their own metadata file.
Source code in ftm_lakehouse/repository/archive.py
get_data(checksum, path)
get_file(checksum, file_id=None)
Get file metadata for the given checksum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checksum
|
str
|
SHA256 checksum of file |
required |
file_id
|
str | None
|
Optional File.id to get specific metadata |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
When no metadata file exists |
Source code in ftm_lakehouse/repository/archive.py
get_txt(checksum, origin=None)
Get extracted text for a file. If origin, get by this specific
extraction, otherwise get the first txt value (no guaranteed order)
Source code in ftm_lakehouse/repository/archive.py
iterate_files()
local_path(checksum)
Get the local path to the blob.
If storage is local, returns actual path. Otherwise, creates a temporary local copy that is cleaned up after context exit.
Source code in ftm_lakehouse/repository/archive.py
open(checksum)
put_data(checksum, path, data)
put_file(file)
put_txt(checksum, text, origin=DEFAULT_ORIGIN)
Store extracted text for a file.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in ftm_lakehouse/repository/archive.py
store(uri, file=None, checksum=None, tag_updated=True, store_metadata=True, **metadata)
Archive a file from a local or remote URI.
The blob is stored once per checksum, but each unique source path creates its own metadata file (keyed by File.id).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Uri
|
Local or remote URI to the file |
required |
file
|
File | None
|
Optional metadata file object to patch |
None
|
checksum
|
str | None
|
Content hash (skip computation if provided) |
None
|
**metadata
|
Any
|
Additional data to store in file's extra field, including
FollowTheMoney properties for the |
{}
|
Returns:
| Type | Description |
|---|---|
File
|
File metadata object |
Source code in ftm_lakehouse/repository/archive.py
store_blob(uri, checksum=None)
Store bytes blob from given uri if it doesn't exist yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Uri
|
Local or remote URI to the file |
required |
checksum
|
str | None
|
Content hash (skip computation if provided) |
None
|
Returns:
| Type | Description |
|---|---|
str
|
checksum |
Source code in ftm_lakehouse/repository/archive.py
stream(checksum)
write_blob(fh, checksum=None, check_exists=True)
Write a blob from the given open file-handler
Source code in ftm_lakehouse/repository/archive.py
EntityRepository
Entity/statement operations combining JournalStore and ParquetStore.
from ftmq.query import M, Query
from ftm_lakehouse import get_entities
entities = get_entities("my_dataset")
entities.add(entity, origin="import")
entities.writer(origin="import")
entities.flush()
entities.query(Query(M(origin="import")))
ftm_lakehouse.repository.EntityRepository
Bases: DatasetHandle
Repository for entity/statement operations.
Combines JournalStore (write-ahead buffer) and ParquetStore (Delta Lake) to provide buffered statement storage with efficient querying.
Writes go to the journal first, then are flushed to the parquet store. Reads query the parquet store (optionally flushing first).
Example
Source code in ftm_lakehouse/repository/entities/main.py
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 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 253 254 255 256 257 258 259 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 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
exists
property
Whether the statement store has been written – local only.
needs_merge
property
Whether the statement store has writes that
merge has not collapsed yet – local only.
Reads are canonical only on a merged store, so anything publishing
canonical rows (the exports, and their diffs strictly) checks
this first. See ParquetStore.needs_merge.
version
property
Current version of the main Delta table.
add(entity, origin=None, fragment=None, role=None)
Add a single entity to the journal.
Source code in ftm_lakehouse/repository/entities/main.py
add_many(entities, origin=None, fragment=None, role=None)
Add an entity iterator to the journal.
Source code in ftm_lakehouse/repository/entities/main.py
compact()
delete_entity(entity_id, origin=None)
Delete all statements for an entity via journal tombstones.
Reads statements from both parquet and journal, then UPSERTs
tombstone rows (with deleted_at set) into the journal. Each
tombstone carries the live row's fragment and role – both
are row identity, so a tombstone missing either lands in a different
merge group and shadows nothing. Reading the live rows first is what
makes that automatic: one tombstone per row means every role's
assertion is deleted, which is what deleting the entity means.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_id
|
str
|
The entity ID to delete |
required |
origin
|
str | None
|
Only delete entity data from this origin |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of tombstone statements written |
Source code in ftm_lakehouse/repository/entities/main.py
delete_origin(origin)
Physically delete an entire origin – journal included.
Unlike delete_entity this writes no
tombstones: origin is a partition column, so
ParquetStore.delete_origin drops whole
partitions under the maintenance fence and the rows are gone at that
commit – no merge, no grace period.
The journal is flushed first, so rows written under origin and
still buffered land in parquet in time to be dropped rather than
resurrecting on the next flush. Flushing
happens outside the fence – its append takes the shared side, which
the exclusive one locks out – so a writer journalling into origin
during the drop still survives it. Stop the writers to be sure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
str
|
The origin tag to drop. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
When the write fence cannot be acquired. |
Source code in ftm_lakehouse/repository/entities/main.py
delete_statement(stmt, fragment=None, role=None)
Delete a single statement via journal tombstone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stmt
|
Statement
|
The Statement to delete. A
|
required |
fragment
|
str | None
|
Fragment override – required to shadow a
fragment-bearing row when passing a plain |
None
|
role
|
str | None
|
Role override – likewise required to shadow a row written
under a role when passing a plain |
None
|
Source code in ftm_lakehouse/repository/entities/main.py
deleted_ids(since)
Entity ids with statements tombstoned since the given timestamp.
Reads ParquetStore.source_raw, since the live view hides exactly
the rows this asks about
Source code in ftm_lakehouse/repository/entities/main.py
evolve_schema()
Add statement columns the parquet store was created without.
Delegates to ParquetStore.evolve_schema,
the primitive behind the schema migrations.
Returns:
| Type | Description |
|---|---|
list[str]
|
Names of the columns added – empty if the store is already current. |
Source code in ftm_lakehouse/repository/entities/main.py
flush()
Drain the journal into the parquet statement store.
The journal holds the parquet statement columns, so this streams Arrow
batches from one store into the other via
write_batches. Duplicates and
tombstones land as new rows; call merge
afterwards to collapse them.
Returns:
| Type | Description |
|---|---|
int
|
Number of statements appended. |
Source code in ftm_lakehouse/repository/entities/main.py
get(entity_id, flush_first=False)
Get a single entity by ID.
Source code in ftm_lakehouse/repository/entities/main.py
merge(force=False)
Collapse duplicates and reap expired tombstones from parquet store.
Flushes the journal first. force rewrites every partition
regardless of freshness tags.
Source code in ftm_lakehouse/repository/entities/main.py
query(q=None, *, flush_first=False)
Query entities from the parquet store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Query | None
|
ftmq |
None
|
flush_first
|
bool
|
Flush the journal to parquet before querying. |
False
|
Yields:
| Type | Description |
|---|---|
StatementEntities
|
StatementEntity objects matching the query. |
Source code in ftm_lakehouse/repository/entities/main.py
query_statements(q=None, *, flush_first=False)
Query statements from the parquet store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Query | None
|
ftmq |
None
|
flush_first
|
bool
|
Flush the journal to parquet before querying. |
False
|
Yields:
| Type | Description |
|---|---|
Statements
|
|
Source code in ftm_lakehouse/repository/entities/main.py
query_statements_data(q=None)
Query raw statement dicts from the parquet store.
The fast read: no LakehouseStatement construction – use
query_statements for model
objects. Same execution strategy as
query_statements, so a sorted or
sliced query still runs globally instead of once per partition.
Source code in ftm_lakehouse/repository/entities/main.py
shard(shards)
Re-shard the parquet store onto shards entity-hash shards.
Drains the journal first – a row left in it would be placed by
whichever count the flushing store resolves, and only rows already
in parquet are moved by the rewrite – then rewrites the store
(ParquetStore.shard) and adopts the new count, so this
instance keeps resolving reads and writes to the right shards.
Only the storage half: the dataset's config.yml is what every
other reader resolves the count from, and
ShardOperation writes
it once this returns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shards
|
int
|
Target shard count; |
required |
Source code in ftm_lakehouse/repository/entities/main.py
stats()
stream()
Stream entities from the exported JSON file.
This reads from the pre-exported entities.ftm.json file, not directly from the parquet store – decoded with the dataset's codec, since that artifact is written compressed when configured.
Source code in ftm_lakehouse/repository/entities/main.py
sweep(with_csv_export=True, tee=True)
One scan of the store, optionally writing statements.csv from it.
Delegates to ParquetStore.sweep with this
dataset's csv key, so the artifact carries the configured codec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_csv_export
|
bool
|
Write the |
True
|
tee
|
bool
|
Yield row dicts. |
True
|
Yields:
| Type | Description |
|---|---|
StatementDict
|
|
Source code in ftm_lakehouse/repository/entities/main.py
unlock()
Forcibly release the dataset write fence.
Delegates to ParquetStore.unlock. Use as an operator
escape hatch when a writer died with the lock held; do not
invoke while a legitimate writer is still running.
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in ftm_lakehouse/repository/entities/main.py
vacuum(retention_hours=0)
Delete obsolete parquet files tombstoned in the Delta log.
write_batches(tables)
Append packed Arrow tables to parquet – the one write loop.
Every producer packs its own rows and hands them here: the journal
drain (JournalStore.flush_batches), the safe bulk import
(flush_table)
and the unsafe one
(RowBuffer). Tables
arrive in JOURNAL_SCHEMA – no
shard column, ParquetStore.append derives it – and go
straight there; one is durable before the producer is asked for the
next, which is what lets the journal drop a segment it has handed
over. Sizing is the producer's call: each table becomes one parquet
file per (shard, bucket, origin) partition it spans, so bigger
tables cost fewer files and fewer Delta commits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
Iterable[Table]
|
Stream of packed statement tables. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of rows written. |
Source code in ftm_lakehouse/repository/entities/main.py
writer(origin=None, role=None)
Get a bulk writer for adding entities/statements.
The writer owns its own lifecycle (insert the tail on success, drop
the un-inserted buffer on error, close either way – see
BaseJournalWriter.__exit__); this adds the freshness tag,
stamped only when the block leaves cleanly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
str | None
|
Origin tag for statements written through this writer. |
None
|
role
|
str | None
|
Default role – who is asserting these statements – for statements that carry none of their own. |
None
|
Yields:
| Type | Description |
|---|---|
BaseJournalWriter
|
The journal writer, open for the duration of the block. |
Source code in ftm_lakehouse/repository/entities/main.py
JobRepository
Job tracking and status. Job runs are stored per job class – resolve the repository through the factory:
from ftm_lakehouse.repository.factories import get_jobs
jobs = get_jobs("my_dataset", CrawlJob)
jobs.put(job)
jobs.get(run_id)
ftm_lakehouse.repository.JobRepository
Bases: DatasetHandle, Generic[J]
Repository for job run storage.
Persists job run data as JSON files, organized by job type and run ID.
Example
repo = JobRepository(dataset="my_data", uri="s3://bucket/dataset")
# Store a job run
repo.put(job)
# Get latest run for a job type
job = repo.latest(CrawlJob)
# Run a job with lifecycle management
with repo.run(job) as run:
# Do work...
run.save() # Periodic save
# Job automatically stopped when context exits
Source code in ftm_lakehouse/repository/job.py
delete(job)
get(run_id)
iterate()
latest()
Get the latest run for the configured job type (self.model).
Jobs are sorted by run ID (which contains timestamp), so the latest is the last in alphabetical order.
Source code in ftm_lakehouse/repository/job.py
put(job)
run(job)
Get a context manager for running a job.
The job is automatically started on entry and stopped on exit. If an exception occurs, it's recorded in the job's exc field.
Source code in ftm_lakehouse/repository/job.py
DocumentRepository
Document metadata assembled from archived files and their entities.
ftm_lakehouse.repository.DocumentRepository
Bases: DatasetHandle
Repository for documents to consume for clients.
This gathers File entities created during storing blobs in the archive and compiles a streamable csv list of document metadata.
Format: id,checksum,name,mimetype,path,size,updated_at,public_url
The csv itself is written by the export sweep
(ExportOperation),
which already holds every entity. The row shape and reading the result
back belong to
DocumentsArtifact;
this repository owns the query side – the folder paths the rows resolve
against (make_paths), the ad-hoc
lookups and the tombstoned ids.
Example
Source code in ftm_lakehouse/repository/documents.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 | |
compression
property
Compression codec of the exported artifacts (the dataset's config).
csv_key(origin=None)
Store key of the exported documents csv, carrying the dataset's codec.
csv_uri(origin=None)
deleted_ids(since, origin=None)
Document ids with statements tombstoned since the given timestamp.
Reads ParquetStore.source_raw, since the live view hides exactly
the rows this asks about.
Source code in ftm_lakehouse/repository/documents.py
iterate(q=None)
Query the store for documents and build their csv rows.
The ad-hoc entry point – the export sweep does not use it, since it
already holds every entity and calls
make_documents
directly against one make_paths result.
Source code in ftm_lakehouse/repository/documents.py
make_paths()
Compute folder structure from Folder (parent) entities.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Mapping of folder ID to complete path (e.g. "root/sub/folder") |
Source code in ftm_lakehouse/repository/documents.py
stream(origin=None)
ArtifactsRepository
The export artifacts one dataset produces – statements.csv, entities.ftm.json, documents.csv (one per origin scope), statistics.json, index.json – and the diff series that ride alongside the streamed ones.
from ftm_lakehouse.repository import get_artifacts
artifacts = get_artifacts("my_dataset")
artifacts.entities.is_fresh()
artifacts.documents["crawl"].key
ftm_lakehouse.repository.ArtifactsRepository
Bases: DatasetHandle
The export artifacts one dataset produces.
Binds the declarations above to this dataset, so a caller addresses an
artifact by kind and gets something that knows where it lives, whether it
is current, how to write it and how to describe itself in index.json.
Example
Source code in ftm_lakehouse/repository/artifacts.py
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | |
__getitem__(kind)
The artifact answering to one export kind, bound to this dataset.
document_scopes()
The documents variants a full export writes, one per origin.
resources()
Describe every written artifact for index.json.
index.json itself is left out – it is the file being written.
Source code in ftm_lakehouse/repository/artifacts.py
session(now, kinds, version, make_diff=True)
The artifacts an export run covers, ready to be driven as one loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
now
|
datetime
|
Timestamp the run started – diff files are named after it and diff states are recorded at it. |
required |
kinds
|
Iterable[ExportKind]
|
Which exports this run covers. |
required |
version
|
int | None
|
Current delta table version, which the diff series resolve their window against. |
required |
make_diff
|
bool
|
Whether diff series run at all. |
True
|
Source code in ftm_lakehouse/repository/artifacts.py
written_by(kinds)
Every artifact those kinds cover, origin scopes expanded.
Source code in ftm_lakehouse/repository/artifacts.py
An artifact is a stateless declaration bound to a dataset; everything true only while an export runs – the open writer, the diff window, the counts – lives on its run, driven by ExportSession as one loop.
ftm_lakehouse.repository.artifacts.Artifact
One export artifact, bound to a dataset.
Stateless – see the module docstring. Per-run state lives on ArtifactRun.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
DatasetHandle
|
The dataset handle the artifact belongs to. |
required |
origin
|
str | None
|
Source tag this variant is scoped to, |
None
|
Source code in ftm_lakehouse/repository/artifacts.py
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 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 | |
compression
property
The dataset's codec, or None where the artifact takes none.
key
property
The key the artifact actually lives at, codec included.
name
property
How this variant names itself in a result – crawl_documents.
tag
property
The codec-free key: what the freshness tag is named after.
uri
property
Full uri of the artifact in the dataset's store.
__getitem__(origin=None)
exists()
is_fresh()
Whether the artifact exists and is newer than its dependencies.
A missing artifact is never fresh – there is nothing to be current.
Source code in ftm_lakehouse/repository/artifacts.py
make_resource(public_prefix=None)
Describe the artifact for index.json, or None if unwritten.
Source code in ftm_lakehouse/repository/artifacts.py
reader(mode='rb')
Open the artifact for reading, decoded with the dataset's codec.
Source code in ftm_lakehouse/repository/artifacts.py
run(now)
touch(ts=None)
writer(lazy=False)
A writer for this artifact, in its own format and codec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lazy
|
bool
|
Defer creating the file to the first row. An artifact is a whole picture of the store, so it opens eagerly – an empty sweep must truncate a stale one rather than leave it. A diff is the opposite: no changes means no file. |
False
|
Source code in ftm_lakehouse/repository/artifacts.py
ftm_lakehouse.repository.artifacts.DiffableArtifact
Bases: Artifact
An artifact that keeps a diff series alongside it.
Owns the series' paths and its stored {timestamp}:{version} state.
Whether this run writes a diff, and against which window, belongs to
DiffableRun.
The series directory carries neither extension nor codec – it doubles as the series' freshness tag and diff-state key, so it must not move when a dataset changes its compression.
Source code in ftm_lakehouse/repository/artifacts.py
series
property
The directory this variant's diff files live in.
state_key
property
Tag key the {timestamp}:{version} state is stored under.
diff_writer(ts)
A writer for one diff file in this series.
Source code in ftm_lakehouse/repository/artifacts.py
get_state()
Last diff state as (timestamp, delta table version).
Source code in ftm_lakehouse/repository/artifacts.py
set_state(ts, version)
Store the diff state the next run is taken against.
ftm_lakehouse.repository.artifacts.DocumentsArtifact
Bases: DiffableArtifact
Document metadata, and its delta series – origin-scopable.
Owns the write side of the documents export: which entities belong in
it, and what rows each contributes. The query side – the folder map, the
ad-hoc lookups, the tombstoned ids – stays on
DocumentRepository.
Source code in ftm_lakehouse/repository/artifacts.py
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 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
is_document(data)
staticmethod
Whether an entity dict belongs in the documents export.
The in-Python spelling of Q_DOCUMENTS: a Document descendant
that is not a bare Folder (those are the path scaffolding, not
files) and actually has a content hash to point at.
Source code in ftm_lakehouse/repository/artifacts.py
make_documents(data, paths, public_prefix=None)
The csv rows one entity dict contributes.
One row per resolvable parent folder, so a file living in two places is listed under both; a file with no resolvable parent still gets its one unpathed row. Each row is its own object, so a caller may materialise them – the diff writes the same rows the csv did.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
SDict
|
Entity dict, as |
required |
paths
|
dict[str, str]
|
Folder id to path map from |
required |
public_prefix
|
str | None
|
Public url prefix to build blob links against. |
None
|
Yields:
| Type | Description |
|---|---|
Documents
|
One |
Source code in ftm_lakehouse/repository/artifacts.py
stream()
Stream this variant's csv back as Document models.