@@ -160,40 +160,26 @@ def evaluate(
160160 if not plan .requires_backfill :
161161 self .console .log_success ("Virtual Update executed successfully" )
162162
163- model_kind_counts : t .Dict [str , int ] = {}
164- audit_counts : t .Dict [str , int ] = {}
165- for snapshot in snapshots .values ():
166- if snapshot .name in all_names :
167- if snapshot .is_audit :
168- audit_counts ["standalone" ] = audit_counts .get ("standalone" , 0 ) + 1
169- if (
170- snapshot .is_model
171- and snapshot .model_kind_name
172- and snapshot .model .kind
173- and not snapshot .model .kind .is_external
174- and not snapshot .model .kind .is_embedded
175- ):
176- kind_name = snapshot .model_kind_name
177- model_kind_counts [kind_name ] = model_kind_counts .get (kind_name , 0 ) + 1
178- if snapshot .is_model and snapshot .model .audits :
179- if snapshot .model .kind .is_external :
180- audit_counts ["EXTERNAL model" ] = audit_counts .get (
181- "EXTERNAL model" , 0
182- ) + len (snapshot .model .audits )
183- else :
184- audit_counts ["model" ] = audit_counts .get ("model" , 0 ) + len (
185- snapshot .model .audits
186- )
187-
188- summary_str = ", " .join (
189- [f"{ v } { k } model{ 's' if v > 1 else '' } " for k , v in model_kind_counts .items ()]
163+ snapshots_to_count : t .List [SnapshotId ] = [
164+ * plan .directly_modified_snapshots ,
165+ * plan .removed_snapshots ,
166+ ] + [
167+ snapshot_id
168+ for snapshot_ids in plan .indirectly_modified_snapshots .values ()
169+ for snapshot_id in snapshot_ids
170+ ]
171+
172+ removed_snapshots = [
173+ s
174+ for s in (plan .environment .previous_finalized_snapshots or [])
175+ if s .snapshot_id in snapshots_to_count
176+ ]
177+ summary_msg = _create_plan_summary_msg (
178+ [* snapshots .values (), * removed_snapshots ], snapshots_to_count
190179 )
191- for audit_type in ["EXTERNAL model" , "model" , "standalone" ]:
192- if audit_type in audit_counts :
193- count = audit_counts [audit_type ]
194- summary_str += f", { count } { audit_type } audit{ 's' if count > 1 else '' } "
195- if summary_str :
196- self .console .log_status_update (f"Plan applied for { summary_str } " )
180+
181+ if summary_msg :
182+ self .console .log_status_update (f"Plan applied for { summary_msg } " )
197183
198184 execute_environment_statements (
199185 adapter = self .snapshot_evaluator .adapter ,
@@ -396,8 +382,14 @@ def _update_views(
396382
397383 environment = plan .environment
398384
385+ # progress bar should only show snapshots that have a virtual layer view
386+ snapshots_with_virtual_views = [
387+ s .snapshot_id
388+ for s in [* promotion_result .added , * promotion_result .removed ]
389+ if s .is_model and s .model_kind_name and not s .model_kind_name .is_symbolic
390+ ]
399391 self .console .start_promotion_progress (
400- len (promotion_result . added ) + len ( promotion_result . removed ),
392+ len (snapshots_with_virtual_views ),
401393 environment .naming_info ,
402394 self .default_catalog ,
403395 )
@@ -409,15 +401,19 @@ def _update_views(
409401 [snapshots [s .snapshot_id ] for s in promotion_result .added ],
410402 environment .naming_info ,
411403 deployability_index = deployability_index ,
412- on_complete = lambda s : self .console .update_promotion_progress (s , True ),
404+ on_complete = lambda s : self .console .update_promotion_progress (
405+ s , True , snapshots_with_virtual_views
406+ ),
413407 snapshots = snapshots ,
414408 )
415409 if promotion_result .removed_environment_naming_info :
416410 self ._demote_snapshots (
417411 plan ,
418412 promotion_result .removed ,
419413 promotion_result .removed_environment_naming_info ,
420- on_complete = lambda s : self .console .update_promotion_progress (s , False ),
414+ on_complete = lambda s : self .console .update_promotion_progress (
415+ s , False , snapshots_with_virtual_views
416+ ),
421417 )
422418
423419 self .state_sync .finalize (environment )
@@ -772,3 +768,46 @@ def update_intervals_for_new_snapshots(
772768
773769 if snapshots_intervals :
774770 state_sync .add_snapshots_intervals (snapshots_intervals )
771+
772+
773+ def _create_plan_summary_msg (
774+ snapshots : t .Iterable [SnapshotInfoLike ], snapshots_to_count : t .List [SnapshotId ]
775+ ) -> str :
776+ model_kind_counts : t .Dict [str , int ] = {}
777+ audit_counts : t .Dict [str , int ] = {}
778+ for snapshot in snapshots :
779+ if snapshot .snapshot_id in snapshots_to_count :
780+ if snapshot .is_audit :
781+ audit_counts ["standalone" ] = audit_counts .get ("standalone" , 0 ) + 1
782+ if (
783+ snapshot .is_model
784+ and snapshot .model_kind_name
785+ and not snapshot .model_kind_name .is_symbolic
786+ ):
787+ kind_name = snapshot .model_kind_name
788+ model_kind_counts [kind_name ] = model_kind_counts .get (kind_name , 0 ) + 1
789+ if (
790+ snapshot .is_model
791+ # removed snapshot SnapshotTableInfos don't have `model`
792+ and hasattr (snapshot , "model" )
793+ and snapshot .model
794+ and snapshot .model .audits
795+ ):
796+ if snapshot .model .kind .is_external : # type: ignore
797+ audit_counts ["EXTERNAL model" ] = audit_counts .get ("EXTERNAL model" , 0 ) + len (
798+ snapshot .model .audits # type: ignore
799+ )
800+ else :
801+ audit_counts ["model" ] = audit_counts .get ("model" , 0 ) + len (
802+ snapshot .model .audits # type: ignore
803+ )
804+
805+ summary_str = ", " .join (
806+ [f"{ v } { k } model{ 's' if v > 1 else '' } " for k , v in model_kind_counts .items ()]
807+ )
808+ for audit_type in ["EXTERNAL model" , "model" , "standalone" ]:
809+ if audit_type in audit_counts :
810+ count = audit_counts [audit_type ]
811+ summary_str += f", { count } { audit_type } audit{ 's' if count > 1 else '' } "
812+
813+ return summary_str
0 commit comments