From a052cf5ab6589f669c3d75b7e70cdf52fc4365ac Mon Sep 17 00:00:00 2001 From: Luca Moschella Date: Fri, 3 Dec 2021 13:53:02 +0100 Subject: [PATCH 1/6] Add __setitem__ to DummyExperiment --- pytorch_lightning/loggers/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pytorch_lightning/loggers/base.py b/pytorch_lightning/loggers/base.py index e5ccae435d8c9..0698a409762b4 100644 --- a/pytorch_lightning/loggers/base.py +++ b/pytorch_lightning/loggers/base.py @@ -474,6 +474,9 @@ def __getitem__(self, idx) -> "DummyExperiment": # enables self.logger.experiment[0].add_image(...) return self + def __setitem__(self, *args, **kwargs) -> None: + pass + class DummyLogger(LightningLoggerBase): """Dummy logger for internal use. From ae967046726f362afb2866bddda43490d0ac8d99 Mon Sep 17 00:00:00 2001 From: Luca Moschella Date: Fri, 3 Dec 2021 15:21:55 +0100 Subject: [PATCH 2/6] Test that the DummyExperiment supports item assignment --- tests/loggers/test_base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/loggers/test_base.py b/tests/loggers/test_base.py index d6b753c0439ee..faf9c0c99959a 100644 --- a/tests/loggers/test_base.py +++ b/tests/loggers/test_base.py @@ -241,6 +241,12 @@ def test_dummylogger_noop_method_calls(): logger.log_metrics("1", 2, three="three") +def test_dummyexperiment_support_item_assignment(): + """Test that the DummyExperiment supports item assignment""" + experiment = DummyExperiment() + experiment["variable"] = "value" + + def test_np_sanitization(): class CustomParamsLogger(CustomLogger): def __init__(self): From 4d80625c6ec68a443d651d2aeaaca0af958191d5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Dec 2021 14:23:28 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/loggers/test_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/loggers/test_base.py b/tests/loggers/test_base.py index faf9c0c99959a..f6feab12587f9 100644 --- a/tests/loggers/test_base.py +++ b/tests/loggers/test_base.py @@ -242,7 +242,7 @@ def test_dummylogger_noop_method_calls(): def test_dummyexperiment_support_item_assignment(): - """Test that the DummyExperiment supports item assignment""" + """Test that the DummyExperiment supports item assignment.""" experiment = DummyExperiment() experiment["variable"] = "value" From 5e335decca56678fd42b213a36ade028b9896501 Mon Sep 17 00:00:00 2001 From: Luca Moschella Date: Fri, 3 Dec 2021 15:51:27 +0100 Subject: [PATCH 4/6] Update tests/loggers/test_base.py Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com> --- tests/loggers/test_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/loggers/test_base.py b/tests/loggers/test_base.py index f6feab12587f9..88630a4fd3c97 100644 --- a/tests/loggers/test_base.py +++ b/tests/loggers/test_base.py @@ -245,7 +245,7 @@ def test_dummyexperiment_support_item_assignment(): """Test that the DummyExperiment supports item assignment.""" experiment = DummyExperiment() experiment["variable"] = "value" - + assert experiment["variable"] != "value" # this is only a stateless mock experiment def test_np_sanitization(): class CustomParamsLogger(CustomLogger): From 154aecfc82c60a80baada5cff7f3b2d5fa6a084e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Dec 2021 14:52:40 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/loggers/test_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/loggers/test_base.py b/tests/loggers/test_base.py index 88630a4fd3c97..f4a91f63b50c4 100644 --- a/tests/loggers/test_base.py +++ b/tests/loggers/test_base.py @@ -245,7 +245,8 @@ def test_dummyexperiment_support_item_assignment(): """Test that the DummyExperiment supports item assignment.""" experiment = DummyExperiment() experiment["variable"] = "value" - assert experiment["variable"] != "value" # this is only a stateless mock experiment + assert experiment["variable"] != "value" # this is only a stateless mock experiment + def test_np_sanitization(): class CustomParamsLogger(CustomLogger): From e81b7ebcc451a69f281a053ea30a607c8ce35e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Fri, 3 Dec 2021 18:02:25 +0100 Subject: [PATCH 6/6] add changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed0408bfbb15..0b631a7bb46a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -231,8 +231,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed a bug that caused incorrect batch indices to be passed to the `BasePredictionWriter` hooks when using a dataloader with `num_workers > 0` ([#10870](https://github.com/PyTorchLightning/pytorch-lightning/pull/10870)) - -- +- Fixed an issue with item assignment on the logger on rank > 0 for those who support it ([#10917](https://github.com/PyTorchLightning/pytorch-lightning/pull/10917))