Skip to content

Commit

Permalink
Added function to log a matplotlib.plt directly to mlflow
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjandevries committed Dec 30, 2020
1 parent 1bd950f commit 7123d3f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/myautoml/utils/mlflow/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from yaml import safe_load

import joblib
import matplotlib.pyplot as plt
import mlflow
import mlflow.sklearn
from mlflow.entities import RunInfo
Expand Down Expand Up @@ -143,3 +144,9 @@ def log_sk_model(sk_model,
for local_path, artifact_path in artifacts.items():
_logger.debug(f"Logging artifact to MLflow: {local_path} - {artifact_path}")
mlflow.log_artifact(local_path, artifact_path)


def log_plt(artifact_path):
with tempfile.NamedTemporaryFile() as file:
plt.savefig(file.name)
mlflow.log_artifact(file.name, artifact_path)

0 comments on commit 7123d3f

Please sign in to comment.