diff --git a/mlflow/tracking/fluent.py b/mlflow/tracking/fluent.py index d0c1ea29bf276..d62c44cd99dad 100644 --- a/mlflow/tracking/fluent.py +++ b/mlflow/tracking/fluent.py @@ -1341,7 +1341,8 @@ def setup_autologging(module): autolog_fn = LIBRARY_TO_AUTOLOG_FN[module.__name__] autologging_params = get_autologging_params(autolog_fn) autolog_fn(**autologging_params) - _logger.info("Autologging successfully enabled for %s.", module.__name__) + if not autologging_params.get("disable", False): + _logger.info("Autologging successfully enabled for %s.", module.__name__) except Exception as e: if _is_testing(): # Raise unexpected exceptions in test mode in order to detect diff --git a/tests/tracking/fluent/test_fluent_autolog.py b/tests/tracking/fluent/test_fluent_autolog.py index 465304ba53637..1475cf6f82b10 100644 --- a/tests/tracking/fluent/test_fluent_autolog.py +++ b/tests/tracking/fluent/test_fluent_autolog.py @@ -192,3 +192,20 @@ def log_autolog_called(self, integration, call_args, call_kwargs): call = universal_autolog_event_logging_calls[0] assert call.integration == "mlflow" assert {"disable": True, "exclusive": True}.items() <= call.call_kwargs.items() + + +def test_autolog_success_message_obeys_disabled(): + with mock.patch("mlflow.tracking.fluent._logger.info") as autolog_logger_mock: + mlflow.autolog(disable=True) + mlflow.utils.import_hooks.notify_module_loaded(tensorflow) + autolog_logger_mock.assert_not_called() + + mlflow.autolog() + mlflow.utils.import_hooks.notify_module_loaded(tensorflow) + autolog_logger_mock.assert_called() + + autolog_logger_mock.reset_mock() + + mlflow.autolog(disable=False) + mlflow.utils.import_hooks.notify_module_loaded(tensorflow) + autolog_logger_mock.assert_called()