Repository: Lightning-AI/pytorch-lightning

Issue:
log_save_interval doesn't have the intended effect
<!-- 
### Common bugs:
1. Tensorboard not showing in Jupyter-notebook see [issue 79](https://github.com/PyTorchLightning/pytorch-lightning/issues/79).    
2. PyTorch 1.1.0 vs 1.2.0 support [see FAQ](https://github.com/PyTorchLightning/pytorch-lightning#faq)    
-->

## 🐛 Bug

I'm using the `MLFlowLogger` class for logging, and initially, I noticed my training loop slowed down immensely when changing the tracking URI from my local file system to a remote mlflow server (which makes sense). To fix this, I saw in the pytorch lightning docs that `log_save_interval` can be used to change the frequency at which logs are written and `row_log_interval` can be used to change the frequency at which rows are added to the logs. However, I found that `log_save_interval` has no effect on speeding up the training loop, and only `row_log_interval` speeds up the training loop.

### To Reproduce

Steps to reproduce the behavior:

1. Take any training loop and log metrics to a remote server (in this case for mlflow)
2. Manipulate log_save_interval and row_log_interval to see the effect

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->


#### Code sample
<!-- Ideally attach a minimal code sample to reproduce the decried issue. 
Minimal means having the shortest code but still preserving the bug. -->

The behavior makes sense when looking at sections of the pytorch lightning codebase.
In `pytorch_lightning/trainer/training_loop.py`:
```
            # when logs should be saved
            should_save_log = (batch_idx + 1) % self.log_save_interval == 0 or early_stop_epoch
            if should_save_log or self.fast_dev_run:
                if self.proc_rank == 0 and self.logger is not None:
                    self.logger.save()

            # when metrics should be logged
            should_log_metrics = batch_idx % self.row_log_interval == 0 or early_stop_epoch
            if should_log_metrics or self.fast_dev_run:
                # logs user requested information to logger
                self.log_metrics(batch_step_metrics, grad_norm_dic)
```
From the above, it can be seen that `log_save_interval` is not used to control when metrics are logged. From what I can tell `self.log_metrics` leads to a call to:
```
self.logger.agg_and_log_metrics(scalar_metrics, step=step)
```
in `pytorch_lightning/trainer/logging.py` which for mlflow causes a write to the remote server.

### Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

I expected `log_save_interval` to reduce the amount of remote writes, but it does not.

### Environment

```
* CUDA:
        - GPU:
        - available:         False
        - version:           None
* Packages:
        - numpy:             1.18.1
        - pyTorch_debug:     False
        - pyTorch_version:   1.4.0
        - pytorch-lightning: 0.7.5
        - tensorboard:       2.2.1
        - tqdm:              4.46.0
* System:
        - OS:                Darwin
        - architecture:
                - 64bit
                - 
        - processor:         i386
        - python:            3.8.2
        - version:           Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64
```

### Additional context

<!-- Add any other context about the problem here. -->
I'm aware my pytorch lightning version is behind the latest (due to an issue with 0.7.6 which seems to have been fixed in master), but my code samples are from the latest code.


Discussion:
Hi! thanks for your contribution!, great first issue!
Had a quick look and it seems that this trainer flag does not apply to all loggers. AFAIK In MLFlow, there is no distinction between adding rows and saving the logs. It probably only applies to the TensorBoard logger. 
We could think about documenting this fact or pulling it out of the Trainer and make it an argument of the TensorBoardLogger.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


Resolving patch:
diff --git a/pytorch_lightning/trainer/__init__.py b/pytorch_lightning/trainer/__init__.py
--- a/pytorch_lightning/trainer/__init__.py
+++ b/pytorch_lightning/trainer/__init__.py
@@ -581,6 +581,9 @@ def on_train_end(self, trainer, pl_module):
     # default used by the Trainer
     trainer = Trainer(log_save_interval=100)
 
+See Also:
+    - :ref:`Experiment Reporting <experiment_reporting>`
+
 logger
 ^^^^^^
 
@@ -913,6 +916,10 @@ def on_train_end(self, trainer, pl_module):
     # default used by the Trainer
     trainer = Trainer(row_log_interval=50)
 
+See Also:
+    - :ref:`Experiment Reporting <experiment_reporting>`
+
+
 sync_batchnorm
 ^^^^^^^^^^^^^^
 


Test patch: