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

Update mlflow with using resolve_tags #6746

Merged
merged 8 commits into from
Apr 8, 2021
Merged
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
17 changes: 15 additions & 2 deletions pytorch_lightning/loggers/mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@
try:
import mlflow
from mlflow.tracking import MlflowClient
from mlflow.tracking import context
# todo: there seems to be still some remaining import error with Conda env
except ImportError:
_MLFLOW_AVAILABLE = False
mlflow, MlflowClient = None, None
mlflow, MlflowClient, context = None, None, None


# before v1.1.0
if hasattr(context, 'resolve_tags'):
from mlflow.tracking.context import resolve_tags
# since v1.1.0
elif hasattr(context, 'registry'):
from mlflow.tracking.context.registry import resolve_tags
else:

def resolve_tags(tags=None):
return tags


class MLFlowLogger(LightningLoggerBase):
Expand Down Expand Up @@ -140,7 +153,7 @@ def experiment(self) -> MlflowClient:
)

if self._run_id is None:
run = self._mlflow_client.create_run(experiment_id=self._experiment_id, tags=self.tags)
run = self._mlflow_client.create_run(experiment_id=self._experiment_id, tags=resolve_tags(self.tags))
self._run_id = run.info.run_id
return self._mlflow_client

Expand Down