Skip to content

[Bug]: obsolete custom message logging #282

@Lopa10ko

Description

@Lopa10ko

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.

GOLEM/golem/core/log.py

Lines 165 to 170 in c85a9d7

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)
   ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions