Skip to content

Commit 53eff54

Browse files
BordaSkafteNicki
andauthored
Apply suggestions from code review
Co-authored-by: Nicki Skafte Detlefsen <[email protected]>
1 parent 24e844d commit 53eff54

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

requirements/pytorch/test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ fastapi # for `ServableModuleValidator` # not setting version as re-defined in
1818
uvicorn # for `ServableModuleValidator` # not setting version as re-defined in App
1919

2020
tensorboard >=2.9.1, <2.21.0 # for `TensorBoardLogger`
21-
mlflow
21+
mlflow >=3.0.0, <4.0 # for `MLFlowLogger

src/lightning/pytorch/loggers/mlflow.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def any_lightning_module_function_or_hook(self):
110110
If required MLFlow package is not installed on the device.
111111
112112
Note:
113-
As of vX.XX, MLFlowLogger will skip logging any metric (same name and step)
113+
MLFlowLogger will skip logging any metric (same name and step)
114114
more than once per run, to prevent database unique constraint violations on
115115
some MLflow backends (such as PostgreSQL). Only the first value for each (metric, step)
116-
pair will be logged per run. This improves robustness for all users.
116+
pair will be logged per run.
117117
118118
"""
119119

@@ -157,7 +157,7 @@ def __init__(
157157
from mlflow.tracking import MlflowClient
158158

159159
self._mlflow_client = MlflowClient(tracking_uri)
160-
self._logged_metrics = set() # Track (key, step)
160+
self._logged_metrics: Set[Tuple[str, float]] = set() # Track (key, step)
161161

162162
@property
163163
@rank_zero_experiment
@@ -275,6 +275,7 @@ def log_metrics(self, metrics: Mapping[str, float], step: Optional[int] = None)
275275
)
276276
k = new_k
277277

278+
# Prevent trying to log duplicate metric value
278279
metric_id = (k, step or 0)
279280
if metric_id in self._logged_metrics:
280281
continue

0 commit comments

Comments
 (0)