Skip to content

fix: make mlflow logging more stable #1651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions mmengine/visualization/vis_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,11 @@ def add_image(self,
should be RGB.
step (int): Global step value to record. Default to 0.
"""
self._mlflow.log_image(image, name)
try:
self._mlflow.log_image(image, name)
except self._mlflow.MlflowException as e:
msg = f'Could not log image {name} to mlflow, {e}'
print_log(msg, level=logging.WARNING)

@force_init_env
def add_scalar(self,
Expand All @@ -796,7 +800,11 @@ def add_scalar(self,
value (int, float, torch.Tensor, np.ndarray): Value to save.
step (int): Global step value to record. Default to 0.
"""
self._mlflow.log_metric(name, value, step)
try:
self._mlflow.log_metric(name, value, step)
except self._mlflow.MlflowException as e:
msg = f'Could not log metric {name} to mlflow, {e}'
print_log(msg, level=logging.WARNING)

@force_init_env
def add_scalars(self,
Expand All @@ -816,7 +824,11 @@ def add_scalars(self,
assert isinstance(scalar_dict, dict)
assert 'step' not in scalar_dict, 'Please set it directly ' \
'through the step parameter'
self._mlflow.log_metrics(scalar_dict, step)
try:
self._mlflow.log_metrics(scalar_dict, step)
except self._mlflow.MlflowException as e:
msg = f'Could not log metrics to mlflow, {e}'
print_log(msg, level=logging.WARNING)

def close(self) -> None:
"""Close the mlflow."""
Expand Down
1 change: 1 addition & 0 deletions requirements/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pyyaml
regex;sys_platform=='win32'
rich
termcolor
torch<2.6.0
yapf