From ccfedab4e300eb5c2d5ef9577da0a62f102b38d5 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:25:03 -0500 Subject: [PATCH 1/2] Expand job model --- CHANGELOG.rst | 1 + brewtils/models.py | 4 ++++ brewtils/schemas.py | 4 +++- brewtils/test/fixtures.py | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8cf4a302..2da079da 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,7 @@ TBD - Fixed self reference bug that was returning back output instead of Request object. - Fixed self reference bug, when SystemClient calls itself but doesn't have a current request. This allows for support to run SystemClient in a sub-thread to the plugin. +- Expand Job model to include Skipped and Canceled counters 3.23.0 ------ diff --git a/brewtils/models.py b/brewtils/models.py index 95b5c241..f1f99128 100644 --- a/brewtils/models.py +++ b/brewtils/models.py @@ -1192,6 +1192,8 @@ def __init__( next_run_time=None, success_count=None, error_count=None, + canceled_count=None, + skip_count=None, status=None, max_instances=None, timeout=None, @@ -1206,6 +1208,8 @@ def __init__( self.next_run_time = next_run_time self.success_count = success_count self.error_count = error_count + self.canceled_count = canceled_count + self.skip_count = skip_count self.status = status self.max_instances = max_instances self.timeout = timeout diff --git a/brewtils/schemas.py b/brewtils/schemas.py index e3c9c94d..535a84e1 100644 --- a/brewtils/schemas.py +++ b/brewtils/schemas.py @@ -516,6 +516,8 @@ class JobSchema(BaseSchema): next_run_time = DateTime(allow_none=True, format="epoch", example="1500065932000") success_count = fields.Int(allow_none=True) error_count = fields.Int(allow_none=True) + canceled_count = fields.Int(allow_none=True) + skip_count = fields.Int(allow_none=True) status = fields.Str(allow_none=True) max_instances = fields.Int(allow_none=True) timeout = fields.Int(allow_none=True) @@ -529,7 +531,7 @@ class JobExportSchema(JobSchema): def __init__(self, *args, **kwargs): # exclude fields from a Job that we don't want when we later go to import # the Job definition - self.opts.exclude += ("id", "next_run_time", "success_count", "error_count") + self.opts.exclude += ("id", "next_run_time", "success_count", "error_count", "canceled_count", "skip_count") super(JobExportSchema, self).__init__(*args, **kwargs) @post_load diff --git a/brewtils/test/fixtures.py b/brewtils/test/fixtures.py index 81f1fd91..20b3988e 100644 --- a/brewtils/test/fixtures.py +++ b/brewtils/test/fixtures.py @@ -569,6 +569,8 @@ def job_dict(ts_epoch, request_template_dict, date_trigger_dict): "next_run_time": ts_epoch, "success_count": 0, "error_count": 0, + "canceled_count": 0, + "skip_count": 0, "status": "RUNNING", "max_instances": 3, "timeout": 30, @@ -616,7 +618,7 @@ def job_ids_dict(job_dict): def job_dict_for_import(job_dict): """A job dict but some keys and values are missing.""" dict_copy = copy.deepcopy(job_dict) - for field in ["id", "next_run_time", "success_count", "error_count"]: + for field in ["id", "next_run_time", "success_count", "error_count","canceled_count","skip_count"]: dict_copy.pop(field, None) return dict_copy From 46361be965d3bbbb5991d8d9cef874acb3bfd6a3 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:28:14 -0500 Subject: [PATCH 2/2] formatting --- brewtils/schemas.py | 9 ++++++++- brewtils/test/fixtures.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/brewtils/schemas.py b/brewtils/schemas.py index 535a84e1..19301a03 100644 --- a/brewtils/schemas.py +++ b/brewtils/schemas.py @@ -531,7 +531,14 @@ class JobExportSchema(JobSchema): def __init__(self, *args, **kwargs): # exclude fields from a Job that we don't want when we later go to import # the Job definition - self.opts.exclude += ("id", "next_run_time", "success_count", "error_count", "canceled_count", "skip_count") + self.opts.exclude += ( + "id", + "next_run_time", + "success_count", + "error_count", + "canceled_count", + "skip_count", + ) super(JobExportSchema, self).__init__(*args, **kwargs) @post_load diff --git a/brewtils/test/fixtures.py b/brewtils/test/fixtures.py index 20b3988e..4d10930a 100644 --- a/brewtils/test/fixtures.py +++ b/brewtils/test/fixtures.py @@ -618,7 +618,14 @@ def job_ids_dict(job_dict): def job_dict_for_import(job_dict): """A job dict but some keys and values are missing.""" dict_copy = copy.deepcopy(job_dict) - for field in ["id", "next_run_time", "success_count", "error_count","canceled_count","skip_count"]: + for field in [ + "id", + "next_run_time", + "success_count", + "error_count", + "canceled_count", + "skip_count", + ]: dict_copy.pop(field, None) return dict_copy