Repository: Lightning-AI/pytorch-lightning
Pull request: fix logging error
# Before submitting

- [ ] Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
- [x] Did you read the [contributor guideline](https://github.com/williamFalcon/pytorch-lightning/blob/master/.github/CONTRIBUTING.md)?
- [ ] Did you make sure to update the docs?   
- [ ] Did you write any new necessary tests?  

## What does this PR do?
Fixes #574 


Problem statement:
Error in `logging` call `pt_callbacks.py`
Stack trace: 

```
....
[00:04<00:00,  1.83s/batch, batch_nb=1, loss=0.478, v_nb=13--- Logging error ---
Traceback (most recent call last):
  File "/Users/kdang/.pyenv/versions/3.6.7/lib/python3.6/logging/__init__.py", line 994, in emit
    msg = self.format(record)
  File "/Users/kdang/.pyenv/versions/3.6.7/lib/python3.6/logging/__init__.py", line 840, in format
    return fmt.format(record)
  File "/Users/kdang/.pyenv/versions/3.6.7/lib/python3.6/logging/__init__.py", line 577, in format
    record.message = record.getMessage()
  File "/Users/kdang/.pyenv/versions/3.6.7/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "edge_regressor_lightning.py", line 172, in <module>
    cli()
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "edge_regressor_lightning.py", line 166, in train
    trainer.fit(model)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 366, in fit
    self.run_pretrain_routine(model)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 474, in run_pretrain_routine
    self.train()
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/pytorch_lightning/trainer/train_loop_mixin.py", line 211, in train
    self.run_training_epoch()
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/pytorch_lightning/trainer/train_loop_mixin.py", line 265, in run_training_epoch
    self.run_evaluation(test=self.testing)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/pytorch_lightning/trainer/evaluation_loop_mixin.py", line 286, in run_evaluation
    logs=self.callback_metrics)
  File "/Users/kdang/.pyenv/versions/id_detection_ssd/lib/python3.6/site-packages/pytorch_lightning/callbacks/pt_callbacks.py", line 317, in on_epoch_end
    f'{filepath} as top {self.save_top_k}')
Message: '\nEpoch 00010: val_loss reached'
```

This is due to problem errors on these lines
```
                        if self.verbose > 0:
                            logging.info(
                                f'\nEpoch {epoch:05d}: {self.monitor} reached ',
                                f'{current:0.5f} (best {self.best:0.5f}), saving model to ',
                                f'{filepath} as top {self.save_top_k}')
                        self._save_model(filepath)

                    else:
                        if self.verbose > 0:
                            logging.info(
                                f'\nEpoch {epoch:05d}: {self.monitor} ',
                                f'was not in top {self.save_top_k}')
```

The fix is simple. just need to change `,` to `+` for string concatenation

Hints from issue discussion:

Commit message: fix logging error

Patch to review:
diff --git a/pytorch_lightning/callbacks/pt_callbacks.py b/pytorch_lightning/callbacks/pt_callbacks.py
index c55a48849696f..29279541ee571 100644
--- a/pytorch_lightning/callbacks/pt_callbacks.py
+++ b/pytorch_lightning/callbacks/pt_callbacks.py
@@ -312,15 +312,15 @@ def on_epoch_end(self, epoch, logs=None):
                             self.best = max(self.best_k_models.values())
                         if self.verbose > 0:
                             logging.info(
-                                f'\nEpoch {epoch:05d}: {self.monitor} reached',
-                                f'{current:0.5f} (best {self.best:0.5f}), saving model to',
+                                f'\nEpoch {epoch:05d}: {self.monitor} reached '+
+                                f'{current:0.5f} (best {self.best:0.5f}), saving model to '+
                                 f'{filepath} as top {self.save_top_k}')
                         self._save_model(filepath)
 
                     else:
                         if self.verbose > 0:
                             logging.info(
-                                f'\nEpoch {epoch:05d}: {self.monitor}',
+                                f'\nEpoch {epoch:05d}: {self.monitor} '+
                                 f'was not in top {self.save_top_k}')
 
             else:


Code review comments:
diff_hunk: @@ -312,15 +312,15 @@ def on_epoch_end(self, epoch, logs=None):
                             self.best = max(self.best_k_models.values())
                         if self.verbose > 0:
                             logging.info(
-                                f'\nEpoch {epoch:05d}: {self.monitor} reached',
-                                f'{current:0.5f} (best {self.best:0.5f}), saving model to',
+                                f'\nEpoch {epoch:05d}: {self.monitor} reached '+
path: pytorch_lightning/callbacks/pt_callbacks.py
text: @user1:
just drop `,` the `+` is not needed... :)

@author:
done :D