From 561665ac5bb6327ecbe27e930e7b8b77d0c8cd86 Mon Sep 17 00:00:00 2001 From: Alex Langenfeld Date: Fri, 25 Oct 2024 15:02:56 -0500 Subject: [PATCH] [RemoteJob] lazy snapshot_id calculation (#25548) wait to call job_index.snapshot_id until its needed ## How I Tested These Changes existing coverage --- .../dagster/_core/remote_representation/external.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python_modules/dagster/dagster/_core/remote_representation/external.py b/python_modules/dagster/dagster/_core/remote_representation/external.py index 2b4779d8fc96e..13593124db60b 100644 --- a/python_modules/dagster/dagster/_core/remote_representation/external.py +++ b/python_modules/dagster/dagster/_core/remote_representation/external.py @@ -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") @@ -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