def test_autologging_event_logger_default_impl_warns_for_log_autolog_called_with_deprecated_args(): AutologgingEventLogger.set_logger(AutologgingEventLogger()) with pytest.warns(DeprecationWarning, match="Received 1 positional arguments"): AutologgingEventLogger.get_logger().log_autolog_called( "test_integration", # call_args is deprecated in MLflow > 1.13.1; specifying a non-empty # value for this parameter should emit a warning call_args=("a"), call_kwargs={"b": "c"}, )
def mock_event_logger(): try: prev_logger = AutologgingEventLogger.get_logger() logger = MockEventLogger() AutologgingEventLogger.set_logger(logger) yield logger finally: AutologgingEventLogger.set_logger(prev_logger)
def test_autologging_event_logger_default_implementation_does_not_throw_for_valid_inputs(): AutologgingEventLogger.set_logger(AutologgingEventLogger()) class PatchObj: def test_fn(self): pass # Test successful autologging workflow AutologgingEventLogger.get_logger().log_autolog_called( "test_integration", ("a"), {"b": 1, "c": "d"} ) AutologgingEventLogger.get_logger().log_patch_function_start( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) AutologgingEventLogger.get_logger().log_original_function_start( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) AutologgingEventLogger.get_logger().log_original_function_success( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) AutologgingEventLogger.get_logger().log_patch_function_success( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) # Test patch function failure autologging workflow AutologgingEventLogger.get_logger().log_patch_function_start( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) AutologgingEventLogger.get_logger().log_patch_function_error( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2}, Exception("patch error"), ) # Test original function failure autologging workflow AutologgingEventLogger.get_logger().log_patch_function_start( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) AutologgingEventLogger.get_logger().log_original_function_start( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2} ) AutologgingEventLogger.get_logger().log_patch_function_error( AutologgingSession("test_integration", "123"), PatchObj(), "test_fn", (1000), {"a": 2}, Exception("patch error"), )