From 7f6c339740b9c69f438b00e45af2887030c95571 Mon Sep 17 00:00:00 2001 From: Helen Koike Date: Fri, 29 Sep 2023 18:41:19 -0300 Subject: [PATCH] ci/ci_run_n_monitor: simplify with defaultdict Signed-off-by: Helen Koike Part-of: --- bin/ci/ci_run_n_monitor.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index d06f1768dc3..92a26eb4e20 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -98,8 +98,8 @@ def monitor_pipeline( stress: bool, ) -> tuple[Optional[int], Optional[int]]: """Monitors pipeline and delegate canceling jobs""" - statuses = {} - target_statuses = {} + statuses: dict[int, str] = defaultdict(str) + target_statuses: dict[int, str] = defaultdict(str) stress_status_counter = defaultdict(lambda: defaultdict(int)) if target_job: @@ -117,9 +117,7 @@ def monitor_pipeline( stress_status_counter[job.name][job.status] += 1 retry_job(project, job) - if (job.id not in target_statuses) or ( - job.status not in target_statuses[job.id] - ): + if job.status not in target_statuses[job.id]: print_job_status_change(job) target_statuses[job.id] = job.status else: @@ -128,7 +126,7 @@ def monitor_pipeline( continue # all jobs - if (job.id not in statuses) or (job.status not in statuses[job.id]): + if job.status not in statuses[job.id]: print_job_status_change(job) statuses[job.id] = job.status