Skip to content

Commit 8000bfb

Browse files
authored
Fix: column width for execution progress bar with standalone audit (#4186)
1 parent 1473bc6 commit 8000bfb

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

sqlmesh/core/console.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,7 +3379,13 @@ def _calculate_audit_str_len(batched_intervals: t.Dict[Snapshot, t.List[Interval
33793379
# until after evaluation occurs, but we must determine the annotation column width here.
33803380
# Therefore, we add enough padding for the longest possible audits result string.
33813381
audit_str_len = 0
3382+
audit_base_str_len = len(f", audits ") + 1 # +1 for check/X
33823383
for snapshot in batched_intervals:
3384+
if snapshot.is_audit:
3385+
# +1 for "1" audit count, +1 for red X
3386+
audit_str_len = max(
3387+
audit_str_len, audit_base_str_len + (2 if not snapshot.audit.blocking else 1)
3388+
)
33833389
if snapshot.is_model and snapshot.model.audits:
33843390
num_audits = len(snapshot.model.audits_with_args)
33853391
num_nonblocking_audits = sum(
@@ -3388,11 +3394,14 @@ def _calculate_audit_str_len(batched_intervals: t.Dict[Snapshot, t.List[Interval
33883394
if not audit[0].blocking
33893395
or ("blocking" in audit[1] and audit[1]["blocking"] == exp.false())
33903396
)
3391-
# make enough room for all audits to pass
3392-
audit_len = len(f", audits {CHECK_MARK}{str(num_audits)}")
3393-
if num_nonblocking_audits:
3394-
# and add enough room for all nonblocking audits to fail
3395-
audit_len += len(f" {RED_X_MARK}{str(num_nonblocking_audits)}") + 1
3397+
if num_audits == 1:
3398+
# +1 for "1" audit count, +1 for red X
3399+
audit_len = audit_base_str_len + (2 if num_nonblocking_audits else 1)
3400+
else:
3401+
audit_len = audit_base_str_len + len(str(num_audits))
3402+
if num_nonblocking_audits:
3403+
# +1 for space, +1 for red X
3404+
audit_len += len(str(num_nonblocking_audits)) + 2
33963405
audit_str_len = max(audit_str_len, audit_len)
33973406
return audit_str_len
33983407

0 commit comments

Comments
 (0)