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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log model config if provided #11880

Merged
merged 6 commits into from
May 2, 2024
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
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
Loading