Skip to content

Commit

Permalink
Fix add environment variable to disable mlflow configuring logging on…
Browse files Browse the repository at this point in the history
… import

Setting MLFLOW_LOGGING_CONFIGURE_LOGGING to false disables mlflow from
configuring logging on import, which may not be desired.

Closes #11132

Signed-off-by: Justin Mahlik <38999128+jmahlik@users.noreply.github.com>
  • Loading branch information
jmahlik committed Feb 19, 2024
1 parent f1db418 commit 1ca8562
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mlflow/__init__.py
Expand Up @@ -32,6 +32,9 @@
from mlflow.version import VERSION

__version__ = VERSION
from mlflow.environment_variables import MLFLOW_CONFIGURE_LOGGING

Check failure on line 35 in mlflow/__init__.py

View workflow job for this annotation

GitHub Actions / lint

[*] Import block is un-sorted or un-formatted. Run `ruff --fix .` to fix this error.
from mlflow.utils.lazy_load import LazyLoader
from mlflow.utils.logging_utils import _configure_mlflow_loggers

from mlflow import (
artifacts, # noqa: F401
Expand Down Expand Up @@ -82,7 +85,8 @@
transformers = LazyLoader("mlflow.transformers", globals(), "mlflow.transformers")
xgboost = LazyLoader("mlflow.xgboost", globals(), "mlflow.xgboost")

_configure_mlflow_loggers(root_module_name=__name__)
if MLFLOW_CONFIGURE_LOGGING.get() is True:
_configure_mlflow_loggers(root_module_name=__name__)

from mlflow.client import MlflowClient
from mlflow.exceptions import MlflowException
Expand Down
6 changes: 6 additions & 0 deletions mlflow/environment_variables.py
Expand Up @@ -511,3 +511,9 @@ def get(self):
MLFLOW_GATEWAY_RATE_LIMITS_STORAGE_URI = _EnvironmentVariable(
"MLFLOW_GATEWAY_RATE_LIMITS_STORAGE_URI", str, None
)

#: Specifies whether or not to have mlflow configure logging on import.
#: If set to True, mlflow will configure ``mlflow.<module_name>`` loggers with
#: logging handlers and formatters.
#: (default: ``True``)
MLFLOW_CONFIGURE_LOGGING = _BooleanEnvironmentVariable("MLFLOW_LOGGING_CONFIGURE_LOGGING", True)

0 comments on commit 1ca8562

Please sign in to comment.