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

A few log level handling cleanups #6393

Merged
merged 4 commits into from
Mar 5, 2025

Conversation

jcrist
Copy link
Member

@jcrist jcrist commented Mar 4, 2025

This PR does two things:

  1. Centralize verbose <-> log level handling

Previously we had conversion to/from the logger.level_enum and verbose parameters strewn across the codebase. We now centralize this in 2 common utility functions. In the future we should also aim to reduce the number of places where we need to handle this at all, but for now this is a slight improvement.

  1. Properly translate verbose to level_enum in simpl_set.pyx

Previously we weren't translating verbose to level_enum in the simpl_set functions. This meant that the default value (False) would be cast to level_enum, resulting in the logger being set to 0 (trace).

This doesn't fix the larger issue that our verbose handling mutates the global logger settings. It does ensure we're at least mutating it to the correct enum value though.

jcrist added 2 commits March 4, 2025 20:59
Previously we had conversion to/from the `logger.level_enum` and
`verbose` parameters strewn across the codebase. We now centralize this
in 2 common utility functions. In the future we should also aim to
reduce the number of places where we need to handle this at all, but for
now this is a slight improvement.
Previously we weren't translating `verbose` to `level_enum` in the
`simpl_set` functions. This meant that the default value (`False`)
would be cast to `level_enum`, resulting in the logger being set to `0`
(trace).

This doesn't fix the larger issue that our `verbose` handling mutates
the global logger settings. It does ensure we're at least translating
things correctly though.
@jcrist jcrist requested a review from a team as a code owner March 4, 2025 21:26
@jcrist jcrist requested review from csadorf and wphicks March 4, 2025 21:26
@github-actions github-actions bot added the Cython / Python Cython or Python issue label Mar 4, 2025
@jcrist jcrist added bug Something isn't working non-breaking Non-breaking change Cython / Python Cython or Python issue and removed Cython / Python Cython or Python issue labels Mar 4, 2025
return level_enum(6 - verbose)


def _verbose_from_level(level: level_enum) -> int:
Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally these would be methods on the level_enum enum (e.g. level_enum.from_verbose(verbose)...), but cython doesn't seem to like any of the ways I wanted to spell this. Leaving these as internal utils for now.

@jcrist
Copy link
Member Author

jcrist commented Mar 5, 2025

/merge

@rapids-bot rapids-bot bot merged commit fbcaf12 into rapidsai:branch-25.04 Mar 5, 2025
67 of 68 checks passed
@jcrist jcrist deleted the cleanup-log-level-handling branch March 5, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Cython / Python Cython or Python issue non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants