diff --git a/CHANGELOG.md b/CHANGELOG.md index 09e99c44dda4f..87943bbbb4ab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Increased TPU check timeout from 20s to 100s ([#5598](https://github.com/PyTorchLightning/pytorch-lightning/pull/5598)) +- Ignored `step` param in Neptune logger's log_metric method ([#5510](https://github.com/PyTorchLightning/pytorch-lightning/pull/5510)) + + ### Deprecated diff --git a/pytorch_lightning/loggers/neptune.py b/pytorch_lightning/loggers/neptune.py index b7077b7d3e6fe..cd8185d6cdd49 100644 --- a/pytorch_lightning/loggers/neptune.py +++ b/pytorch_lightning/loggers/neptune.py @@ -252,13 +252,15 @@ def log_metrics( Args: metrics: Dictionary with metric names as keys and measured quantities as values - step: Step number at which the metrics should be recorded, must be strictly increasing + step: Step number at which the metrics should be recorded, currently ignored """ assert rank_zero_only.rank == 0, 'experiment tried to log from global_rank != 0' metrics = self._add_prefix(metrics) for key, val in metrics.items(): - self.log_metric(key, val, step=step) + # `step` is ignored because Neptune expects strictly increasing step values which + # Lighting does not always guarantee. + self.log_metric(key, val) @rank_zero_only def finalize(self, status: str) -> None: @@ -318,7 +320,7 @@ def log_text(self, log_name: str, text: str, step: Optional[int] = None) -> None text: The value of the log (data-point). step: Step number at which the metrics should be recorded, must be strictly increasing """ - self.log_metric(log_name, text, step=step) + self.experiment.log_text(log_name, text, step=step) @rank_zero_only def log_image(self, diff --git a/tests/loggers/test_all.py b/tests/loggers/test_all.py index 4bf15ff8d99a1..5dfb9476011c5 100644 --- a/tests/loggers/test_all.py +++ b/tests/loggers/test_all.py @@ -353,7 +353,7 @@ def test_logger_with_prefix_all(tmpdir, monkeypatch): with mock.patch('pytorch_lightning.loggers.neptune.neptune'): logger = _instantiate_logger(NeptuneLogger, save_idr=tmpdir, prefix=prefix) logger.log_metrics({"test": 1.0}, step=0) - logger.experiment.log_metric.assert_called_once_with("tmp-test", x=0, y=1.0) + logger.experiment.log_metric.assert_called_once_with("tmp-test", 1.0) # TensorBoard with mock.patch('pytorch_lightning.loggers.tensorboard.SummaryWriter'): diff --git a/tests/loggers/test_neptune.py b/tests/loggers/test_neptune.py index 515b463e10c4f..661baf810cba7 100644 --- a/tests/loggers/test_neptune.py +++ b/tests/loggers/test_neptune.py @@ -76,8 +76,8 @@ def test_neptune_additional_methods(neptune): created_experiment.log_metric.reset_mock() logger.log_text('test', 'text') - created_experiment.log_metric.assert_called_once_with('test', 'text') - created_experiment.log_metric.reset_mock() + created_experiment.log_text.assert_called_once_with('test', 'text', step=None) + created_experiment.log_text.reset_mock() logger.log_image('test', 'image file') created_experiment.log_image.assert_called_once_with('test', 'image file')