From e51abd10f77a8738de4b047b86471cc7b1775fc6 Mon Sep 17 00:00:00 2001 From: Brian Pulfer Date: Wed, 18 Jan 2023 10:54:53 +0100 Subject: [PATCH 1/4] Solved minor bug (Issue #16411). --- src/pytorch_lightning/loggers/mlflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/loggers/mlflow.py b/src/pytorch_lightning/loggers/mlflow.py index bbed562283326..980d4e4bccb9e 100644 --- a/src/pytorch_lightning/loggers/mlflow.py +++ b/src/pytorch_lightning/loggers/mlflow.py @@ -247,7 +247,7 @@ def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None: f"Mlflow only allows parameters with up to 250 characters. Discard {k}={v}", category=RuntimeWarning ) continue - params_list.append(Param(key=v, value=v)) + params_list.append(Param(key=k, value=v)) self.experiment.log_batch(run_id=self.run_id, params=params_list) From 270e5935043a9adc8e175d07462b88a67f1a92e2 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Thu, 19 Jan 2023 20:45:19 +0100 Subject: [PATCH 2/4] add test that fails without fix --- tests/tests_pytorch/loggers/test_mlflow.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/tests_pytorch/loggers/test_mlflow.py b/tests/tests_pytorch/loggers/test_mlflow.py index d6828901a9961..23de563270cfe 100644 --- a/tests/tests_pytorch/loggers/test_mlflow.py +++ b/tests/tests_pytorch/loggers/test_mlflow.py @@ -253,8 +253,9 @@ def test_mlflow_logger_experiment_calls(client, _, time, param, metric, tmpdir): logger.log_hyperparams(params) logger.experiment.log_batch.assert_called_once_with( - run_id=logger.run_id, params=[param(key="test_param", value="test_param")] + run_id=logger.run_id, params=[param(key="test", value="test_param")] ) + param.assert_called_with(key="test", value="test_param") metrics = {"some_metric": 10} logger.log_metrics(metrics) @@ -262,6 +263,7 @@ def test_mlflow_logger_experiment_calls(client, _, time, param, metric, tmpdir): logger.experiment.log_batch.assert_called_with( run_id=logger.run_id, metrics=[metric(key="some_metric", value=10, timestamp=1000, step=0)] ) + metric.assert_called_with(key="some_metric", value=10, timestamp=1000, step=0) logger._mlflow_client.create_experiment.assert_called_once_with( name="test", artifact_location="my_artifact_location" From 47f1ceb502814b770363ee0be0192637d089cd73 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Thu, 19 Jan 2023 20:46:31 +0100 Subject: [PATCH 3/4] add changelog --- src/lightning_fabric/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning_fabric/CHANGELOG.md b/src/lightning_fabric/CHANGELOG.md index f1357e2c08a31..97898f45f356b 100644 --- a/src/lightning_fabric/CHANGELOG.md +++ b/src/lightning_fabric/CHANGELOG.md @@ -29,7 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Fixed -- +- Fixed an issue with `MLFlowLogger` logging the wrong keys with `.log_hyperparams()` ([#16418](https://github.com/Lightning-AI/lightning/pull/16418)) ## [1.9.0] - 2023-01-17 From 857f67d7ac6929f04fddbe7cfde16136b9c1ba36 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Thu, 19 Jan 2023 20:52:36 +0100 Subject: [PATCH 4/4] wrong changelog --- src/lightning_fabric/CHANGELOG.md | 2 +- src/pytorch_lightning/CHANGELOG.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lightning_fabric/CHANGELOG.md b/src/lightning_fabric/CHANGELOG.md index 97898f45f356b..f1357e2c08a31 100644 --- a/src/lightning_fabric/CHANGELOG.md +++ b/src/lightning_fabric/CHANGELOG.md @@ -29,7 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Fixed -- Fixed an issue with `MLFlowLogger` logging the wrong keys with `.log_hyperparams()` ([#16418](https://github.com/Lightning-AI/lightning/pull/16418)) +- ## [1.9.0] - 2023-01-17 diff --git a/src/pytorch_lightning/CHANGELOG.md b/src/pytorch_lightning/CHANGELOG.md index 5455ce9099869..5195a0e21b5cc 100644 --- a/src/pytorch_lightning/CHANGELOG.md +++ b/src/pytorch_lightning/CHANGELOG.md @@ -130,6 +130,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed an unintended limitation for calling `save_hyperparameters` on mixin classes that don't subclass `LightningModule`/`LightningDataModule` ([#16369](https://github.com/Lightning-AI/lightning/pull/16369)) +- Fixed an issue with `MLFlowLogger` logging the wrong keys with `.log_hyperparams()` ([#16418](https://github.com/Lightning-AI/lightning/pull/16418)) + + ## [1.9.0] - 2023-01-17