Skip to content

Commit

Permalink
[RemoteJob] lazy snapshot_id calculation (#25548)
Browse files Browse the repository at this point in the history
wait to call job_index.snapshot_id until its needed

## How I Tested These Changes

existing coverage
  • Loading branch information
alangenfeld authored Oct 25, 2024
1 parent b019ac4 commit 561665a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,13 @@ def __init__(
if job_data_snap:
self._active_preset_dict = {ap.name: ap for ap in job_data_snap.active_presets}
self._name = job_data_snap.name
self._snapshot_id = self._job_index.job_snapshot_id

elif job_ref_snap:
self._active_preset_dict = {ap.name: ap for ap in job_ref_snap.active_presets}
self._name = job_ref_snap.name
if ref_to_data_fn is None:
check.failed("ref_to_data_fn must be passed when using deferred snapshots")
self._snapshot_id = job_ref_snap.snapshot_id

else:
check.failed("Expected either job data or ref, got neither")

Expand Down Expand Up @@ -631,6 +630,13 @@ def metadata(self) -> Mapping[str, MetadataValue]:
def job_snapshot(self) -> JobSnap:
return self._job_index.job_snapshot

@property
def _snapshot_id(self) -> str:
if self._job_ref_snap:
return self._job_ref_snap.snapshot_id

return self._job_index.job_snapshot_id

@property
def computed_job_snapshot_id(self) -> str:
return self._snapshot_id
Expand Down

0 comments on commit 561665a

Please sign in to comment.