Overview
When working with frameworks that rely both on FEDOT and GOLEM, one can encountered a problem when trying to log using the message method. The problem is that the incorrect logging level is set, which results in an error of KeyError: 45.
This issue has already been discussed. The no-brainer solution to this unexpected behavior is to replace the level value with one of the default levels (for example, 40). Additionally, it might be appropriate to display a message that the message method is now outdated and doesn't differ from the info method.
|
def message(self, msg: str, **kwargs): |
|
""" Record the message to user. |
|
Message is an intermediate logging level between info and warning |
|
to display main info about optimization process """ |
|
level = 45 |
|
self.log(level, msg, **kwargs) |
A listing of a rather ugly workaround mock in our test suite
def mock_message(self, msg: str, **kwargs):
level = 40
self.log(level, msg, **kwargs)
@pytest.mark.parametrize('pipeline_case', LINEAR_PIPELINE_CASES, ids=str)
def test_valid_linear_pipelines(pipeline_case: LinearPipelineCase, monkeypatch):
# monkeypatch golem message function
monkeypatch.setattr(golem.core.log.LoggerAdapter, 'message', mock_message)
...
Overview
When working with frameworks that rely both on
FEDOTandGOLEM, one can encountered a problem when trying to log using themessagemethod. The problem is that the incorrect logging level is set, which results in an error ofKeyError: 45.This issue has already been discussed. The no-brainer solution to this unexpected behavior is to replace the
levelvalue with one of the default levels (for example,40). Additionally, it might be appropriate to display a message that themessagemethod is now outdated and doesn't differ from theinfomethod.GOLEM/golem/core/log.py
Lines 165 to 170 in c85a9d7
A listing of a rather ugly workaround mock in our test suite