Repository: Lightning-AI/pytorch-lightning
Pull request: Fix info message when EarlyStopping 'mode' not provided [ci skip]
## What does this PR do?

Fix info message when EarlyStopping 'mode' not provided

<!--
Please include a summary of the change and which issue is fixed.
 Please also include relevant motivation and context.
 List any dependencies that are required for this change.
-->

Fixes #4268 

## Before submitting
- [x] Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
- [x] Did you read the [contributor guideline](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/.github/CONTRIBUTING.md), Pull Request section?
- [x] Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
- [x] Did you make sure to update the documentation with your changes?
- [x] Did you write any new necessary tests? 
- [x] Did you verify new and existing tests pass locally with your changes?
- [x] If you made a notable change (that affects users), did you update the [CHANGELOG](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/CHANGELOG.md)?

<!-- For CHANGELOG separate each item in unreleased section by a blank line to reduce collisions -->

## PR review
 - [x] Is this pull request ready for review? (if not, please submit in draft mode)

Anyone in the community is free to review the PR once the tests have passed.    
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

## Did you have fun?
Make sure you had fun coding 🙃


Problem statement:
EarlyStopping mode auto is unknown, fallback to auto mode.
In the process of refactoring as I upgraded lighting and it looks like there's been a slight change to the callback interface.

This code:

`early_stop_callback = pl.callbacks.EarlyStopping(verbose=True)`

Results in the message:

> EarlyStopping mode auto is unknown, fallback to auto mode.
> EarlyStopping mode set to min for monitoring early_stop_on.

The default for `mode` is 'auto' so the first message doesn't make sense

Hints from issue discussion:
Hey @david-waterworth,

Thanks for using Pytorch Lightning and finding this bug !

I think it should be this way.

```
EarlyStopping mode not provided, fallback to auto mode.
...
EarlyStopping mode set to min for monitoring early_stop_on.
```

Best regards,
Thomas Chaton.

Commit message: fixup! Fix info message when EarlyStopping 'mode' not provided

Patch to review:
diff --git a/pytorch_lightning/callbacks/early_stopping.py b/pytorch_lightning/callbacks/early_stopping.py
index 864d3d836ec43..1af1e6231d54f 100644
--- a/pytorch_lightning/callbacks/early_stopping.py
+++ b/pytorch_lightning/callbacks/early_stopping.py
@@ -88,7 +88,7 @@ def __init__(self, monitor: str = 'early_stop_on', min_delta: float = 0.0, patie
 
         if mode not in self.mode_dict:
             if self.verbose > 0:
-                log.info(f'EarlyStopping mode {mode} is unknown, fallback to auto mode.')
+                log.info("EarlyStopping mode not provided or set to 'auto'. Continuing with auto mode.")
             self.mode = 'auto'
 
         if self.mode == 'auto':


Code review comments:
diff_hunk: @@ -88,7 +88,7 @@ def __init__(self, monitor: str = 'early_stop_on', min_delta: float = 0.0, patie
 
         if mode not in self.mode_dict:
             if self.verbose > 0:
-                log.info(f'EarlyStopping mode {mode} is unknown, fallback to auto mode.')
+                log.info("EarlyStopping mode not provided or set to 'auto'. Continuing with auto mode.")
path: pytorch_lightning/callbacks/early_stopping.py
text: @user1:
```suggestion
                log.info(f'EarlyStopping mode {mode} is unknown, fallback to auto mode.')
```

diff_hunk: @@ -88,7 +88,7 @@ def __init__(self, monitor: str = 'early_stop_on', min_delta: float = 0.0, patie
 
         if mode not in self.mode_dict:
path: pytorch_lightning/callbacks/early_stopping.py
text: @user1:
I suggest this
```suggestion
        if mode not in self.mode_dict and mode != 'auto':
```