pipeline_snapshot
¶
Pipeline Snapshot Manager.
Manages track snapshots during pipeline execution for efficient delta processing.
PipelineSnapshotManager
¶
Manages track snapshots during pipeline execution.
Maintains an in-memory cache of tracks for efficient updates during the pipeline run, avoiding repeated fetches from Music.app.
Initialize the snapshot manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track_processor
|
TrackProcessor
|
Processor for fetching tracks by ID. |
required |
console_logger
|
Logger
|
Logger for console output. |
required |
Source code in src/app/pipeline_snapshot.py
reset
¶
set_snapshot
¶
Store the current pipeline track snapshot for downstream reuse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackDict]
|
List of tracks to cache. |
required |
library_mtime
|
datetime | None
|
Library modification time captured BEFORE fetching tracks. This prevents race conditions where new tracks added during fetch would be missed but metadata would incorrectly show library as unchanged. |
None
|
Source code in src/app/pipeline_snapshot.py
update_tracks
¶
Apply field updates from processed tracks to the cached snapshot.
Source code in src/app/pipeline_snapshot.py
get_snapshot
¶
clear
¶
persist_to_disk
async
¶
Persist the current in-memory snapshot to disk.
This should be called at the end of the pipeline to ensure that genre/year changes are reflected in the disk snapshot.
Returns:
| Type | Description |
|---|---|
bool
|
True if snapshot was persisted, False if no snapshot available. |
Source code in src/app/pipeline_snapshot.py
merge_smart_delta
async
¶
Merge snapshot with Smart Delta changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot_tracks
|
list[TrackDict]
|
Current snapshot tracks. |
required |
delta
|
TrackDelta
|
Delta containing new, updated, and removed track IDs. |
required |
Returns:
| Type | Description |
|---|---|
list[TrackDict] | None
|
Updated list of tracks if successful, otherwise None to indicate |
list[TrackDict] | None
|
fallback should be used. |