From 0834e351fe31c4a5ed10f23f5902cc983b59f613 Mon Sep 17 00:00:00 2001 From: Scott Taubman <86254668+scott-taubman@users.noreply.github.com> Date: Fri, 14 Apr 2023 15:43:06 -0400 Subject: [PATCH] #404 - Unpin required version of packaging (#405) --- brewtils/decorators.py | 3 --- brewtils/models.py | 2 -- brewtils/request_handling.py | 2 -- brewtils/rest/system_client.py | 31 ++++++++++++++++++++++++------- brewtils/schemas.py | 1 - brewtils/test/comparable.py | 3 --- setup.cfg | 2 +- setup.py | 4 ++-- test/decorators_test.py | 1 - test/rest/system_client_test.py | 2 -- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/brewtils/decorators.py b/brewtils/decorators.py index 77a8fff3..68277034 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -120,7 +120,6 @@ def echo_json(self, message): """ if _wrapped is None: - if form is not None: _deprecate( "Use of form with @command is now deprecated and will eventually be removed" @@ -707,7 +706,6 @@ def _initialize_parameters(parameter_list): initialized_params = [] for param in parameter_list: - # This is already a Parameter. Only really need to interpret the choices # definition and recurse down into nested Parameters if isinstance(param, Parameter): @@ -774,7 +772,6 @@ def _signature_parameters(cmd, method): """ # Now we need to reconcile the parameters with the method signature for index, arg in enumerate(signature(method).parameters.values()): - # Don't want to include special parameters if (index == 0 and arg.name in ("self", "cls")) or arg.kind in ( InspectParameter.VAR_KEYWORD, diff --git a/brewtils/models.py b/brewtils/models.py index b37f8544..f674361f 100644 --- a/brewtils/models.py +++ b/brewtils/models.py @@ -955,7 +955,6 @@ def get_plugin_log_config(self, **kwargs): return LoggingConfig(level=level, handlers=handlers, formatters=formatters) def _generate_handlers(self, specific_handlers): - # If we are not given an override for handlers, then we will just # assume that we want to use all the handlers given in the current # configuration. @@ -972,7 +971,6 @@ def _generate_handlers(self, specific_handlers): return handlers def _generate_formatters(self, specific_formatters): - # If we are not given an override for formatters, then we will just # assume that we want to use the formatters given in the current # configuration diff --git a/brewtils/request_handling.py b/brewtils/request_handling.py index d19786b9..3ff50dc8 100644 --- a/brewtils/request_handling.py +++ b/brewtils/request_handling.py @@ -423,7 +423,6 @@ def update_request(self, request, headers): return with self.beergarden_error_condition: - self._wait_for_beergarden_if_down(request) try: @@ -459,7 +458,6 @@ def _wait_if_not_first_attempt(self, headers): self._shutdown_event.wait(time_to_sleep) def _handle_request_update_failure(self, request, headers, exc): - # If beergarden is down, we always want to try again # Yes, even if it is the 'final_attempt' if isinstance(exc, (RequestsConnectionError, RestConnectionError)): diff --git a/brewtils/rest/system_client.py b/brewtils/rest/system_client.py index 1b02bc77..bce8d8c2 100644 --- a/brewtils/rest/system_client.py +++ b/brewtils/rest/system_client.py @@ -6,7 +6,7 @@ from multiprocessing import cpu_count from typing import Any, Dict, Iterable, Optional -from packaging.version import parse +from packaging.version import parse, InvalidVersion import brewtils.plugin from brewtils.errors import ( @@ -443,7 +443,6 @@ def _wait_for_request(self, request, raise_on_error, timeout): delay_time = 0.5 total_wait_time = 0 while request.status not in Request.COMPLETED_STATUSES: - if timeout and 0 < timeout < total_wait_time: raise TimeoutExceededError( "Timeout waiting for request '%s' to complete" % str(request) @@ -549,8 +548,26 @@ def _resolve_parameters(self, command, request): @staticmethod def _determine_latest(systems): # type: (Iterable[System]) -> Optional[System] - return ( - sorted(systems, key=lambda x: parse(x.version), reverse=True)[0] - if systems - else None - ) + """Returns the system with the latest version from the provided list of Systems. + Any version adhering to PEP440 is treated as "later" than a version that does + not adhere to that standard. + """ + versions = [] + legacy_versions = [] + system_versions_map = {} + + for system in systems: + system_versions_map[system.version] = system + + try: + versions.append(parse(system.version)) + except InvalidVersion: + legacy_versions.append(system.version) + + eligible_versions = versions if versions else legacy_versions + + if eligible_versions: + latest_version = sorted(eligible_versions, reverse=True)[0] + return system_versions_map.get(str(latest_version)) + else: + return None diff --git a/brewtils/schemas.py b/brewtils/schemas.py index 721e50ea..e632c324 100644 --- a/brewtils/schemas.py +++ b/brewtils/schemas.py @@ -394,7 +394,6 @@ class LoggingConfigSchema(BaseSchema): class EventSchema(BaseSchema): - name = fields.Str(allow_none=True) namespace = fields.Str(allow_none=True) garden = fields.Str(allow_none=True) diff --git a/brewtils/test/comparable.py b/brewtils/test/comparable.py index 9c6f599f..da25684b 100644 --- a/brewtils/test/comparable.py +++ b/brewtils/test/comparable.py @@ -194,7 +194,6 @@ def _assert_wrapper(obj1, obj2, expected_type=None, do_raise=False, **kwargs): def assert_command_equal(obj1, obj2, do_raise=False): - return _assert_wrapper( obj1, obj2, @@ -218,7 +217,6 @@ def assert_parameter_equal(obj1, obj2, do_raise=False): def assert_event_equal(obj1, obj2, do_raise=False): - _assert(obj1.payload_type == obj2.payload_type, "Payload types were not equal") comparison_func_name = "_assert_wrapper" @@ -359,7 +357,6 @@ def assert_job_ids_equal(dict1, dict2, do_raise=False): def assert_operation_equal(obj1, obj2, do_raise=False): - _assert(obj1.model_type == obj2.model_type, "Model types were not equal") comparison_func_name = "_assert_wrapper" diff --git a/setup.cfg b/setup.cfg index 1044026b..13ffb2e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ universal = 1 [flake8] max-line-length = 100 -ignore = E203,W503 +ignore = E203,W503,F401 [isort] profile = black diff --git a/setup.py b/setup.py index cfb03e1d..a524c862 100644 --- a/setup.py +++ b/setup.py @@ -34,13 +34,13 @@ def find_version(): "lark-parser<0.7", "marshmallow<3", "marshmallow-polyfield<4", - "packaging<21", + "packaging", "pika<=1.2,>=1.0.1", "pytz<2021", "requests<3", "simplejson<4", "six<2", - "wrapt<1.13", + "wrapt", "yapconf>=0.3.7", ], extras_require={ diff --git a/test/decorators_test.py b/test/decorators_test.py index 9f2a0cb8..9d250526 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -1093,7 +1093,6 @@ def foo(self): assert "command_registrar" in str(w[0].message) def test_register(self, cmd): - # Just for sanity assert not hasattr(cmd, "_command") diff --git a/test/rest/system_client_test.py b/test/rest/system_client_test.py index 4bda20f0..e0bb8c0f 100644 --- a/test/rest/system_client_test.py +++ b/test/rest/system_client_test.py @@ -158,7 +158,6 @@ def test_latest_config_ns(self, easy_client, bg_system): ) def test_no_system_kwargs(self): - brewtils.plugin.CONFIG.namespace = "foo" brewtils.plugin.CONFIG.name = "foo" brewtils.plugin.CONFIG.version = "1.0.0" @@ -172,7 +171,6 @@ def test_no_system_kwargs(self): assert client._default_instance == brewtils.plugin.CONFIG.instance_name def test_all_system_kwargs(self): - brewtils.plugin.CONFIG.name = "foo" brewtils.plugin.CONFIG.version = "1.0.0" brewtils.plugin.CONFIG.instance_name = "foo"