Skip to content

Commit

Permalink
Merge branch 'develop' into Status_Info_Model
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed Jul 15, 2024
2 parents 36f423c + 304bc8f commit b410c2f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion brewtils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,6 +32,7 @@
"configure_logging",
"normalize_url_prefix",
"AutoDecorator",
"get_current_request_read_only",
]

# Aliased for compatibility
Expand Down
2 changes: 1 addition & 1 deletion brewtils/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = "3.26.3"
__version__ = "3.26.4"
27 changes: 14 additions & 13 deletions brewtils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions brewtils/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import copy
import json
import logging
import logging.config
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion brewtils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion brewtils/test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/decorators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit b410c2f

Please sign in to comment.