@@ -329,11 +329,11 @@ class SnapshotInfoMixin(ModelKindMixin):
329
329
base_table_name_override : t .Optional [str ]
330
330
dev_table_suffix : str
331
331
332
- @property
332
+ @cached_property
333
333
def identifier (self ) -> str :
334
334
return self .fingerprint .to_identifier ()
335
335
336
- @property
336
+ @cached_property
337
337
def snapshot_id (self ) -> SnapshotId :
338
338
return SnapshotId (name = self .name , identifier = self .identifier )
339
339
@@ -1748,7 +1748,7 @@ def has_paused_forward_only(
1748
1748
1749
1749
1750
1750
def missing_intervals (
1751
- snapshots : t .Collection [Snapshot ],
1751
+ snapshots : t .Union [ t . Collection [Snapshot ], t . Dict [ SnapshotId , Snapshot ] ],
1752
1752
start : t .Optional [TimeLike ] = None ,
1753
1753
end : t .Optional [TimeLike ] = None ,
1754
1754
execution_time : t .Optional [TimeLike ] = None ,
@@ -1759,6 +1759,9 @@ def missing_intervals(
1759
1759
end_bounded : bool = False ,
1760
1760
) -> t .Dict [Snapshot , Intervals ]:
1761
1761
"""Returns all missing intervals given a collection of snapshots."""
1762
+ if not isinstance (snapshots , dict ):
1763
+ # Make sure that the mapping is only constructed once
1764
+ snapshots = {snapshot .snapshot_id : snapshot for snapshot in snapshots }
1762
1765
missing = {}
1763
1766
cache : t .Dict [str , datetime ] = {}
1764
1767
end_date = end or now_timestamp ()
@@ -1771,7 +1774,7 @@ def missing_intervals(
1771
1774
interval_end_per_model = interval_end_per_model or {}
1772
1775
deployability_index = deployability_index or DeployabilityIndex .all_deployable ()
1773
1776
1774
- for snapshot in snapshots :
1777
+ for snapshot in snapshots . values () :
1775
1778
if not snapshot .evaluatable :
1776
1779
continue
1777
1780
snapshot_start_date = start_dt
@@ -1944,7 +1947,7 @@ def inclusive_exclusive(
1944
1947
1945
1948
1946
1949
def earliest_start_date (
1947
- snapshots : t .Collection [Snapshot ],
1950
+ snapshots : t .Union [ t . Collection [Snapshot ], t . Dict [ SnapshotId , Snapshot ] ],
1948
1951
cache : t .Optional [t .Dict [str , datetime ]] = None ,
1949
1952
relative_to : t .Optional [TimeLike ] = None ,
1950
1953
) -> datetime :
@@ -1959,9 +1962,12 @@ def earliest_start_date(
1959
1962
"""
1960
1963
cache = {} if cache is None else cache
1961
1964
if snapshots :
1965
+ if not isinstance (snapshots , dict ):
1966
+ # Make sure that the mapping is only constructed once
1967
+ snapshots = {snapshot .snapshot_id : snapshot for snapshot in snapshots }
1962
1968
return min (
1963
1969
start_date (snapshot , snapshots , cache = cache , relative_to = relative_to )
1964
- for snapshot in snapshots
1970
+ for snapshot in snapshots . values ()
1965
1971
)
1966
1972
return yesterday ()
1967
1973
0 commit comments