Skip to content

Commit

Permalink
Call _validate_config() from Config.freeze() instead of the attribute…
Browse files Browse the repository at this point in the history
… setters, avoids issue where setting attributes becomes order dependent
  • Loading branch information
dagardner-nv committed Nov 7, 2024
1 parent db07ec1 commit 88dca95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions python/morpheus/morpheus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def freeze(self):
"""
self._check_cpp_mode(fix_mis_match=not self.frozen)
if not self.frozen:
self._validate_config()
self.frozen = True

def _check_cpp_mode(self, fix_mis_match: bool = False):
Expand Down Expand Up @@ -267,7 +268,6 @@ def pipeline_batch_size(self):
@pipeline_batch_size.setter
def pipeline_batch_size(self, value: int):
self._pipeline_batch_size = value
self._validate_config()

@property
def model_max_batch_size(self):
Expand All @@ -276,7 +276,6 @@ def model_max_batch_size(self):
@model_max_batch_size.setter
def model_max_batch_size(self, value: int):
self._model_max_batch_size = value
self._validate_config()

def _validate_config(self):
if self._pipeline_batch_size < self._model_max_batch_size:
Expand Down
2 changes: 2 additions & 0 deletions tests/morpheus/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def test_warning_model_batch_size_less_than_pipeline_batch_size(caplog: pytest.L
config.pipeline_batch_size = 256
with caplog.at_level(logging.WARNING):
config.model_max_batch_size = 257
config.freeze()
assert len(caplog.records) == 1
import re
assert re.match(".*pipeline_batch_size < model_max_batch_size.*", caplog.records[0].message) is not None
Expand All @@ -169,6 +170,7 @@ def test_warning_pipeline_batch_size_less_than_model_batch_size(caplog: pytest.L
config.model_max_batch_size = 8
with caplog.at_level(logging.WARNING):
config.pipeline_batch_size = 7
config.freeze()
assert len(caplog.records) == 1
import re
assert re.match(".*pipeline_batch_size < model_max_batch_size.*", caplog.records[0].message) is not None

0 comments on commit 88dca95

Please sign in to comment.