Skip to content

Commit

Permalink
🔊 Improve error message for MlflowModelTrackingDataset.save when a ru…
Browse files Browse the repository at this point in the history
…n id is already active (#549)
  • Loading branch information
Galileo-Galilei committed Aug 26, 2024
1 parent 0e4fe31 commit cefe506
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions kedro_mlflow/io/models/mlflow_model_tracking_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ def _save(self, model: Any) -> None:
if mlflow.active_run():
# it is not possible to log in a run which is not the current opened one
raise DatasetError(
"'run_id' cannot be specified"
" if there is an mlflow active run."
"Run_id mismatch: "
f"\n - 'run_id'={self._run_id}"
f"\n - active_run id={mlflow.active_run().info.run_id}"
f"'run_id' cannot be specified (run_id='{self._run_id}') "
f"if there is an mlflow active run (active run id='{mlflow.active_run().info.run_id}') "
f"See the rationale in this issue: https://github.com/Galileo-Galilei/kedro-mlflow/issues/549."
)
else:
# if the run id is specified and there is no opened run,
Expand Down
2 changes: 1 addition & 1 deletion tests/io/models/test_mlflow_model_tracking_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_save_sklearn_flavor_with_run_id_and_already_active_run(tracking_uri):
with mlflow.start_run():
with pytest.raises(
DatasetError,
match="'run_id' cannot be specified if there is an mlflow active run.",
match="if there is an mlflow active run",
):
mlflow_model_ds.save(linreg_model)

Expand Down

0 comments on commit cefe506

Please sign in to comment.