33import random
44import time
55from collections .abc import Iterable , Sequence
6- from typing import TYPE_CHECKING
6+ from typing import TYPE_CHECKING , TypedDict
77
88import click
99from sqlalchemy .orm import Session , sessionmaker
@@ -145,7 +145,7 @@ def record_batch(
145145 targeted_runs : int ,
146146 skipped_runs : int ,
147147 deleted_runs : int ,
148- related_counts : dict [ str , int ] | None ,
148+ related_counts : RelatedCountsDict | None ,
149149 related_action : str | None ,
150150 batch_duration_seconds : float ,
151151 ) -> None :
@@ -173,6 +173,15 @@ def record_completion(self, *, status: str, job_duration_seconds: float) -> None
173173 self ._record (self ._job_duration_seconds , job_duration_seconds , attributes )
174174
175175
176+ class RelatedCountsDict (TypedDict ):
177+ node_executions : int
178+ offloads : int
179+ app_logs : int
180+ trigger_logs : int
181+ pauses : int
182+ pause_reasons : int
183+
184+
176185class WorkflowRunCleanup :
177186 def __init__ (
178187 self ,
@@ -506,7 +515,7 @@ def _count_trigger_logs(self, session: Session, run_ids: Sequence[str]) -> int:
506515 return trigger_repo .count_by_run_ids (run_ids )
507516
508517 @staticmethod
509- def _empty_related_counts () -> dict [ str , int ] :
518+ def _empty_related_counts () -> RelatedCountsDict :
510519 return {
511520 "node_executions" : 0 ,
512521 "offloads" : 0 ,
@@ -517,7 +526,7 @@ def _empty_related_counts() -> dict[str, int]:
517526 }
518527
519528 @staticmethod
520- def _format_related_counts (counts : dict [ str , int ] ) -> str :
529+ def _format_related_counts (counts : RelatedCountsDict ) -> str :
521530 return (
522531 f"node_executions { counts ['node_executions' ]} , "
523532 f"offloads { counts ['offloads' ]} , "
0 commit comments