From cb13abb16c4a086f3c150a2ff75d680f35017b67 Mon Sep 17 00:00:00 2001 From: Christopher Harris Date: Fri, 23 Aug 2024 18:14:49 +0000 Subject: [PATCH] convert to using logging.warning --- python/morpheus/morpheus/config.py | 2 +- tests/test_config.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/python/morpheus/morpheus/config.py b/python/morpheus/morpheus/config.py index cce03bb750..eae5d5d78e 100644 --- a/python/morpheus/morpheus/config.py +++ b/python/morpheus/morpheus/config.py @@ -241,7 +241,7 @@ def model_max_batch_size(self, value: int): def _validate_config(self): if self._pipeline_batch_size < self._model_max_batch_size: - warnings.warn( + logging.warning( "Config has `pipeline_batch_size < model_max_batch_size` which effectively limits `model_max_batch_size`. This may reduce performance." ) diff --git a/tests/test_config.py b/tests/test_config.py index 232d1d35e7..0311624d16 100755 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -17,6 +17,7 @@ import json import os from unittest import mock +import logging import pytest @@ -108,15 +109,21 @@ def test_to_string(config): assert isinstance(json.loads(conf_str), dict) -def test_warning_model_batch_size_less_than_pipeline_batch_size(): +def test_warning_model_batch_size_less_than_pipeline_batch_size(caplog: pytest.LogCaptureFixture): config = morpheus.config.Config() config.pipeline_batch_size = 256 - with pytest.warns(): + with caplog.at_level(logging.WARNING): config.model_max_batch_size = 257 + assert len(caplog.records) == 1 + import re + assert re.match(".*pipeline_batch_size < model_max_batch_size.*", caplog.records[0].message) is not None -def test_warning_pipeline_batch_size_less_than_model_batch_size(): +def test_warning_pipeline_batch_size_less_than_model_batch_size(caplog: pytest.LogCaptureFixture): config = morpheus.config.Config() config.model_max_batch_size = 8 - with pytest.warns(): + with caplog.at_level(logging.WARNING): config.pipeline_batch_size = 7 + assert len(caplog.records) == 1 + import re + assert re.match(".*pipeline_batch_size < model_max_batch_size.*", caplog.records[0].message) is not None