diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0980fd55..261d77d5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Brewtils Changelog ================== +3.26.4 +------ +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` +- Expand Job Export to include Job id + 3.26.3 ------ 7/10/24 diff --git a/brewtils/__init__.py b/brewtils/__init__.py index 5ac46e04..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 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 +32,7 @@ "configure_logging", "normalize_url_prefix", "AutoDecorator", + "get_current_request_read_only", ] # Aliased for compatibility 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" 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/brewtils/plugin.py b/brewtils/plugin.py index 1c07943a..a4724c02 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 @@ -46,6 +47,15 @@ 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 + do not impact the actual current request + """ + return copy.deepcopy(request_context.current_request) + + class Plugin(object): """A Beer-garden Plugin diff --git a/brewtils/schemas.py b/brewtils/schemas.py index f7459ca1..51283183 100644 --- a/brewtils/schemas.py +++ b/brewtils/schemas.py @@ -564,7 +564,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", diff --git a/brewtils/test/fixtures.py b/brewtils/test/fixtures.py index 132b33c5..da7570d7 100644 --- a/brewtils/test/fixtures.py +++ b/brewtils/test/fixtures.py @@ -631,7 +631,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", diff --git a/test/decorators_test.py b/test/decorators_test.py index 7ab81dca..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 == "Any" + assert cmd6.parameters[0].type is None with pytest.raises(ValueError):