Skip to content

Commit

Permalink
Log model config if provided (mlflow#11880)
Browse files Browse the repository at this point in the history
Signed-off-by: Prithvi Kannan <[email protected]>
  • Loading branch information
prithvikannan authored May 2, 2024
1 parent f4a200e commit d38872e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mlflow/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,21 @@ def log(
):
_logger.warning(_LOG_MODEL_MISSING_SIGNATURE_WARNING)
mlflow.tracking.fluent.log_artifacts(local_path, mlflow_model.artifact_path, run_id)

# if the model_config kwarg is passed in, then log the model config as an params
if "model_config" in kwargs:
model_config = kwargs["model_config"]
if isinstance(model_config, str):
try:
with open(model_config) as f:
model_config = json.load(f)
except Exception as e:
_logger.warning("Failed to load model config from %s: %s", model_config, e)
try:
mlflow.tracking.fluent.log_params(model_config)
except Exception as e:
_logger.warning("Failed to log model config as params: %s", str(e))

try:
mlflow.tracking.fluent._record_logged_model(mlflow_model, run_id)
except MlflowException:
Expand Down

0 comments on commit d38872e

Please sign in to comment.