Skip to content
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

Capture status in mlflow logger #3355

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
24 changes: 18 additions & 6 deletions composer/loggers/mlflow_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import pathlib
import posixpath
import sys
import textwrap
import time
import warnings
Expand Down Expand Up @@ -487,13 +488,24 @@ def log_images(
)

def post_close(self):
if self._enabled:
import mlflow
import pdb
pdb.set_trace()
if not self._enabled or self._run_id is None:
return

assert isinstance(self._run_id, str)
mlflow.flush_async_logging()
self._mlflow_client.set_terminated(self._run_id)
mlflow.end_run()
import mlflow

exc_tpe, exc_info, tb = sys.exc_info()
if (exc_tpe, exc_info, tb) == (None, None, None):
status = 'FINISHED'
else:
status = 'FAILED'

log.info(f'Finishing MLflow run with status {status}')
mlflow.flush_async_logging()

self._mlflow_client.set_terminated(self._run_id, status=status)
mlflow.end_run(status=status)


def _convert_to_mlflow_image(image: Union[np.ndarray, torch.Tensor], channels_last: bool) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion tests/loggers/test_mlflow_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def before_forward(self, state: State, logger: Logger):
)

trainer.fit()
test_mlflow_logger.post_close()
# test_mlflow_logger.post_close()

run = _get_latest_mlflow_run(
experiment_name=experiment_name,
Expand Down
Loading