From c2f91a27ee28dd1817db08b5f2bc98dcf2e2c305 Mon Sep 17 00:00:00 2001 From: 1maple1 <160027655+1maple1@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:14:28 +0000 Subject: [PATCH 01/12] Allow parameter decorator to passthrough None for type --- brewtils/decorators.py | 27 ++++++++++++++------------- test/decorators_test.py | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/brewtils/decorators.py b/brewtils/decorators.py index b27019be..7186aaa5 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -297,19 +297,20 @@ def echo(self, message): """ # Validate type against permitted string literals - if not isinstance(type, str): - # Try to map literal to string equivalent - temp_type = _format_type(type) - if temp_type in Parameter.TYPES: - type = temp_type - elif type not in Parameter.TYPES: - # Allowing type matching: string == String == STRING - for parameter_type in Parameter.TYPES: - if type.upper() == parameter_type.upper(): - type = parameter_type - break - if type not in Parameter.TYPES: - raise ValueError(f"Unable to map type {type} to string literal") + if type: + if not isinstance(type, str): + # Try to map literal to string equivalent + temp_type = _format_type(type) + if temp_type in Parameter.TYPES: + type = temp_type + elif type not in Parameter.TYPES: + # Allowing type matching: string == String == STRING + for parameter_type in Parameter.TYPES: + if type.upper() == parameter_type.upper(): + type = parameter_type + break + if type not in Parameter.TYPES: + raise ValueError(f"Unable to map type {type} to string literal") if _wrapped is None: return functools.partial( diff --git a/test/decorators_test.py b/test/decorators_test.py index 7ab81dca..4a5e3204 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -731,7 +731,7 @@ def cmd6(foo): assert cmd3.parameters[0].type == "Float" assert cmd4.parameters[0].type == "Boolean" assert cmd5.parameters[0].type == "Dictionary" - assert cmd6.parameters[0].type == "Any" + assert cmd6.parameters[0].type == None with pytest.raises(ValueError): From 7a56bf7d3fc12699768f67ed354ed38177c3af89 Mon Sep 17 00:00:00 2001 From: 1maple1 <160027655+1maple1@users.noreply.github.com> Date: Thu, 11 Jul 2024 07:20:13 -0400 Subject: [PATCH 02/12] Update CHANGELOG.rst --- CHANGELOG.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0980fd55..54fe58d0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Brewtils Changelog ================== +3.27.0 +------ +TBD + +- Fixed bug where parameter type mapping did not match type hinting + 3.26.3 ------ 7/10/24 From 3bf04ea8f54df38082eddbcd1b6b3ad29152ec74 Mon Sep 17 00:00:00 2001 From: 1maple1 <160027655+1maple1@users.noreply.github.com> Date: Thu, 11 Jul 2024 07:31:01 -0400 Subject: [PATCH 03/12] Update decorators_test.py --- test/decorators_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/decorators_test.py b/test/decorators_test.py index 4a5e3204..c7e4ad78 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -731,7 +731,7 @@ def cmd6(foo): assert cmd3.parameters[0].type == "Float" assert cmd4.parameters[0].type == "Boolean" assert cmd5.parameters[0].type == "Dictionary" - assert cmd6.parameters[0].type == None + assert cmd6.parameters[0].type is None with pytest.raises(ValueError): From b9a93e1856cc2585fc5de8e8fa5dfd9349d63506 Mon Sep 17 00:00:00 2001 From: 1maple1 <160027655+1maple1@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:28:29 -0400 Subject: [PATCH 04/12] Update CHANGELOG.rst --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 54fe58d0..a29f644f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Brewtils Changelog ================== -3.27.0 +3.26.4 ------ TBD From a06749933569004ef9ee8b709262ed04271c14ba Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:51:02 +0000 Subject: [PATCH 05/12] Include Job ID in export schema --- CHANGELOG.rst | 6 ++++++ brewtils/schemas.py | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0980fd55..4d173769 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Brewtils Changelog ================== +3.26.4 +------ +TBD + +- Expand Job Export to include Job id + 3.26.3 ------ 7/10/24 diff --git a/brewtils/schemas.py b/brewtils/schemas.py index a1fa4fbe..92427abd 100644 --- a/brewtils/schemas.py +++ b/brewtils/schemas.py @@ -556,7 +556,6 @@ 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", From 18f23e48cf8c911f2fba826451ffdca3a2944953 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:53:51 +0000 Subject: [PATCH 06/12] fix testing --- brewtils/test/fixtures.py | 1 - 1 file changed, 1 deletion(-) diff --git a/brewtils/test/fixtures.py b/brewtils/test/fixtures.py index 8f940d9d..3996cc8b 100644 --- a/brewtils/test/fixtures.py +++ b/brewtils/test/fixtures.py @@ -629,7 +629,6 @@ 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", From 5e8cf05968ac84e1be34183710a8009e4935859f Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:33:43 +0000 Subject: [PATCH 07/12] Add function to provide read-only of the current request --- CHANGELOG.rst | 6 ++++++ brewtils/__init__.py | 3 ++- brewtils/plugin.py | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0980fd55..e760c369 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Brewtils Changelog ================== +3.26.4 +------ +TBD + +- Exposed a read only feature to provide the current request that is being processed `from brewtils import get_current_request_read_only` + 3.26.3 ------ 7/10/24 diff --git a/brewtils/__init__.py b/brewtils/__init__.py index 5ac46e04..b757edf2 100644 --- a/brewtils/__init__.py +++ b/brewtils/__init__.py @@ -4,7 +4,7 @@ from brewtils.config import get_argument_parser, get_connection_info, load_config from brewtils.decorators import client, command, parameter, subscribe, system from brewtils.log import configure_logging -from brewtils.plugin import Plugin, RemotePlugin # noqa F401 +from brewtils.plugin import get_current_request_read_only, Plugin, RemotePlugin # noqa F401 from brewtils.rest import normalize_url_prefix from brewtils.rest.easy_client import EasyClient, get_easy_client from brewtils.rest.publish_client import PublishClient @@ -28,6 +28,7 @@ "configure_logging", "normalize_url_prefix", "AutoDecorator", + "get_current_request_read_only" ] # Aliased for compatibility diff --git a/brewtils/plugin.py b/brewtils/plugin.py index 1c07943a..f40b6c35 100644 --- a/brewtils/plugin.py +++ b/brewtils/plugin.py @@ -45,6 +45,13 @@ # Global config, used to simplify BG client creation and sanity checks. CONFIG = Box(default_box=True) +def get_current_request_read_only(): + """ Read-Only instance of Current Request + + Returns a copy of the current request, modifications to this object + does not impact the actual current request + """ + return copy.deepcopy(request_context.current_request) class Plugin(object): """A Beer-garden Plugin From d29e8faba376b86d3d962e24783ca64ea251c7cc Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:40:03 +0000 Subject: [PATCH 08/12] add import statement --- brewtils/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/brewtils/plugin.py b/brewtils/plugin.py index f40b6c35..f129ba6d 100644 --- a/brewtils/plugin.py +++ b/brewtils/plugin.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import copy import json import logging import logging.config From 475841883cdb5f235f455771c9e27f7277709bae Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:41:50 +0000 Subject: [PATCH 09/12] formatting --- brewtils/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/brewtils/plugin.py b/brewtils/plugin.py index f129ba6d..3da6d847 100644 --- a/brewtils/plugin.py +++ b/brewtils/plugin.py @@ -46,14 +46,16 @@ # Global config, used to simplify BG client creation and sanity checks. CONFIG = Box(default_box=True) + def get_current_request_read_only(): - """ Read-Only instance of Current Request + """Read-Only instance of Current Request Returns a copy of the current request, modifications to this object does not impact the actual current request """ return copy.deepcopy(request_context.current_request) + class Plugin(object): """A Beer-garden Plugin From 6251ea19144765cb10e953c89887f7838c053898 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:42:48 +0000 Subject: [PATCH 10/12] formatting --- brewtils/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/brewtils/__init__.py b/brewtils/__init__.py index b757edf2..0fe5ec1d 100644 --- a/brewtils/__init__.py +++ b/brewtils/__init__.py @@ -4,7 +4,11 @@ from brewtils.config import get_argument_parser, get_connection_info, load_config from brewtils.decorators import client, command, parameter, subscribe, system from brewtils.log import configure_logging -from brewtils.plugin import get_current_request_read_only, Plugin, RemotePlugin # noqa F401 +from brewtils.plugin import ( + get_current_request_read_only, + Plugin, + RemotePlugin, +) # noqa F401 from brewtils.rest import normalize_url_prefix from brewtils.rest.easy_client import EasyClient, get_easy_client from brewtils.rest.publish_client import PublishClient @@ -28,7 +32,7 @@ "configure_logging", "normalize_url_prefix", "AutoDecorator", - "get_current_request_read_only" + "get_current_request_read_only", ] # Aliased for compatibility From c56cdb933d328a7522a2215a84aa1987e9c03319 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:49:40 -0400 Subject: [PATCH 11/12] Update plugin.py --- brewtils/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brewtils/plugin.py b/brewtils/plugin.py index 3da6d847..a4724c02 100644 --- a/brewtils/plugin.py +++ b/brewtils/plugin.py @@ -51,7 +51,7 @@ def get_current_request_read_only(): """Read-Only instance of Current Request Returns a copy of the current request, modifications to this object - does not impact the actual current request + do not impact the actual current request """ return copy.deepcopy(request_context.current_request) From 44770ad6c0b3e7a320d46b30996fe7117d4f45e1 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:53:25 +0000 Subject: [PATCH 12/12] 3.26.4 --- CHANGELOG.rst | 2 +- brewtils/__version__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ed2f3277..261d77d5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,7 @@ Brewtils Changelog 3.26.4 ------ -TBD +7/12/24 - Fixed bug where parameter type mapping did not match type hinting - Exposed a read only feature to provide the current request that is being processed `from brewtils import get_current_request_read_only` diff --git a/brewtils/__version__.py b/brewtils/__version__.py index 3e4329cf..c5d46780 100644 --- a/brewtils/__version__.py +++ b/brewtils/__version__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -__version__ = "3.26.3" +__version__ = "3.26.4"