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

Fix logging issues that can arise when importing flaml #1377

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

kernelmethod
Copy link
Contributor

Previously, FLAML would automatically set its own loglevel when imported, overriding any other logging settings that may previously have been set by users of the library. FLAML will now check whether a loglevel has been explicitly set before setting its own.

In addition, the flaml.automl warning is now emitted using warnings rather than logging.warning. This falls more in line with other FLAML submodules (e.g. flaml.ml).

Taken in conjunction, these two changes make it a lot easier for downstream users to suppress warnings emitted by FLAML upon importing the library, either by configuring logging prior to importing flaml or by using the somewhat more idiomatic

with warnings.catch_warnings(action="ignore"):
    import flaml

This change also helps to ensure that FLAML's defaults won't override users' explicit logging settings.

Why are these changes needed?

These changes make it easier for downstream users to configure FLAML's logging utilities as they see fit, and make it easier to suppress certain warnings that may occur when importing flaml for the first time.

Related issue number

N/A

Checks

Previously, FLAML would automatically set its own loglevel when
imported, overriding any other logging settings that may previously have
been set by users of the library. FLAML will now check whether a
loglevel has been explicitly set before setting its own.

In addition, the `flaml.automl` warning is now emitted using `warnings`
rather than `logging.warning`. This falls more in line with other FLAML
submodules (e.g. `flaml.ml`).

Taken in conjunction, these two changes make it a lot easier for
downstream users to suppress warnings emitted by FLAML upon importing
the library, either by configuring logging prior to importing `flaml` or
by using the somewhat more idiomatic
```
with warnings.catch_warnings(action="ignore"):
    import flaml
```
This change also helps to ensure that FLAML's defaults won't override
users' explicit logging settings.
Copy link
Collaborator

@thinkall thinkall left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, @kernelmethod ! LGTM!

@thinkall thinkall merged commit 07f4413 into microsoft:main Nov 12, 2024
16 checks passed
@kernelmethod kernelmethod deleted the import-warnings-and-logging branch November 13, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants