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 15, 2024
1 parent a030e40 commit 69fb02f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mlflow/__init__.py
Expand Up @@ -34,6 +34,7 @@
# See: https://github.com/numpy/numpy/pull/432/commits/170ed4e33d6196d7
import warnings

from mlflow.environment_variables import MLFLOW_CONFIGURE_LOGGING
from mlflow.utils.lazy_load import LazyLoader
from mlflow.utils.logging_utils import _configure_mlflow_loggers
from mlflow.version import VERSION as __version__ # noqa: F401
Expand Down Expand Up @@ -88,7 +89,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 69fb02f

Please sign in to comment.