2626from databricks .labs .ucx .hive_metastore .tables import FasterTableScanCrawler , Table
2727from databricks .labs .ucx .hive_metastore .udfs import Udf
2828from databricks .labs .ucx .installer .logs import TaskRunWarningRecorder
29- from databricks .labs .ucx .progress .history import HistoryLog
29+ from databricks .labs .ucx .progress .history import ProgressEncoder
30+ from databricks .labs .ucx .progress .jobs import JobsProgressEncoder
3031from databricks .labs .ucx .progress .workflow_runs import WorkflowRunRecorder
3132
3233# As with GlobalContext, service factories unavoidably have a lot of public methods.
@@ -137,7 +138,7 @@ def task_run_warning_recorder(self) -> TaskRunWarningRecorder:
137138 self ._config_path .parent ,
138139 self .named_parameters ["workflow" ],
139140 int (self .named_parameters ["job_id" ]),
140- int ( self .named_parameters [ " parent_run_id" ]) ,
141+ self .parent_run_id ,
141142 self .sql_backend ,
142143 self .inventory_database ,
143144 int (self .named_parameters .get ("attempt" , "0" )),
@@ -151,7 +152,7 @@ def workflow_run_recorder(self) -> WorkflowRunRecorder:
151152 workspace_id = self .workspace_id ,
152153 workflow_name = self .named_parameters ["workflow" ],
153154 workflow_id = int (self .named_parameters ["job_id" ]),
154- workflow_run_id = int ( self .named_parameters [ " parent_run_id" ]) ,
155+ workflow_run_id = self .parent_run_id ,
155156 workflow_run_attempt = int (self .named_parameters .get ("attempt" , 0 )),
156157 workflow_start_time = self .named_parameters ["start_time" ],
157158 )
@@ -161,89 +162,94 @@ def workspace_id(self) -> int:
161162 return self .workspace_client .get_workspace_id ()
162163
163164 @cached_property
164- def historical_clusters_log (self ) -> HistoryLog [ClusterInfo ]:
165- return HistoryLog (
165+ def parent_run_id (self ) -> int :
166+ return int (self .named_parameters ["parent_run_id" ])
167+
168+ @cached_property
169+ def clusters_progress (self ) -> ProgressEncoder [ClusterInfo ]:
170+ return ProgressEncoder (
166171 self .sql_backend ,
167172 self .cluster_ownership ,
168173 ClusterInfo ,
169- int ( self .named_parameters [ " parent_run_id" ]) ,
174+ self .parent_run_id ,
170175 self .workspace_id ,
171176 self .config .ucx_catalog ,
172177 )
173178
174179 @cached_property
175- def historical_cluster_policies_log (self ) -> HistoryLog [PolicyInfo ]:
176- return HistoryLog (
180+ def policies_progress (self ) -> ProgressEncoder [PolicyInfo ]:
181+ return ProgressEncoder (
177182 self .sql_backend ,
178183 self .cluster_policy_ownership ,
179184 PolicyInfo ,
180- int ( self .named_parameters [ " parent_run_id" ]) ,
185+ self .parent_run_id ,
181186 self .workspace_id ,
182187 self .config .ucx_catalog ,
183188 )
184189
185190 @cached_property
186- def historical_grants_log (self ) -> HistoryLog [Grant ]:
187- return HistoryLog (
191+ def grants_progress (self ) -> ProgressEncoder [Grant ]:
192+ return ProgressEncoder (
188193 self .sql_backend ,
189194 self .grant_ownership ,
190195 Grant ,
191- int ( self .named_parameters [ " parent_run_id" ]) ,
196+ self .parent_run_id ,
192197 self .workspace_id ,
193198 self .config .ucx_catalog ,
194199 )
195200
196201 @cached_property
197- def historical_jobs_log (self ) -> HistoryLog [JobInfo ]:
198- return HistoryLog (
202+ def jobs_progress (self ) -> ProgressEncoder [JobInfo ]:
203+ return JobsProgressEncoder (
199204 self .sql_backend ,
200205 self .job_ownership ,
201- JobInfo ,
202- int ( self .named_parameters [ " parent_run_id" ]) ,
206+ self . inventory_database ,
207+ self .parent_run_id ,
203208 self .workspace_id ,
204209 self .config .ucx_catalog ,
205210 )
206211
207212 @cached_property
208- def historical_pipelines_log (self ) -> HistoryLog [PipelineInfo ]:
209- return HistoryLog (
213+ def pipelines_progress (self ) -> ProgressEncoder [PipelineInfo ]:
214+ return ProgressEncoder (
210215 self .sql_backend ,
211216 self .pipeline_ownership ,
212217 PipelineInfo ,
213- int ( self .named_parameters [ " parent_run_id" ]) ,
218+ self .parent_run_id ,
214219 self .workspace_id ,
215220 self .config .ucx_catalog ,
216221 )
217222
218223 @cached_property
219- def historical_tables_log (self ) -> HistoryLog [Table ]:
220- return HistoryLog (
224+ def tables_progress (self ) -> ProgressEncoder [Table ]:
225+ return ProgressEncoder (
221226 self .sql_backend ,
222227 self .table_ownership ,
223228 Table ,
224- int ( self .named_parameters [ " parent_run_id" ]) ,
229+ self .parent_run_id ,
225230 self .workspace_id ,
226231 self .config .ucx_catalog ,
227232 )
228233
229234 @cached_property
230- def historical_table_migration_log (self ) -> HistoryLog [TableMigrationStatus ]:
231- return HistoryLog (
235+ def historical_table_migration_log (self ) -> ProgressEncoder [TableMigrationStatus ]:
236+ # TODO: merge into tables_progress
237+ return ProgressEncoder (
232238 self .sql_backend ,
233239 self .table_migration_ownership ,
234240 TableMigrationStatus ,
235- int ( self .named_parameters [ " parent_run_id" ]) ,
241+ self .parent_run_id ,
236242 self .workspace_id ,
237243 self .config .ucx_catalog ,
238244 )
239245
240246 @cached_property
241- def historical_udfs_log (self ) -> HistoryLog [Udf ]:
242- return HistoryLog (
247+ def udfs_progress (self ) -> ProgressEncoder [Udf ]:
248+ return ProgressEncoder (
243249 self .sql_backend ,
244250 self .udf_ownership ,
245251 Udf ,
246- int ( self .named_parameters [ " parent_run_id" ]) ,
252+ self .parent_run_id ,
247253 self .workspace_id ,
248254 self .config .ucx_catalog ,
249255 )
0 commit comments