Skip to content

Commit e3b29cb

Browse files
jxtngxBordaotaj
authored
Fix mypy errors attributed to pytorch_lightning.loggers.mlflow (#13691)
Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: otaj <[email protected]>
1 parent 3474626 commit e3b29cb

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ module = [
5858
"pytorch_lightning.demos.boring_classes",
5959
"pytorch_lightning.demos.mnist_datamodule",
6060
"pytorch_lightning.loggers.comet",
61-
"pytorch_lightning.loggers.mlflow",
6261
"pytorch_lightning.loggers.neptune",
6362
"pytorch_lightning.loggers.wandb",
6463
"pytorch_lightning.profilers.advanced",

src/pytorch_lightning/loggers/logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ def group_separator(self) -> str:
203203

204204
@property
205205
@abstractmethod
206-
def name(self) -> str:
206+
def name(self) -> Optional[str]:
207207
"""Return the experiment name."""
208208

209209
@property
210210
@abstractmethod
211-
def version(self) -> Union[int, str]:
211+
def version(self) -> Optional[Union[int, str]]:
212212
"""Return the experiment version."""
213213

214214

src/pytorch_lightning/loggers/mlflow.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@
5050
from mlflow.tracking.context.registry import resolve_tags
5151
else:
5252

53-
def resolve_tags(tags=None):
53+
def resolve_tags(tags: Optional[Dict] = None) -> Optional[Dict]:
54+
"""
55+
Args:
56+
tags: A dictionary of tags to override. If specified, tags passed in this argument will
57+
override those inferred from the context.
58+
59+
Returns: A dictionary of resolved tags.
60+
61+
Note:
62+
See ``mlflow.tracking.context.registry`` for more details.
63+
"""
5464
return tags
5565

5666

@@ -129,7 +139,7 @@ def __init__(
129139
tracking_uri = f"{LOCAL_FILE_URI_PREFIX}{save_dir}"
130140

131141
self._experiment_name = experiment_name
132-
self._experiment_id = None
142+
self._experiment_id: Optional[str] = None
133143
self._tracking_uri = tracking_uri
134144
self._run_name = run_name
135145
self._run_id = run_id
@@ -141,7 +151,7 @@ def __init__(
141151

142152
self._mlflow_client = MlflowClient(tracking_uri)
143153

144-
@property
154+
@property # type: ignore[misc]
145155
@rank_zero_experiment
146156
def experiment(self) -> MlflowClient:
147157
r"""
@@ -187,7 +197,7 @@ def experiment(self) -> MlflowClient:
187197
return self._mlflow_client
188198

189199
@property
190-
def run_id(self) -> str:
200+
def run_id(self) -> Optional[str]:
191201
"""Create the experiment if it does not exist to get the run id.
192202
193203
Returns:
@@ -197,7 +207,7 @@ def run_id(self) -> str:
197207
return self._run_id
198208

199209
@property
200-
def experiment_id(self) -> str:
210+
def experiment_id(self) -> Optional[str]:
201211
"""Create the experiment if it does not exist to get the experiment id.
202212
203213
Returns:
@@ -261,7 +271,7 @@ def save_dir(self) -> Optional[str]:
261271
return self._tracking_uri.lstrip(LOCAL_FILE_URI_PREFIX)
262272

263273
@property
264-
def name(self) -> str:
274+
def name(self) -> Optional[str]:
265275
"""Get the experiment id.
266276
267277
Returns:
@@ -270,7 +280,7 @@ def name(self) -> str:
270280
return self.experiment_id
271281

272282
@property
273-
def version(self) -> str:
283+
def version(self) -> Optional[str]:
274284
"""Get the run id.
275285
276286
Returns:

0 commit comments

Comments
 (0)