From b2201cf0504a6be22c279f9c68321a0c1d8556d2 Mon Sep 17 00:00:00 2001 From: Justin Goheen <26209687+JustinGoheen@users.noreply.github.com> Date: Sat, 16 Jul 2022 22:11:10 -0400 Subject: [PATCH 1/7] update pyproject.toml for ci code-check --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 989e63122f640..8187bbd3507c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,6 @@ module = [ "pytorch_lightning.demos.boring_classes", "pytorch_lightning.demos.mnist_datamodule", "pytorch_lightning.loggers.comet", - "pytorch_lightning.loggers.mlflow", "pytorch_lightning.loggers.neptune", "pytorch_lightning.loggers.tensorboard", "pytorch_lightning.loggers.wandb", From 3fef7391e0a6ad885d882da9d092e49a4e1e7282 Mon Sep 17 00:00:00 2001 From: Justin Goheen <26209687+JustinGoheen@users.noreply.github.com> Date: Sat, 16 Jul 2022 23:03:58 -0400 Subject: [PATCH 2/7] update type hints --- src/pytorch_lightning/loggers/mlflow.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pytorch_lightning/loggers/mlflow.py b/src/pytorch_lightning/loggers/mlflow.py index b8ce0ef423a31..9efe936dee975 100644 --- a/src/pytorch_lightning/loggers/mlflow.py +++ b/src/pytorch_lightning/loggers/mlflow.py @@ -50,7 +50,17 @@ from mlflow.tracking.context.registry import resolve_tags else: - def resolve_tags(tags=None): + def resolve_tags(tags: Optional[Dict] = None) -> Optional[Dict]: + """ + Args: + tags: A dictionary of tags to override. If specified, tags passed in this argument will + override those inferred from the context. + + Returns: A dictionary of resolved tags. + + Note: + See ``mlflow.tracking.context.registry`` for more details. + """ return tags @@ -129,7 +139,7 @@ def __init__( tracking_uri = f"{LOCAL_FILE_URI_PREFIX}{save_dir}" self._experiment_name = experiment_name - self._experiment_id = None + self._experiment_id: Optional[str] = None self._tracking_uri = tracking_uri self._run_name = run_name self._run_id = run_id @@ -141,7 +151,7 @@ def __init__( self._mlflow_client = MlflowClient(tracking_uri) - @property + @property # type: ignore[misc] @rank_zero_experiment def experiment(self) -> MlflowClient: r""" @@ -194,7 +204,7 @@ def run_id(self) -> str: The run id. """ _ = self.experiment - return self._run_id + return self._run_id # type: ignore[return-value] @property def experiment_id(self) -> str: @@ -204,7 +214,7 @@ def experiment_id(self) -> str: The experiment id. """ _ = self.experiment - return self._experiment_id + return self._experiment_id # type: ignore[return-value] @rank_zero_only def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None: @@ -250,7 +260,7 @@ def finalize(self, status: str = "FINISHED") -> None: self.experiment.set_terminated(self.run_id, status) @property - def save_dir(self) -> Optional[str]: + def save_dir(self) -> str: """The root file directory in which MLflow experiments are saved. Return: From 5952527705eb3a706156c6e2ca6ceb0bae5f9f3f Mon Sep 17 00:00:00 2001 From: Justin Goheen <26209687+JustinGoheen@users.noreply.github.com> Date: Mon, 18 Jul 2022 15:29:11 -0400 Subject: [PATCH 3/7] update --- src/pytorch_lightning/loggers/logger.py | 4 ++-- src/pytorch_lightning/loggers/mlflow.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pytorch_lightning/loggers/logger.py b/src/pytorch_lightning/loggers/logger.py index 03d934aa58760..df1f0ef1ef7c6 100644 --- a/src/pytorch_lightning/loggers/logger.py +++ b/src/pytorch_lightning/loggers/logger.py @@ -203,12 +203,12 @@ def group_separator(self) -> str: @property @abstractmethod - def name(self) -> str: + def name(self) -> Optional[str]: """Return the experiment name.""" @property @abstractmethod - def version(self) -> Union[int, str]: + def version(self) -> Union[int, Optional[str]]: """Return the experiment version.""" diff --git a/src/pytorch_lightning/loggers/mlflow.py b/src/pytorch_lightning/loggers/mlflow.py index 9efe936dee975..7f3390709acae 100644 --- a/src/pytorch_lightning/loggers/mlflow.py +++ b/src/pytorch_lightning/loggers/mlflow.py @@ -197,24 +197,24 @@ def experiment(self) -> MlflowClient: return self._mlflow_client @property - def run_id(self) -> str: + def run_id(self) -> Optional[str]: """Create the experiment if it does not exist to get the run id. Returns: The run id. """ _ = self.experiment - return self._run_id # type: ignore[return-value] + return self._run_id @property - def experiment_id(self) -> str: + def experiment_id(self) -> Optional[str]: """Create the experiment if it does not exist to get the experiment id. Returns: The experiment id. """ _ = self.experiment - return self._experiment_id # type: ignore[return-value] + return self._experiment_id @rank_zero_only def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None: @@ -271,7 +271,7 @@ def save_dir(self) -> str: return self._tracking_uri.lstrip(LOCAL_FILE_URI_PREFIX) @property - def name(self) -> str: + def name(self) -> Optional[str]: """Get the experiment id. Returns: @@ -280,7 +280,7 @@ def name(self) -> str: return self.experiment_id @property - def version(self) -> str: + def version(self) -> Optional[str]: """Get the run id. Returns: From 3964e93276b971c52041fe182f698bcd0a76c1e6 Mon Sep 17 00:00:00 2001 From: Justin Goheen <26209687+JustinGoheen@users.noreply.github.com> Date: Mon, 18 Jul 2022 15:55:12 -0400 Subject: [PATCH 4/7] revert save_dir change --- 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 7f3390709acae..313fcfe07f10e 100644 --- a/src/pytorch_lightning/loggers/mlflow.py +++ b/src/pytorch_lightning/loggers/mlflow.py @@ -260,7 +260,7 @@ def finalize(self, status: str = "FINISHED") -> None: self.experiment.set_terminated(self.run_id, status) @property - def save_dir(self) -> str: + def save_dir(self) -> Optional[str]: """The root file directory in which MLflow experiments are saved. Return: From acbfad34847e11b5c67ead31315a54043bf8f7ef Mon Sep 17 00:00:00 2001 From: Justin Goheen <26209687+JustinGoheen@users.noreply.github.com> Date: Mon, 18 Jul 2022 17:06:22 -0400 Subject: [PATCH 5/7] Update src/pytorch_lightning/loggers/logger.py Co-authored-by: Jirka Borovec --- src/pytorch_lightning/loggers/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/loggers/logger.py b/src/pytorch_lightning/loggers/logger.py index df1f0ef1ef7c6..525feee9e587c 100644 --- a/src/pytorch_lightning/loggers/logger.py +++ b/src/pytorch_lightning/loggers/logger.py @@ -208,7 +208,7 @@ def name(self) -> Optional[str]: @property @abstractmethod - def version(self) -> Union[int, Optional[str]]: + def version(self) -> Union[int, str, None]: """Return the experiment version.""" From 08415ee74de831da9a94479a874607e3259c3e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Wed, 20 Jul 2022 12:28:23 +0200 Subject: [PATCH 6/7] Update src/pytorch_lightning/loggers/logger.py --- src/pytorch_lightning/loggers/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytorch_lightning/loggers/logger.py b/src/pytorch_lightning/loggers/logger.py index 525feee9e587c..56bf4660c29dd 100644 --- a/src/pytorch_lightning/loggers/logger.py +++ b/src/pytorch_lightning/loggers/logger.py @@ -208,7 +208,7 @@ def name(self) -> Optional[str]: @property @abstractmethod - def version(self) -> Union[int, str, None]: + def version(self) -> Optional[Union[int, str]]: """Return the experiment version.""" From 0fe85a12f59cc8e3e434a88a513cbfd152b1ba8e Mon Sep 17 00:00:00 2001 From: otaj Date: Wed, 20 Jul 2022 18:26:47 +0200 Subject: [PATCH 7/7] empty