Repository: Lightning-AI/pytorch-lightning
Pull request: Improve DummyLogger
## What does this PR do?

Fixes #6395

This PR makes the methods in `DummyLogger` accept arbitrary positional and keyword inputs.
The new test fails on master.

## Before submitting
- [x] Was this discussed/approved via a GitHub issue? (not for typos and docs)
- [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?
- [x] Did you make sure to update the documentation with your changes? (if necessary)
- [x] Did you write any new necessary tests? (not for typos and docs)
- [x] Did you verify new and existing tests pass locally with your changes?
- [ ] Did you update the [CHANGELOG](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/CHANGELOG.md)? (not for typos, docs, test updates, or internal minor changes/refactorings)

<!-- For CHANGELOG separate each item in the unreleased section by a blank line to reduce collisions -->

## PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read [Review guidelines](https://github.com/PyTorchLightning/pytorch-lightning/wiki/Review-guidelines). In short, see the following bullet-list:

 - [x] Is this pull request ready for review? (if not, please submit in draft mode)
 - [x] Check that all items from **Before submitting** are resolved
 - [x] Make sure the title is self-explanatory and the description concisely explains the PR
 - [x] Add labels and milestones (and optionally projects) to the PR so it can be classified

## Did you have fun?
Make sure you had fun coding 🙃


Problem statement:
fast_dev_run fail on log_hyperparams
## 🐛 Bug
Issue when running: `fast_dev_run=True`
"TypeError: log_hyperparams() takes 2 positional arguments but 3 were given"

### To Reproduce

When using the following: Where self.hp_metrics is a list of strings where each string is an available metric that is being logged, example "accuracy/val".
```
def on_train_start(self):
        if self.logger:
            self.logger.log_hyperparams(self.hparams, {metric:0 for metric in self.hp_metrics})
```
### Expected behavior

Assume the unit test is wrong since the documentation say that self.logger.log_hyperparams takes one positional argument and one dictionary. The code run fine without fast_dev_run=True and everything is logged correctly to tensorboard.

### Environment

pytorch_lightning 1.2.2

Hints from issue discussion:
```python
import torch
from torch.utils.data import Dataset

from pytorch_lightning import LightningModule, Trainer


class RandomDataset(Dataset):


    def __init__(self, size, length):
        self.len = length
        self.data = torch.randn(length, size)

    def __getitem__(self, index):
        return self.data[index]

    def __len__(self):
        return self.len


class BoringModel(LightningModule):

    def __init__(self):

        super().__init__()
        self.layer = torch.nn.Linear(32, 2)

    def forward(self, x):
        return self.layer(x)

    def training_step(self, batch, batch_idx):
        output = self.layer(batch)
        return output.sum()

    def configure_optimizers(self):
        optimizer = torch.optim.SGD(self.layer.parameters(), lr=0.1)
        return optimizer

    def on_train_start(self):
        if self.logger:
            self.logger.log_hyperparams(self.hparams, {"x": 0})


if __name__ == '__main__':
    train_data = torch.utils.data.DataLoader(RandomDataset(32, 64))
    model = BoringModel()
    trainer = Trainer(fast_dev_run=True)
    trainer.fit(model, train_data)
```
minimal repro example

Commit message: add changelog

Patch to review:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed7eec7cff7f9..56f87493f5085 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -110,7 +110,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 - Fixed PyTorch Profiler with `emit_nvtx` ([#6260](https://github.com/PyTorchLightning/pytorch-lightning/pull/6260))
 
 
-- Fixed `trainer.test` from `best_path` hangs after calling `trainer.fit`  ([#6272](https://github.com/PyTorchLightning/pytorch-lightning/pull/6272))
+- Fixed `DummyLogger.log_hyperparams` raising a `TypeError` when running with `fast_dev_run=True` ([#6398](https://github.com/PyTorchLightning/pytorch-lightning/pull/6398))
 
 
 ## [1.2.2] - 2021-03-02
diff --git a/pytorch_lightning/loggers/base.py b/pytorch_lightning/loggers/base.py
index 4fdb5e8c437bf..af08758750fdc 100644
--- a/pytorch_lightning/loggers/base.py
+++ b/pytorch_lightning/loggers/base.py
@@ -279,12 +279,14 @@ def _sanitize_params(params: Dict[str, Any]) -> Dict[str, Any]:
         return params
 
     @abstractmethod
-    def log_hyperparams(self, params: argparse.Namespace):
+    def log_hyperparams(self, params: argparse.Namespace, *args, **kwargs):
         """
         Record hyperparameters.
 
         Args:
             params: :class:`~argparse.Namespace` containing the hyperparameters
+            args: Optional positional arguments, depends on the specific logger being used
+            kwargs: Optional keywoard arguments, depends on the specific logger being used
         """
 
     def log_graph(self, model: LightningModule, input_array=None) -> None:
@@ -418,30 +420,29 @@ def nop(*args, **kw):
     def __getattr__(self, _):
         return self.nop
 
-    def __getitem__(self, idx):
-        # enables self.logger[0].experiment.add_image
-        # and self.logger.experiment[0].add_image(...)
+    def __getitem__(self, idx) -> "DummyExperiment":
+        # enables self.logger.experiment[0].add_image(...)
         return self
 
 
 class DummyLogger(LightningLoggerBase):
-    """ Dummy logger for internal use. Is usefull if we want to disable users
-        logger for a feature, but still secure that users code can run """
+    """
+    Dummy logger for internal use. It is useful if we want to disable user's
+    logger for a feature, but still ensure that user code can run
+    """
 
     def __init__(self):
         super().__init__()
         self._experiment = DummyExperiment()
 
     @property
-    def experiment(self):
+    def experiment(self) -> DummyExperiment:
         return self._experiment
 
-    @rank_zero_only
-    def log_metrics(self, metrics, step):
+    def log_metrics(self, *args, **kwargs):
         pass
 
-    @rank_zero_only
-    def log_hyperparams(self, params):
+    def log_hyperparams(self, *args, **kwargs):
         pass
 
     @property
@@ -452,7 +453,8 @@ def name(self):
     def version(self):
         pass
 
-    def __getitem__(self, idx):
+    def __getitem__(self, idx) -> "DummyLogger":
+        # enables self.logger[0].experiment.add_image(...)
         return self
 
 
diff --git a/tests/loggers/test_base.py b/tests/loggers/test_base.py
index c48fef5e04b49..cf3a0cb74b3f4 100644
--- a/tests/loggers/test_base.py
+++ b/tests/loggers/test_base.py
@@ -229,15 +229,24 @@ def log_metrics(self, metrics, step):
 
 
 def test_dummyexperiment_support_indexing():
+    """ Test that the DummyExperiment can imitate indexing the experiment in a LoggerCollection. """
     experiment = DummyExperiment()
     assert experiment[0] == experiment
 
 
 def test_dummylogger_support_indexing():
+    """ Test that the DummyLogger can imitate indexing of a LoggerCollection. """
     logger = DummyLogger()
     assert logger[0] == logger
 
 
+def test_dummylogger_noop_method_calls():
+    """ Test that the DummyLogger methods can be called with arbitrary arguments. """
+    logger = DummyLogger()
+    logger.log_hyperparams("1", 2, three="three")
+    logger.log_metrics("1", 2, three="three")
+
+
 def test_np_sanitization():
 
     class CustomParamsLogger(CustomLogger):


Code review comments:
diff_hunk: @@ -452,7 +453,8 @@ def name(self):
     def version(self):
path: pytorch_lightning/loggers/base.py
text: @user1:
the return values for name/version don't match the base interface

@author:
don't know how to cleanly address this. 
one could make version and name optional in the base class, but then again they are not really optional

@user1:
For the purposes of the dummy logger, should we return empty string and 0?