From 5abd8e0e745f2b15c6c6a83cba471ebefbe2b83e Mon Sep 17 00:00:00 2001 From: puhuk Date: Wed, 4 Sep 2024 22:18:23 +0900 Subject: [PATCH 1/5] To fix #3277 To fix #3277 , replace `_VALID_PARAM_AND_METRIC_NAMES ` to regular expression from `mlflow` https://github.com/mlflow/mlflow/blob/d6625d6df85b61f3661ba90efc36f94511a5c23f/mlflow/utils/validation.py#L15C1-L15C60 --- ignite/handlers/mlflow_logger.py | 3 ++- requirements-dev.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ignite/handlers/mlflow_logger.py b/ignite/handlers/mlflow_logger.py index 68a996d8fb1..45461e4f966 100644 --- a/ignite/handlers/mlflow_logger.py +++ b/ignite/handlers/mlflow_logger.py @@ -9,6 +9,7 @@ from ignite.handlers.base_logger import BaseLogger, BaseOptimizerParamsHandler, BaseOutputHandler from ignite.handlers.utils import global_step_from_engine # noqa +import re __all__ = ["MLflowLogger", "OutputHandler", "OptimizerParamsHandler", "global_step_from_engine"] @@ -245,7 +246,7 @@ def __call__(self, engine: Engine, logger: MLflowLogger, event_name: Union[str, ) # Additionally recheck metric names as MLflow rejects non-valid names with MLflowException - from mlflow.utils.validation import _VALID_PARAM_AND_METRIC_NAMES + _VALID_PARAM_AND_METRIC_NAMES = re.compile(r"^[/\w.\- ]*$") metrics = {} for keys, value in rendered_metrics.items(): diff --git a/requirements-dev.txt b/requirements-dev.txt index 732a0544b71..d475e556cdf 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -17,7 +17,7 @@ tensorboardX visdom polyaxon wandb -mlflow<2.16.0 # https://github.com/pytorch/ignite/issues/3277 +mlflow neptune-client>=0.16.17 tensorboard torchvision From 011d8b7cc5cf06462a6a2df964912362b9521ad0 Mon Sep 17 00:00:00 2001 From: puhuk Date: Wed, 4 Sep 2024 13:18:57 +0000 Subject: [PATCH 2/5] autopep8 fix --- ignite/handlers/mlflow_logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ignite/handlers/mlflow_logger.py b/ignite/handlers/mlflow_logger.py index 45461e4f966..e6c0fccb4ed 100644 --- a/ignite/handlers/mlflow_logger.py +++ b/ignite/handlers/mlflow_logger.py @@ -1,5 +1,6 @@ """MLflow logger and its helper handlers.""" +import re import warnings from typing import Any, Callable, List, Optional, Union @@ -9,7 +10,6 @@ from ignite.handlers.base_logger import BaseLogger, BaseOptimizerParamsHandler, BaseOutputHandler from ignite.handlers.utils import global_step_from_engine # noqa -import re __all__ = ["MLflowLogger", "OutputHandler", "OptimizerParamsHandler", "global_step_from_engine"] From 8a005467e4fcc9eea30e1587753e6b6dfdeb89bc Mon Sep 17 00:00:00 2001 From: puhuk Date: Wed, 4 Sep 2024 23:29:04 +0900 Subject: [PATCH 3/5] Update mlflow_logger.py --- ignite/handlers/mlflow_logger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ignite/handlers/mlflow_logger.py b/ignite/handlers/mlflow_logger.py index 45461e4f966..256f7c2bd1c 100644 --- a/ignite/handlers/mlflow_logger.py +++ b/ignite/handlers/mlflow_logger.py @@ -246,7 +246,7 @@ def __call__(self, engine: Engine, logger: MLflowLogger, event_name: Union[str, ) # Additionally recheck metric names as MLflow rejects non-valid names with MLflowException - _VALID_PARAM_AND_METRIC_NAMES = re.compile(r"^[/\w.\- ]*$") + from mlflow.utils.validation import validate_param_and_metric_name metrics = {} for keys, value in rendered_metrics.items(): @@ -254,7 +254,7 @@ def __call__(self, engine: Engine, logger: MLflowLogger, event_name: Union[str, metrics[key] = value for key in list(metrics.keys()): - if not _VALID_PARAM_AND_METRIC_NAMES.match(key): + if not validate_param_and_metric_name(key): warnings.warn( f"MLflowLogger output_handler encountered an invalid metric name '{key}' that " "will be ignored and not logged to MLflow" From fd623d70d61dcbc5681f19ae977166acd4e45e7f Mon Sep 17 00:00:00 2001 From: vfdev Date: Wed, 4 Sep 2024 16:32:37 +0200 Subject: [PATCH 4/5] Update ignite/handlers/mlflow_logger.py --- ignite/handlers/mlflow_logger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ignite/handlers/mlflow_logger.py b/ignite/handlers/mlflow_logger.py index 5d7167ba7a0..916f51bd687 100644 --- a/ignite/handlers/mlflow_logger.py +++ b/ignite/handlers/mlflow_logger.py @@ -1,6 +1,5 @@ """MLflow logger and its helper handlers.""" -import re import warnings from typing import Any, Callable, List, Optional, Union From 72648122d5de3ac8f5e8ac3e8068f62d22d191f3 Mon Sep 17 00:00:00 2001 From: puhuk Date: Wed, 4 Sep 2024 23:50:48 +0900 Subject: [PATCH 5/5] Update mlflow_logger.py Remove `import re` --- ignite/handlers/mlflow_logger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ignite/handlers/mlflow_logger.py b/ignite/handlers/mlflow_logger.py index 5d7167ba7a0..916f51bd687 100644 --- a/ignite/handlers/mlflow_logger.py +++ b/ignite/handlers/mlflow_logger.py @@ -1,6 +1,5 @@ """MLflow logger and its helper handlers.""" -import re import warnings from typing import Any, Callable, List, Optional, Union