Skip to content

Commit

Permalink
Don't log autolog success message if disable=True (mlflow#4050)
Browse files Browse the repository at this point in the history
  • Loading branch information
apurva-koti authored Feb 4, 2021
1 parent a0e51b7 commit d14062f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mlflow/tracking/fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/tracking/fluent/test_fluent_autolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit d14062f

Please sign in to comment.