Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print version on debug verbosity level #765

Conversation

nurbal
Copy link
Contributor

@nurbal nurbal commented Jan 19, 2022

Description

Prints Orion version if verbose level is debug.

% orion -vv

Implements changes requested in issue #735.

Changes

Quite straitforward.

Checklist

Tests

  • I added corresponding tests for bug fixes and new features. If possible, the tests fail without the changes
  • All new and existing tests are passing

Documentation

  • I have updated the relevant documentation related to my changes

Quality

  • I have read the CONTRIBUTING doc
  • My commits messages follow this format
  • My code follows the style guidelines ($ tox -e lint)

Further comments

n/a

caplog.set_level(logging.DEBUG)
with pytest.raises(SystemExit):
orion.core.cli.main([""])
assert "Orion version : " not in caplog.text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea to test that the log was effective at the DEBUG level only. Instead of testing with INFO and then with DEBUG you could use record_tuples to verify the level at which the message was logged:

You can also resort to record_tuples if all you want to do is to ensure, that certain messages have been logged under a given logger name with a given severity and message:

def test_foo(caplog):
    logging.getLogger().info("boo %s", "arg")

    assert caplog.record_tuples == [("root", logging.INFO, "boo arg")]

https://docs.pytest.org/en/6.2.x/logging.html#caplog-fixture

@@ -71,6 +74,7 @@ def parse(self, argv):
format="%(asctime)-15s::%(levelname)s::%(name)s::%(message)s",
level=levels.get(verbose, logging.DEBUG),
)
logger.debug("Orion version : " + orion.core.__version__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have an error here: https://github.com/Epistimio/orion/runs/4939592554?check_suite_focus=true#step:5:15
This is because pylint prefers a format with strings using '%s' instead of concatenating them. So it should rather be

logger.debug("Orion version : %s", orion.core.__version__)

Sorry I didn't catch this in the first place. 😅

@bouthilx
Copy link
Member

@nurbal The current error is not due to your PR, it is due to some new release of numpydoc. I made a fix in PR #771. I'll restart the tests when the fix is merged.

@bouthilx
Copy link
Member

PR #771 is merged. I relaunched the tests.

@bouthilx bouthilx merged commit 41f0371 into Epistimio:develop Jan 26, 2022
@bouthilx bouthilx added the enhancement Improves a feature or non-functional aspects (e.g., optimization, prettify, technical debt) label Feb 8, 2022
@bouthilx bouthilx mentioned this pull request Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves a feature or non-functional aspects (e.g., optimization, prettify, technical debt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants